]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
If the [csv] section does not exist in cdr.conf, then an unload/load sequence
authorTilghman Lesher <tilghman@meg.abyt.es>
Wed, 9 Apr 2008 18:57:33 +0000 (18:57 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Wed, 9 Apr 2008 18:57:33 +0000 (18:57 +0000)
is needed to correct the problem.  Track whether the load succeeded with a
variable, so we can fix this with a simple reload event, instead.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113874 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr/cdr_csv.c
configs/cdr.conf.sample

index 00b8de32084be89ac337a480fd228435cd7b4eae..527646e2987b36e8b60b116bf6e8489ddd348ef2 100644 (file)
@@ -57,6 +57,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 static int usegmtime = 0;
 static int loguniqueid = 0;
 static int loguserfield = 0;
+static int loaded = 0;
 static char *config = "cdr.conf";
 
 /* #define CSV_LOGUNIQUEID 1 */
@@ -324,6 +325,7 @@ static int csv_log(struct ast_cdr *cdr)
 static int unload_module(void)
 {
        ast_cdr_unregister(name);
+       loaded = 0;
        return 0;
 }
 
@@ -337,13 +339,21 @@ static int load_module(void)
        res = ast_cdr_register(name, ast_module_info->description, csv_log);
        if (res) {
                ast_log(LOG_ERROR, "Unable to register CSV CDR handling\n");
+       } else {
+               loaded = 1;
        }
        return res;
 }
 
 static int reload(void)
 {
-       load_config();
+       if (load_config()) {
+               loaded = 1;
+       } else {
+               loaded = 0;
+               ast_log(LOG_WARNING, "No [csv] section in cdr.conf.  Unregistering backend.\n");
+               ast_cdr_unregister(name);
+       }
 
        return 0;
 }
index c2882c1f0dc52371e437d6ef248d0a0e22fb0d8d..693b2809288534678bd5ec71866f54ce289d8123 100644 (file)
 
 [csv]
 usegmtime=yes    ; log date/time in GMT.  Default is "no"
-loguniqueid=yes  ; log uniqueid.  Default is "no
-loguserfield=yes ; log user field.  Default is "no
+loguniqueid=yes  ; log uniqueid.  Default is "no"
+loguserfield=yes ; log user field.  Default is "no"
 
 ;[radius]
 ;usegmtime=yes    ; log date/time in GMT