Skip to content
Snippets Groups Projects
Commit 5e53ebf5 authored by rswindell's avatar rswindell
Browse files

Attempt to use alarm() (on Unix) to timeout connect().

parent 1d99c314
Branches
Tags
No related merge requests found
......@@ -206,12 +206,21 @@ js_connect(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
#if defined(__unix__)
alarm(10); /* timeout */
#endif
if(connect(p->sock, (struct sockaddr *)&addr, sizeof(addr))!=0) {
#if defined(__unix__)
alarm(0);
#endif
p->last_error=ERROR_VALUE;
dbprintf(TRUE, p, "connect failed with error %d",ERROR_VALUE);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
return(JS_TRUE);
}
#if defined(__unix__)
alarm(0);
#endif
*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
dbprintf(FALSE, p, "connected to port %u at %s", port, JS_GetStringBytes(str));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment