From: Rupa Schomaker Date: Wed, 8 Apr 2009 15:54:46 +0000 (+0000) Subject: hook reloadxml event X-Git-Tag: v1.0.4~1236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfae11366c72b4b51c72e66abae205f1ecfb9c94;p=thirdparty%2Ffreeswitch.git hook reloadxml event git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12950 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/mod/applications/mod_memcache/mod_memcache.c b/src/mod/applications/mod_memcache/mod_memcache.c index 6a55e8bb7d..31021530e2 100755 --- a/src/mod/applications/mod_memcache/mod_memcache.c +++ b/src/mod/applications/mod_memcache/mod_memcache.c @@ -56,6 +56,8 @@ static struct { char *memcached_str; } globals; +static switch_event_node_t *NODE = NULL; + static switch_status_t config_callback_memcached(switch_xml_config_item_t *data, switch_config_callback_type_t callback_type, switch_bool_t changed) { switch_status_t status = SWITCH_STATUS_SUCCESS; @@ -131,7 +133,7 @@ static switch_status_t do_config(switch_bool_t reload) { memset(&globals, 0, sizeof(globals)); - if (switch_xml_config_parse_module_settings("memcache.conf", SWITCH_FALSE, instructions) != SWITCH_STATUS_SUCCESS) { + if (switch_xml_config_parse_module_settings("memcache.conf", reload, instructions) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_GENERR; } @@ -139,6 +141,12 @@ static switch_status_t do_config(switch_bool_t reload) return SWITCH_STATUS_SUCCESS; } +static void event_handler(switch_event_t *event) +{ + do_config(SWITCH_TRUE); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Memcache Reloaded\n"); +} + SWITCH_STANDARD_API(memcache_function) { switch_status_t status; @@ -338,6 +346,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_memcache_load) do_config(SWITCH_FALSE); + if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &NODE) != SWITCH_STATUS_SUCCESS)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event!\n"); + return SWITCH_STATUS_TERM; + } + SWITCH_ADD_API(api_interface, "memcache", "Memcache API", memcache_function, "syntax"); /* indicate that the module should continue to be loaded */