]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
hook reloadxml event
authorRupa Schomaker <rupa@rupa.com>
Wed, 8 Apr 2009 15:54:46 +0000 (15:54 +0000)
committerRupa Schomaker <rupa@rupa.com>
Wed, 8 Apr 2009 15:54:46 +0000 (15:54 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12950 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_memcache/mod_memcache.c

index 6a55e8bb7d04a182b3ddca85153ae016aec1de8e..31021530e25fe1cfb881c9b49469e96466dd983c 100755 (executable)
@@ -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 */