diff --git a/res/res_ari_applications.c b/res/res_ari_applications.c index ac2c3ba426..cb12e84c8c 100644 --- a/res/res_ari_applications.c +++ b/res/res_ari_applications.c @@ -492,19 +492,24 @@ static struct stasis_rest_handlers applications = { .children = { &applications_applicationName, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&applications); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&applications); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&applications); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Stasis application resources", diff --git a/res/res_ari_asterisk.c b/res/res_ari_asterisk.c index b1680e300a..1a574aaaf5 100644 --- a/res/res_ari_asterisk.c +++ b/res/res_ari_asterisk.c @@ -1213,19 +1213,24 @@ static struct stasis_rest_handlers asterisk = { .children = { &asterisk_config,&asterisk_info,&asterisk_modules,&asterisk_logging,&asterisk_variable, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&asterisk); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&asterisk); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&asterisk); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Asterisk resources", diff --git a/res/res_ari_bridges.c b/res/res_ari_bridges.c index 2889c15152..69d4d6ed5d 100644 --- a/res/res_ari_bridges.c +++ b/res/res_ari_bridges.c @@ -1405,19 +1405,24 @@ static struct stasis_rest_handlers bridges = { .children = { &bridges_bridgeId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&bridges); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&bridges); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&bridges); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Bridge resources", diff --git a/res/res_ari_channels.c b/res/res_ari_channels.c index fca0cef05d..f59f206346 100644 --- a/res/res_ari_channels.c +++ b/res/res_ari_channels.c @@ -2469,19 +2469,24 @@ static struct stasis_rest_handlers channels = { .children = { &channels_channelId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&channels); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&channels); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&channels); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Channel resources", diff --git a/res/res_ari_device_states.c b/res/res_ari_device_states.c index cf0b7a9896..a3711e6ebf 100644 --- a/res/res_ari_device_states.c +++ b/res/res_ari_device_states.c @@ -323,19 +323,24 @@ static struct stasis_rest_handlers deviceStates = { .children = { &deviceStates_deviceName, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&deviceStates); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&deviceStates); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&deviceStates); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Device state resources", diff --git a/res/res_ari_endpoints.c b/res/res_ari_endpoints.c index 4a5ddd9e2c..43d2558983 100644 --- a/res/res_ari_endpoints.c +++ b/res/res_ari_endpoints.c @@ -447,19 +447,24 @@ static struct stasis_rest_handlers endpoints = { .children = { &endpoints_sendMessage,&endpoints_tech, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&endpoints); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&endpoints); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&endpoints); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Endpoint resources", diff --git a/res/res_ari_events.c b/res/res_ari_events.c index 461b314047..fd208c57bc 100644 --- a/res/res_ari_events.c +++ b/res/res_ari_events.c @@ -448,7 +448,6 @@ static int load_module(void) res |= ast_websocket_server_add_protocol2(events.ws_server, protocol); stasis_app_ref(); res |= ast_ari_add_handler(&events); - if (res) { unload_module(); return AST_MODULE_LOAD_DECLINE; diff --git a/res/res_ari_mailboxes.c b/res/res_ari_mailboxes.c index 8e0648b8ab..f85541cf04 100644 --- a/res/res_ari_mailboxes.c +++ b/res/res_ari_mailboxes.c @@ -329,19 +329,24 @@ static struct stasis_rest_handlers mailboxes = { .children = { &mailboxes_mailboxName, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&mailboxes); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&mailboxes); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&mailboxes); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Mailboxes resources", diff --git a/res/res_ari_playbacks.c b/res/res_ari_playbacks.c index a0ebd66a38..25e211c551 100644 --- a/res/res_ari_playbacks.c +++ b/res/res_ari_playbacks.c @@ -281,19 +281,24 @@ static struct stasis_rest_handlers playbacks = { .children = { &playbacks_playbackId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&playbacks); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&playbacks); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&playbacks); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Playback control resources", diff --git a/res/res_ari_recordings.c b/res/res_ari_recordings.c index bdcf676811..29720a84aa 100644 --- a/res/res_ari_recordings.c +++ b/res/res_ari_recordings.c @@ -797,19 +797,24 @@ static struct stasis_rest_handlers recordings = { .children = { &recordings_stored,&recordings_live, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&recordings); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&recordings); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&recordings); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Recording resources", diff --git a/res/res_ari_sounds.c b/res/res_ari_sounds.c index 48fa204c52..6d09d2cbe0 100644 --- a/res/res_ari_sounds.c +++ b/res/res_ari_sounds.c @@ -211,19 +211,24 @@ static struct stasis_rest_handlers sounds = { .children = { &sounds_soundId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&sounds); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&sounds); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&sounds); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Sound resources",