From dab63328cdd7c6a9e4a3da01267deee731822c93 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Fri, 27 Feb 2009 20:21:48 +0000 Subject: [PATCH] More initial paradox of doom avoidement git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12334 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_event_socket/mod_event_socket.c | 12 ++++++++--- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 20 +++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 73f8b4e4e5..bf1c31e235 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -920,6 +920,9 @@ SWITCH_STANDARD_API(event_sink_function) if (!strcasecmp(api_command, "unload") && !strcasecmp(api_args, "mod_event_socket")) { api_command = "bgapi"; api_args = "unload mod_event_socket"; + } else if (!strcasecmp(api_command, "reload") && !strcasecmp(api_args, "mod_event_socket")) { + api_command = "bgapi"; + api_args = "reload mod_event_socket"; } switch_api_execute(api_command, api_args, NULL, stream); @@ -1351,13 +1354,16 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even { switch_status_t status = SWITCH_STATUS_SUCCESS; char *cmd = switch_event_get_header(*event, "command"); - char cheat[] = "api bgapi unload mod_event_socket"; + char unload_cheat[] = "api bgapi unload mod_event_socket"; + char reload_cheat[] = "api bgapi reload mod_event_socket"; *reply = '\0'; if (switch_stristr("unload", cmd) && switch_stristr("mod_event_socket", cmd)) { - cmd = cheat; - } + cmd = unload_cheat; + } else if (switch_stristr("reload", cmd) && switch_stristr("mod_event_socket", cmd)) { + cmd = reload_cheat; + } if (!strncasecmp(cmd, "exit", 4)) { switch_clear_flag_locked(listener, LFLAG_RUNNING); diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index 166d9fd672..5aff2d013b 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -685,6 +685,9 @@ abyss_bool handler_hook(TSession * r) if (switch_stristr("unload", command) && switch_stristr("mod_xml_rpc", r->requestInfo.query)) { command = "bgapi"; api_str = "unload mod_xml_rpc"; + } else if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", r->requestInfo.query)) { + command = "bgapi"; + api_str = "reload mod_xml_rpc"; } else { api_str = r->requestInfo.query; } @@ -719,6 +722,7 @@ static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * cons switch_stream_handle_t stream = { 0 }; xmlrpc_value *val = NULL; const char *x_command = "bgapi", x_arg= "unload mod_xml_rpc"; + switch_bool_t freed = 0; /* Parse our argument array. */ @@ -731,9 +735,16 @@ static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * cons if (switch_stristr("unload", command) && switch_stristr("mod_xml_rpc", arg)) { switch_safe_free(command); - command = x_command; switch_safe_free(arg); - arg = x_arg; + freed = 1; + command = "bgapi"; + arg = "unload mod_xml_rpc"; + } else if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", arg)) { + switch_safe_free(command); + switch_safe_free(arg); + freed = 1; + command = "bgapi"; + arg = "reload mod_xml_rpc"; } SWITCH_STANDARD_STREAM(stream); @@ -746,11 +757,8 @@ static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * cons } /* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */ - if (command != x_command) { + if (!freed) { switch_safe_free(command); - } - - if (arg != x_arg) { switch_safe_free(arg); }