[asterisk-commits] Add missing checks during startup. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 4 10:29:04 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: Add missing checks during startup.
......................................................................


Add missing checks during startup.

This ensures startup is canceled due to allocation failures from the
following initializations.
* channel.c: ast_channels_init
* config_options.c: aco_init

ASTERISK-26265 #close

Change-Id: I911ed08fa2a3be35de55903e0225957bcdbe9611
---
M include/asterisk/_private.h
M main/asterisk.c
M main/channel.c
3 files changed, 14 insertions(+), 6 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  Matthew Fredrickson: Looks good to me, but someone else must approve



diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h
index 6dbf24f..36b316f 100644
--- a/include/asterisk/_private.h
+++ b/include/asterisk/_private.h
@@ -29,7 +29,7 @@
 void clean_time_zones(void);			/*!< Provided by localtime.c */
 int ast_term_init(void);		/*!< Provided by term.c */
 int astdb_init(void);			/*!< Provided by db.c */
-void ast_channels_init(void);		/*!< Provided by channel.c */
+int ast_channels_init(void);		/*!< Provided by channel.c */
 void ast_builtins_init(void);		/*!< Provided by cli.c */
 int ast_cli_perms_init(int reload);	/*!< Provided by cli.c */
 int dnsmgr_init(void);			/*!< Provided by dnsmgr.c */
diff --git a/main/asterisk.c b/main/asterisk.c
index 850003b..05381fc 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -4452,7 +4452,10 @@
 		exit(1);
 	}
 
-	aco_init();
+	if (aco_init()) {
+		printf("Failed: aco_init\n%s", term_quit());
+		exit(1);
+	}
 
 	if (init_logger()) {		/* Start logging subsystem */
 		printf("Failed: init_logger\n%s", term_quit());
@@ -4546,7 +4549,10 @@
 		exit(1);
 	}
 
-	ast_channels_init();
+	if (ast_channels_init()) {
+		printf("Failed: ast_channels_init\n%s", term_quit());
+		exit(1);
+	}
 
 	if (ast_endpoint_init()) {
 		printf ("Failed: ast_endpoint_init\n%s", term_quit());
diff --git a/main/channel.c b/main/channel.c
index 911c269..1f18d53 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -7803,13 +7803,14 @@
 	ast_channel_unregister(&surrogate_tech);
 }
 
-void ast_channels_init(void)
+int ast_channels_init(void)
 {
 	channels = ao2_container_alloc(NUM_CHANNEL_BUCKETS,
 			ast_channel_hash_cb, ast_channel_cmp_cb);
-	if (channels) {
-		ao2_container_register("channels", channels, prnt_channel_key);
+	if (!channels) {
+		return -1;
 	}
+	ao2_container_register("channels", channels, prnt_channel_key);
 
 	ast_channel_register(&surrogate_tech);
 
@@ -7823,6 +7824,7 @@
 
 	ast_register_cleanup(channels_shutdown);
 
+	return 0;
 }
 
 /*! \brief Print call group and pickup group ---*/

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I911ed08fa2a3be35de55903e0225957bcdbe9611
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>



More information about the asterisk-commits mailing list