提交 be7914fd authored 作者: Anthony Minessale's avatar Anthony Minessale

disable garbage collector on originate and waitfor_* funcs in js

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7343 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 8640657c
...@@ -2070,6 +2070,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, ...@@ -2070,6 +2070,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
switch_time_t started; switch_time_t started;
unsigned int elapsed; unsigned int elapsed;
int32 timeout = 60; int32 timeout = 60;
jsrefcount saveDepth;
METHOD_SANITY_CHECK(); METHOD_SANITY_CHECK();
...@@ -2082,6 +2083,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, ...@@ -2082,6 +2083,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
JS_ValueToInt32(cx, argv[0], &timeout); JS_ValueToInt32(cx, argv[0], &timeout);
} }
saveDepth = JS_SuspendRequest(cx);
for (;;) { for (;;) {
if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout)
|| switch_channel_get_state(channel) >= CS_HANGUP) { || switch_channel_get_state(channel) >= CS_HANGUP) {
...@@ -2097,6 +2099,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, ...@@ -2097,6 +2099,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
switch_yield(1000); switch_yield(1000);
} }
JS_ResumeRequest(cx, saveDepth);
return JS_TRUE; return JS_TRUE;
} }
...@@ -2109,6 +2112,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc ...@@ -2109,6 +2112,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
switch_time_t started; switch_time_t started;
unsigned int elapsed; unsigned int elapsed;
int32 timeout = 60; int32 timeout = 60;
jsrefcount saveDepth;
METHOD_SANITY_CHECK(); METHOD_SANITY_CHECK();
...@@ -2121,6 +2125,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc ...@@ -2121,6 +2125,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
JS_ValueToInt32(cx, argv[0], &timeout); JS_ValueToInt32(cx, argv[0], &timeout);
} }
saveDepth = JS_SuspendRequest(cx);
for (;;) { for (;;) {
if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout)
|| switch_channel_get_state(channel) >= CS_HANGUP) { || switch_channel_get_state(channel) >= CS_HANGUP) {
...@@ -2135,6 +2140,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc ...@@ -2135,6 +2140,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
switch_yield(1000); switch_yield(1000);
} }
JS_ResumeRequest(cx, saveDepth);
return JS_TRUE; return JS_TRUE;
} }
...@@ -2797,7 +2803,9 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva ...@@ -2797,7 +2803,9 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
const char *username = NULL; const char *username = NULL;
char *to = NULL; char *to = NULL;
char *tmp; char *tmp;
jsrefcount saveDepth;
switch_status_t status;
*rval = BOOLEAN_TO_JSVAL(JS_FALSE); *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
if (JS_ValueToObject(cx, argv[0], &session_obj)) { if (JS_ValueToObject(cx, argv[0], &session_obj)) {
...@@ -2847,8 +2855,11 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva ...@@ -2847,8 +2855,11 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
caller_profile = switch_caller_profile_new(pool,username, dialplan, cid_name, cid_num, network_addr, caller_profile = switch_caller_profile_new(pool,username, dialplan, cid_name, cid_num, network_addr,
ani, aniii, rdnis, modname, context, dest); ani, aniii, rdnis, modname, context, dest);
if (switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, SOF_NONE) saveDepth = JS_SuspendRequest(cx);
!= SWITCH_STATUS_SUCCESS) { status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, SOF_NONE);
JS_ResumeRequest(cx, saveDepth);
if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
goto done; goto done;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论