Merge "rtp_engine/res_rtp_asterisk: Fix RTP struct reentrancy crashes."
[asterisk/asterisk.git] / res / res_ari_bridges.c
index e61865e..5402c2b 100644 (file)
@@ -1537,19 +1537,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",