[Asterisk-code-review] Add missing checks during startup. (asterisk[11])
Corey Farrell
asteriskteam at digium.com
Wed Aug 3 15:43:31 CDT 2016
Corey Farrell has uploaded a new change for review.
https://gerrit.asterisk.org/3410
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
* format.c: ast_format_attr_init and ast_format_list_init
ASTERISK-26265 #close
Change-Id: I911ed08fa2a3be35de55903e0225957bcdbe9611
---
M include/asterisk/_private.h
M main/asterisk.c
M main/channel.c
3 files changed, 21 insertions(+), 6 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/10/3410/1
diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h
index 1bc2433..35bc14a 100644
--- a/include/asterisk/_private.h
+++ b/include/asterisk/_private.h
@@ -24,7 +24,7 @@
int init_framer(void); /*!< Provided by frame.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 0e33d0c..10f437b 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -4235,10 +4235,17 @@
threadstorage_init();
- ast_format_attr_init();
- ast_format_list_init();
- ast_rtp_engine_init();
+ if (ast_format_attr_init()) {
+ printf("Failed: ast_format_attr_init\n%s", term_quit());
+ exit(1);
+ }
+ if (ast_format_list_init()) {
+ printf("Failed: ast_format_list_init\n%s", term_quit());
+ exit(1);
+ }
+
+ ast_rtp_engine_init();
ast_autoservice_init();
if (ast_timing_init()) {
@@ -4272,7 +4279,10 @@
exit(1);
}
- ast_channels_init();
+ if (ast_channels_init()) {
+ printf("Failed: ast_channels_init\n%s", term_quit());
+ exit(1);
+ }
if ((moduleresult = load_modules(1))) { /* Load modules, pre-load only */
printf("Failed: load_modules(1)\n%s", term_quit());
diff --git a/main/channel.c b/main/channel.c
index af7845a..ecb2565 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -8671,10 +8671,13 @@
}
}
-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) {
+ return -1;
+ }
ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
@@ -8683,6 +8686,8 @@
ast_plc_reload();
ast_register_cleanup(channels_shutdown);
+
+ return 0;
}
/*! \brief Print call group and pickup group ---*/
--
To view, visit https://gerrit.asterisk.org/3410
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I911ed08fa2a3be35de55903e0225957bcdbe9611
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Corey Farrell <git at cfware.com>
More information about the asterisk-code-review
mailing list