[asterisk-commits] Astobj2: Fix initialization order of refdebug and AO2 DEBUG. (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat May 2 10:17:26 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: Astobj2: Fix initialization order of refdebug and AO2_DEBUG.
......................................................................


Astobj2: Fix initialization order of refdebug and AO2_DEBUG.

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
---
M main/asterisk.c
M main/astobj2.c
2 files changed, 9 insertions(+), 7 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Matt Jordan: Looks good to me, approved; Verified



diff --git a/main/asterisk.c b/main/asterisk.c
index 2b70a99..137ee93 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -4353,7 +4353,10 @@
 	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)
diff --git a/main/astobj2.c b/main/astobj2.c
index f1d5001..1bb5237 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -899,13 +899,7 @@
 {
 #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 @@
 	}
 #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) */

-- 
To view, visit https://gerrit.asterisk.org/328
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9a243ea3fc5653b48b931ba6d61971cb2e530244
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list