git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7303 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-01-19 23:23:12 +00:00
parent 0a0ee507a2
commit 492ee40266
1 changed files with 9 additions and 12 deletions

View File

@ -38,8 +38,6 @@
#include <curl/curl.h> #include <curl/curl.h>
#endif #endif
static int foo = 0; static int foo = 0;
static switch_mutex_t *mutex;
SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load); SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown);
@ -3223,6 +3221,12 @@ static JSBool js_api_execute(JSContext * cx, JSObject * obj, uintN argc, jsval *
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char retbuf[2048] = ""; char retbuf[2048] = "";
if (!strcasecmp(cmd, "jsapi")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid API Call!\n");
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
return JS_TRUE;
}
if (argc > 1) { if (argc > 1) {
arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
} }
@ -3405,8 +3409,6 @@ static void js_parse_and_execute(switch_core_session_t *session, const char *inp
JSContext *cx = NULL; JSContext *cx = NULL;
jsval rval; jsval rval;
switch_mutex_lock(mutex);
if ((cx = JS_NewContext(globals.rt, globals.gStackChunkSize))) { if ((cx = JS_NewContext(globals.rt, globals.gStackChunkSize))) {
JS_BeginRequest(cx); JS_BeginRequest(cx);
JS_SetErrorReporter(cx, js_error); JS_SetErrorReporter(cx, js_error);
@ -3424,8 +3426,7 @@ static void js_parse_and_execute(switch_core_session_t *session, const char *inp
} }
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Allocation Error!\n"); abort();
goto end;
} }
script = input_code; script = input_code;
@ -3456,9 +3457,6 @@ static void js_parse_and_execute(switch_core_session_t *session, const char *inp
JS_DestroyContext(cx); JS_DestroyContext(cx);
} }
end:
switch_mutex_unlock(mutex);
return; return;
} }
@ -3523,6 +3521,7 @@ SWITCH_STANDARD_API(jsapi_function)
ro.cmd = cmd; ro.cmd = cmd;
ro.session = session; ro.session = session;
ro.stream = stream; ro.stream = stream;
js_parse_and_execute(session, (char *) cmd, &ro); js_parse_and_execute(session, (char *) cmd, &ro);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -3587,8 +3586,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load)
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED, pool);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }