[Freeswitch-svn] [commit] r12326 - in freeswitch/trunk/src/mod: event_handlers/mod_event_socket xml_int/mod_xml_rpc
FreeSWITCH SVN
anthm at freeswitch.org
Fri Feb 27 08:35:42 PST 2009
Author: anthm
Date: Fri Feb 27 10:35:42 2009
New Revision: 12326
Log:
avoiding initial paradox of doom
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Fri Feb 27 10:35:42 2009
@@ -906,7 +906,7 @@
char *api_command = switch_event_get_header(stream->param_event, "fsapi-command");
char *api_args = switch_event_get_header(stream->param_event, "fsapi-args");
switch_event_t *event, *oevent;
-
+
if (!(api_command)) {
stream->write_function(stream, "<data><reply type=\"error\">INVALID API COMMAND!</reply></data>\n");
goto end;
@@ -916,6 +916,12 @@
switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS);
oevent = stream->param_event;
stream->param_event = event;
+
+ if (!strcasecmp(api_command, "unload") && !strcasecmp(api_args, "mod_event_socket")) {
+ api_command = "bgapi";
+ api_args = "unload mod_event_socket";
+ }
+
switch_api_execute(api_command, api_args, NULL, stream);
stream->param_event = oevent;
stream->write_function(stream, " </api-command>\n</data>");
@@ -1341,9 +1347,14 @@
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
char *cmd = switch_event_get_header(*event, "command");
-
+ char cheat[] = "api bgapi unload mod_event_socket";
+
*reply = '\0';
+ if (switch_stristr("unload mod_event_socket", cmd)) {
+ cmd = cheat;
+ }
+
if (!strncasecmp(cmd, "exit", 4)) {
switch_clear_flag_locked(listener, LFLAG_RUNNING);
switch_snprintf(reply, reply_len, "+OK bye");
Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c (original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c Fri Feb 27 10:35:42 2009
@@ -453,6 +453,7 @@
char *path_info = NULL;
abyss_bool ret = TRUE;
int html = 0, text = 0, xml = 0;
+ const char *api_str;
stream.data = r;
stream.write_function = http_stream_write;
@@ -681,8 +682,14 @@
ConnWrite(r->conn, "\r\n", 2);
}
+ if (switch_stristr("unload", command) && switch_stristr("mod_xml_rpc", r->requestInfo.query)) {
+ command = "bgapi";
+ api_str = "unload mod_xml_rpc";
+ } else {
+ api_str = r->requestInfo.query;
+ }
- if (switch_api_execute(command, r->requestInfo.query, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
+ if (switch_api_execute(command, api_str, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
ResponseStatus(r, 200);
r->responseStarted = TRUE;
//r->done = TRUE;
@@ -711,6 +718,8 @@
char *command = NULL, *arg = NULL;
switch_stream_handle_t stream = { 0 };
xmlrpc_value *val = NULL;
+ const char *x_command = "bgapi", x_arg= "unload mod_xml_rpc";
+
/* Parse our argument array. */
xmlrpc_decompose_value(envP, paramArrayP, "(ss)", &command, &arg);
@@ -720,6 +729,13 @@
return NULL;
}
+ 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;
+ }
+
SWITCH_STANDARD_STREAM(stream);
if (switch_api_execute(command, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
/* Return our result. */
@@ -730,8 +746,14 @@
}
/* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */
- switch_safe_free(command);
- switch_safe_free(arg);
+ if (command != x_command) {
+ switch_safe_free(command);
+ }
+
+ if (arg != x_arg) {
+ switch_safe_free(arg);
+ }
+
return val;
}
More information about the Freeswitch-svn
mailing list