[asterisk-commits] file: branch 1.4 r43454 -
/branches/1.4/channels/chan_mgcp.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Sep 21 15:12:09 MST 2006
Author: file
Date: Thu Sep 21 17:12:09 2006
New Revision: 43454
URL: http://svn.digium.com/view/asterisk?rev=43454&view=rev
Log:
Clean up chan_mgcp's module load function (issue #8001 reported by Mithraen with mods by moi)
Modified:
branches/1.4/channels/chan_mgcp.c
Modified: branches/1.4/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_mgcp.c?rev=43454&r1=43453&r2=43454&view=diff
==============================================================================
--- branches/1.4/channels/chan_mgcp.c (original)
+++ branches/1.4/channels/chan_mgcp.c Thu Sep 21 17:12:09 2006
@@ -4266,34 +4266,35 @@
/*! \brief load_module: PBX load module - initialization ---*/
static int load_module(void)
{
- int res;
-
- sched = sched_context_create();
- if (!sched) {
+ if (!(sched = sched_context_create())) {
ast_log(LOG_WARNING, "Unable to create schedule context\n");
- return -1;
- }
- io = io_context_create();
- if (!io) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+
+ if (!(io = io_context_create())) {
ast_log(LOG_WARNING, "Unable to create I/O context\n");
- return -1;
- }
-
- if (!(res = reload_config())) {
- /* Make sure we can register our mgcp channel type */
- if (ast_channel_register(&mgcp_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class 'MGCP'\n");
- return -1;
- }
- ast_rtp_proto_register(&mgcp_rtp);
- ast_cli_register_multiple(cli_mgcp, sizeof(cli_mgcp) / sizeof(struct ast_cli_entry));
-
- /* And start the monitor for the first time */
- restart_monitor();
- } else
+ sched_context_destroy(sched);
+ return AST_MODULE_LOAD_FAILURE;
+ }
+
+ if (reload_config())
return AST_MODULE_LOAD_DECLINE;
- return res;
+ /* Make sure we can register our mgcp channel type */
+ if (ast_channel_register(&mgcp_tech)) {
+ ast_log(LOG_ERROR, "Unable to register channel class 'MGCP'\n");
+ io_context_destroy(io);
+ sched_context_destroy(sched);
+ return AST_MODULE_LOAD_FAILURE;
+ }
+
+ ast_rtp_proto_register(&mgcp_rtp);
+ ast_cli_register_multiple(cli_mgcp, sizeof(cli_mgcp) / sizeof(struct ast_cli_entry));
+
+ /* And start the monitor for the first time */
+ restart_monitor();
+
+ return AST_MODULE_LOAD_SUCCESS;
}
/*! \brief mgcp_do_reload: Reload module */
More information about the asterisk-commits
mailing list