From: Areski Belaid Date: Mon, 11 Nov 2019 16:23:20 +0000 (+0100) Subject: [mod_callcenter] Unreserve callcenter events when config errors loading X-Git-Tag: v1.10.2^2~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=647ed310e54ce8bcab683ea6d37fbd1a9a22577b;p=thirdparty%2Ffreeswitch.git [mod_callcenter] Unreserve callcenter events when config errors loading --- diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index f8b75fa459..f9e32fe845 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -4208,12 +4208,19 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load) switch_json_api_interface_t *json_api_interface; switch_status_t status; - + /* create/register custom event message type */ if (switch_event_reserve_subclass(CALLCENTER_EVENT) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", CALLCENTER_EVENT); return SWITCH_STATUS_TERM; } + /* Subscribe to presence request events */ + if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, + cc_presence_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to subscribe for presence events!\n"); + return SWITCH_STATUS_GENERR; + } + memset(&globals, 0, sizeof(globals)); globals.pool = pool; @@ -4221,15 +4228,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load) switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); if ((status = load_config()) != SWITCH_STATUS_SUCCESS) { + switch_event_unbind(&globals.node); + switch_event_free_subclass(CALLCENTER_EVENT); + switch_core_hash_destroy(&globals.queue_hash); return status; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, - cc_presence_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to subscribe for presence events!\n"); - return SWITCH_STATUS_GENERR; - } - switch_mutex_lock(globals.mutex); globals.running = 1; switch_mutex_unlock(globals.mutex);