[Freeswitch-svn] [commit] r5024 - freeswitch/trunk/src/mod/languages/mod_spidermonkey
Freeswitch SVN
mikej at freeswitch.org
Thu Apr 26 19:09:26 EDT 2007
Author: mikej
Date: Thu Apr 26 19:09:26 2007
New Revision: 5024
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
Log:
address http://jira.freeswitch.org/browse/FSCORE-6 We still need to test what the right number is for stack depth is for different platforms. We can get 13 out of msvc on my box (set the level to 12) but this is probably platform dependent and stack size dependent. How can we compute this?
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Thu Apr 26 19:09:26 2007
@@ -623,6 +623,7 @@
return Event;
}
+#define MAX_STACK_DEPTH 12
static switch_status_t js_common_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
@@ -639,6 +640,8 @@
return SWITCH_STATUS_FALSE;
}
+ jss->stack_depth++;
+
switch (itype) {
case SWITCH_INPUT_TYPE_EVENT:
if ((event = (switch_event_t *) input)) {
@@ -648,6 +651,7 @@
}
}
if (!Event) {
+ jss->stack_depth--;
return SWITCH_STATUS_FALSE;
}
break;
@@ -662,10 +666,17 @@
argv[argc++] = cb_state->arg;
}
+ if (jss->stack_depth > MAX_STACK_DEPTH) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Maximum recursive callback limit %d reached.\n", MAX_STACK_DEPTH);
+ jss->stack_depth--;
+ return SWITCH_STATUS_FALSE;
+ }
+
JS_ResumeRequest(cb_state->cx, cb_state->saveDepth);
JS_CallFunction(cb_state->cx, cb_state->obj, cb_state->function, argc, argv, &cb_state->ret);
cb_state->saveDepth = JS_SuspendRequest(cb_state->cx);
+ jss->stack_depth--;
return SWITCH_STATUS_SUCCESS;
}
@@ -2037,6 +2048,7 @@
jss->flags = flags;
jss->cx = cx;
jss->obj = session_obj;
+ jss->stack_depth = 0;
if ((JS_SetPrivate(cx, session_obj, jss) &&
JS_DefineProperties(cx, session_obj, session_props) && JS_DefineFunctions(cx, session_obj, session_methods))) {
return session_obj;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h Thu Apr 26 19:09:26 2007
@@ -129,6 +129,7 @@
unsigned int flags;
switch_call_cause_t cause;
JSFunction *on_hangup;
+ int stack_depth;
switch_channel_state_t hook_state;
};
More information about the Freeswitch-svn
mailing list