Skip to content
Snippets Groups Projects
Commit 8a91245d authored by rswindell's avatar rswindell
Browse files

recv, recvline, and peek methods now return null when there is a time-out or no data

(instead of an empty string)
parent b37ee52e
No related branches found
No related tags found
No related merge requests found
......@@ -272,7 +272,8 @@ js_recv(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
len = recv(p->sock,buf,len,0);
if(len<0) {
p->last_error=ERROR_VALUE;
len=0;
*rval = JSVAL_NULL;
return(JS_TRUE);
}
buf[len]=0;
......@@ -307,7 +308,8 @@ js_peek(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
len = recv(p->sock,buf,len,MSG_PEEK);
if(len<0) {
p->last_error=ERROR_VALUE;
len=0;
*rval = JSVAL_NULL;
return(JS_TRUE);
}
buf[len]=0;
......@@ -355,8 +357,11 @@ js_recvline(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
}
if(!rd) {
if(time(NULL)-start>timeout)
break; /* time-out */
if(time(NULL)-start>timeout) {
dbprintf(FALSE, p, "recvline timeout");
*rval = JSVAL_NULL;
return(JS_TRUE); /* time-out */
}
mswait(1);
continue; /* no data */
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment