Prevent CDR backends from unregistering while billing data is in flight
[asterisk/asterisk.git] / cdr / cdr_syslog.c
index e593812..de8cae4 100644 (file)
  * \ingroup cdr_drivers
  */
 
+/*! \li \ref cdr_syslog.c uses the configuration file \ref cdr_syslog.conf
+ * \addtogroup configuration_file Configuration Files
+ */
+
+/*!
+ * \page cdr_syslog.conf cdr_syslog.conf
+ * \verbinclude cdr_syslog.conf.sample
+ */
+
 /*** MODULEINFO
        <depend>syslog</depend>
        <support_level>core</support_level>
@@ -51,7 +60,7 @@ AST_THREADSTORAGE(syslog_buf);
 
 static const char name[] = "cdr-syslog";
 
-struct cdr_config {
+struct cdr_syslog_config {
        AST_DECLARE_STRING_FIELDS(
                AST_STRING_FIELD(ident);
                AST_STRING_FIELD(format);
@@ -59,14 +68,14 @@ struct cdr_config {
        int facility;
        int priority;
        ast_mutex_t lock;
-       AST_LIST_ENTRY(cdr_config) list;
+       AST_LIST_ENTRY(cdr_syslog_config) list;
 };
 
-static AST_RWLIST_HEAD_STATIC(sinks, cdr_config);
+static AST_RWLIST_HEAD_STATIC(sinks, cdr_syslog_config);
 
 static void free_config(void)
 {
-       struct cdr_config *sink;
+       struct cdr_syslog_config *sink;
        while ((sink = AST_RWLIST_REMOVE_HEAD(&sinks, list))) {
                ast_mutex_destroy(&sink->lock);
                ast_free(sink);
@@ -77,7 +86,7 @@ static int syslog_log(struct ast_cdr *cdr)
 {
        struct ast_channel *dummy;
        struct ast_str *str;
-       struct cdr_config *sink;
+       struct cdr_syslog_config *sink;
 
        /* Batching saves memory management here.  Otherwise, it's the same as doing an
           allocation and free each time. */
@@ -165,7 +174,7 @@ static int load_config(int reload)
        }
 
        while ((catg = ast_category_browse(cfg, catg))) {
-               struct cdr_config *sink;
+               struct cdr_syslog_config *sink;
 
                if (!strcasecmp(catg, "general")) {
                        continue;
@@ -177,7 +186,7 @@ static int load_config(int reload)
                        continue;
                }
 
-               sink = ast_calloc_with_stringfields(1, struct cdr_config, 1024);
+               sink = ast_calloc_with_stringfields(1, struct cdr_syslog_config, 1024);
 
                if (!sink) {
                        ast_log(AST_LOG_ERROR,
@@ -226,7 +235,9 @@ static int load_config(int reload)
 
 static int unload_module(void)
 {
-       ast_cdr_unregister(name);
+       if (ast_cdr_unregister(name)) {
+               return -1;
+       }
 
        if (AST_RWLIST_WRLOCK(&sinks)) {
                ast_cdr_register(name, ast_module_info->description, syslog_log);