Replace most uses of ast_register_atexit with ast_register_cleanup.
[asterisk/asterisk.git] / main / ccss.c
index 09fa2d1..7f63690 100644 (file)
@@ -52,6 +52,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/manager.h"
 #include "asterisk/causes.h"
 #include "asterisk/stasis_system.h"
+#include "asterisk/format_cache.h"
 
 /*** DOCUMENTATION
        <application name="CallCompletionRequest" language="en_US">
@@ -1031,8 +1032,15 @@ static int cc_publish(struct stasis_message_type *message_type, int core_id, str
        RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
        RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 
+       if (!message_type) {
+               return -1;
+       }
+
        blob = ast_json_pack("{s: i}",
                "core_id", core_id);
+       if (!blob) {
+               return -1;
+       }
 
        if (extras) {
                ast_json_object_update(blob, extras);
@@ -2814,8 +2822,7 @@ static void *generic_recall(void *data)
        const char *callback_macro = ast_get_cc_callback_macro(agent->cc_params);
        const char *callback_sub = ast_get_cc_callback_sub(agent->cc_params);
        unsigned int recall_timer = ast_get_cc_recall_timer(agent->cc_params) * 1000;
-       struct ast_format tmp_fmt;
-       struct ast_format_cap *tmp_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
+       struct ast_format_cap *tmp_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 
        if (!tmp_cap) {
                return NULL;
@@ -2826,17 +2833,17 @@ static void *generic_recall(void *data)
                *target++ = '\0';
        }
 
-       ast_format_cap_add(tmp_cap, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0));
+       ast_format_cap_append(tmp_cap, ast_format_slin, 0);
        if (!(chan = ast_request_and_dial(tech, tmp_cap, NULL, NULL, target, recall_timer, &reason, generic_pvt->cid_num, generic_pvt->cid_name))) {
                /* Hmm, no channel. Sucks for you, bud.
                 */
                ast_log_dynamic_level(cc_logger_level, "Core %u: Failed to call back %s for reason %d\n",
                                agent->core_id, agent->device_name, reason);
                ast_cc_failed(agent->core_id, "Failed to call back device %s/%s", tech, target);
-               ast_format_cap_destroy(tmp_cap);
+               ao2_ref(tmp_cap, -1);
                return NULL;
        }
-       ast_format_cap_destroy(tmp_cap);
+       ao2_ref(tmp_cap, -1);
        
        /* We have a channel. It's time now to set up the datastore of recalled CC interfaces.
         * This will be a common task for all recall functions. If it were possible, I'd have
@@ -4681,7 +4688,7 @@ int ast_cc_init(void)
        initialize_cc_devstate_map();
        res |= ast_devstate_prov_add("ccss", ccss_device_state);
 
-       ast_register_atexit(cc_shutdown);
+       ast_register_cleanup(cc_shutdown);
 
        return res;
 }