]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
disable garbage collector on originate and waitfor_* funcs in js
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 24 Jan 2008 14:05:52 +0000 (14:05 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 24 Jan 2008 14:05:52 +0000 (14:05 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7343 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_spidermonkey/mod_spidermonkey.c

index c3be678619574e313205fef76b59199e3e8fe1a2..1b80a128fa9c1b0ca94a9a2ad62f6d94b4b145b8 100644 (file)
@@ -2070,6 +2070,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
        switch_time_t started;
        unsigned int elapsed;
        int32 timeout = 60;
+       jsrefcount saveDepth;
 
        METHOD_SANITY_CHECK();
 
@@ -2082,6 +2083,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
                JS_ValueToInt32(cx, argv[0], &timeout);
        }
 
+       saveDepth = JS_SuspendRequest(cx);
        for (;;) {
                if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout)
                        || switch_channel_get_state(channel) >= CS_HANGUP) {
@@ -2097,6 +2099,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
 
                switch_yield(1000);
        }
+       JS_ResumeRequest(cx, saveDepth);
 
        return JS_TRUE;
 }
@@ -2109,6 +2112,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
        switch_time_t started;
        unsigned int elapsed;
        int32 timeout = 60;
+       jsrefcount saveDepth;
 
        METHOD_SANITY_CHECK();
 
@@ -2121,6 +2125,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
                JS_ValueToInt32(cx, argv[0], &timeout);
        }
 
+       saveDepth = JS_SuspendRequest(cx);
        for (;;) {
                if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout)
                        || switch_channel_get_state(channel) >= CS_HANGUP) {
@@ -2135,6 +2140,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
 
                switch_yield(1000);
        }
+       JS_ResumeRequest(cx, saveDepth);
 
        return JS_TRUE;
 }
@@ -2797,7 +2803,9 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
                const char *username = NULL;
                char *to = NULL;
                char *tmp;
-                       
+               jsrefcount saveDepth;
+               switch_status_t status;
+
                *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 
                if (JS_ValueToObject(cx, argv[0], &session_obj)) {
@@ -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,
                                                                                                   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) 
-                       != SWITCH_STATUS_SUCCESS) {
+               saveDepth = JS_SuspendRequest(cx);
+               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);
                        goto done;
                }