diff options
author | Joshua Colp <jcolp@digium.com> | 2016-01-11 16:54:49 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-01-11 16:54:49 -0600 |
commit | 8ec4d20fa9907080c303efe7bd0527e055b7325d (patch) | |
tree | fba7d914f934dbb39a711b98c74f8d3ad373a54f | |
parent | ddc9c1f72089bb998a6b8689d8fe3f134e1d26ec (diff) | |
parent | 79b430988102eefed7d2ddb3655361df129a6216 (diff) |
Merge "pbx_dundi: Run cleanup on failed load." into 13
-rw-r--r-- | pbx/pbx_dundi.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 04da24788..51801f45f 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -5014,30 +5014,31 @@ static int load_module(void) io = io_context_create(); sched = ast_sched_context_create(); - if (!io || !sched) - return AST_MODULE_LOAD_DECLINE; + if (!io || !sched) { + goto declined; + } - if (set_config("dundi.conf", &sin, 0)) - return AST_MODULE_LOAD_DECLINE; + if (set_config("dundi.conf", &sin, 0)) { + goto declined; + } netsocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if (netsocket < 0) { ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno)); - return AST_MODULE_LOAD_DECLINE; + goto declined; } if (bind(netsocket, (struct sockaddr *) &sin, sizeof(sin))) { ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), strerror(errno)); - return AST_MODULE_LOAD_DECLINE; + goto declined; } ast_set_qos(netsocket, tos, 0, "DUNDi"); if (start_network_thread()) { ast_log(LOG_ERROR, "Unable to start network thread\n"); - close(netsocket); - return AST_MODULE_LOAD_DECLINE; + goto declined; } ast_cli_register_multiple(cli_dundi, ARRAY_LEN(cli_dundi)); @@ -5050,6 +5051,10 @@ static int load_module(void) ast_verb(2, "DUNDi Ready and Listening on %s port %d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); return AST_MODULE_LOAD_SUCCESS; + +declined: + unload_module(); + return AST_MODULE_LOAD_DECLINE; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Distributed Universal Number Discovery (DUNDi)", |