changeset 49:45fd970860f2

Added calls to JS_SuspendRequest() and JS_ResumeRequest() around blocking NSPR network calls.
author Atul Varma <varmaa@toolness.com>
date Wed, 24 Jun 2009 16:10:12 -0700
parents aabc1dd92639
children 853f80bd3b4b
files server_socket.cpp
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/server_socket.cpp	Wed Jun 24 15:58:54 2009 -0700
+++ b/server_socket.cpp	Wed Jun 24 16:10:12 2009 -0700
@@ -105,9 +105,11 @@
     if (!getSocket(cx, obj, &fd))
       return JS_FALSE;
     
+    jsrefcount rc = JS_SuspendRequest(cx);
     PRInt32 sent = PR_Send(fd, dataBytes, dataLength, 0,
                            PR_INTERVAL_NO_TIMEOUT);
-    
+    JS_ResumeRequest(cx, rc);
+
     if (sent == -1) {
       JS_ReportError(cx, "Send failed.");
       return JS_FALSE;
@@ -131,7 +133,9 @@
     return JS_FALSE;
 
   char buffer[length];
+  jsrefcount rc = JS_SuspendRequest(cx);
   PRInt32 recvd = PR_Recv(fd, buffer, length, 0, PR_INTERVAL_NO_TIMEOUT);
+  JS_ResumeRequest(cx, rc);
 
   if (recvd == -1) {
     JS_ReportError(cx, "Receive failed.");
@@ -208,7 +212,10 @@
     return JS_FALSE;
 
   PRNetAddr addr;
+
+  jsrefcount rc = JS_SuspendRequest(cx);
   PRFileDesc *conn = PR_Accept(fd, &addr, timeout);
+  JS_ResumeRequest(cx, rc);
 
   if (conn == NULL) {
     *rval = JSVAL_NULL;