Skip to content
Snippets Groups Projects
Commit afafff2f authored by deuce's avatar deuce
Browse files

Update Socket.recvline() for new js_socket_recv() TLS semantics.

Fixes recvline() returning an zero-length "line" on timeouts, which causes
infinite loops and 100% CPU utilization with IMAPv4-TLS service (and likely
any other service that uses recvline with a short timeout).
parent a97ca06b
No related branches found
No related tags found
No related merge requests found
...@@ -1331,7 +1331,6 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1331,7 +1331,6 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist)
start=time(NULL); start=time(NULL);
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
for(i=0;i<len;) { for(i=0;i<len;) {
if(p->session==-1) { if(p->session==-1) {
switch(js_sock_read_check(p,start,timeout,i)) { switch(js_sock_read_check(p,start,timeout,i)) {
case 1: case 1:
...@@ -1353,21 +1352,13 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1353,21 +1352,13 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist)
break; break;
} }
else { else {
if (got == -1) { if (got == 0) {
len = 0;
continue;
}
switch(js_sock_read_check(p,start,timeout,i)) {
case 1:
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
JS_RESUMEREQUEST(cx, rc);
free(buf); free(buf);
return(JS_TRUE); /* time-out */ return(JS_TRUE); /* time-out */
case 2: }
if (got == -1) {
len = 0; len = 0;
continue; continue;
case 3:
continue;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment