]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Astobj2: Fix initialization order of refdebug and AO2_DEBUG. 28/328/3
authorCorey Farrell <git@cfware.com>
Fri, 1 May 2015 18:22:03 +0000 (14:22 -0400)
committerCorey Farrell <git@cfware.com>
Fri, 1 May 2015 19:40:45 +0000 (15:40 -0400)
This ensures that refdebug is initialized before AO2_DEBUG if
both are enabled, since AO2_DEBUG allocates a container.

This change also makes AO2_DEBUG initialization critical, a
failure will abort Asterisk startup.  This is needed since
the failure would be caused by reg_containers allocation
failure, and that would result in a segmentation fault by
ao2_container_register later in startup.

ASTERISK-25048 #close
Reported by: Corey Farrell

Change-Id: I9a243ea3fc5653b48b931ba6d61971cb2e530244

main/asterisk.c
main/astobj2.c

index 2b70a99b0c8595aea07af42d98e6bd37ac14e8dc..137ee931585be1fe3adb897b9e7b7221efebaa38 100644 (file)
@@ -4353,7 +4353,10 @@ int main(int argc, char *argv[])
        register_config_cli();
        read_config_maps();
 
-       astobj2_init();
+       if (astobj2_init()) {
+               printf("Failed: astobj2_init\n%s", term_quit());
+               exit(1);
+       }
 
        if (ast_opt_console) {
                if (el_hist == NULL || el == NULL)
index f1d5001748bd3635811fb22f3ca19d180d6460f6..1bb5237f1be2ae7a0442f1179f06c1348bf0e15e 100644 (file)
@@ -899,13 +899,7 @@ int astobj2_init(void)
 {
 #ifdef REF_DEBUG
        char ref_filename[1024];
-#endif
-
-       if (container_init() != 0) {
-               return -1;
-       }
 
-#ifdef REF_DEBUG
        snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR);
        ref_log = fopen(ref_filename, "w");
        if (!ref_log) {
@@ -913,6 +907,11 @@ int astobj2_init(void)
        }
 #endif
 
+       if (container_init() != 0) {
+               fclose(ref_log);
+               return -1;
+       }
+
 #if defined(AO2_DEBUG)
        ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
 #endif /* defined(AO2_DEBUG) */