#include <curl/curl.h>
#endif
static int foo = 0;
+static switch_mutex_t *mutex;
SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load);
JSContext *cx = NULL;
jsval rval;
+ switch_mutex_lock(mutex);
if ((cx = JS_NewContext(globals.rt, globals.gStackChunkSize))) {
JS_BeginRequest(cx);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Allocation Error!\n");
- return;
+ goto end;
}
script = input_code;
eval_some_js(buf, cx, javascript_global_object, &rval);
}
}
-
+
if (cx) {
eval_some_js(script, cx, javascript_global_object, &rval);
JS_DestroyContext(cx);
}
+
+ end:
+ switch_mutex_unlock(mutex);
+
+ return;
+
}
SWITCH_STANDARD_APP(js_dp_function)
curl_global_init(CURL_GLOBAL_ALL);
+ switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED, pool);
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}