Skip to content
Snippets Groups Projects
Commit 175bad39 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Improve JS error reporting

Include function names. Include host:port in "Unable to connect" error.
parent a738b950
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
...@@ -864,7 +864,7 @@ js_accept(JSContext *cx, uintN argc, jsval *arglist) ...@@ -864,7 +864,7 @@ js_accept(JSContext *cx, uintN argc, jsval *arglist)
if((sockobj=js_CreateSocketObject(cx, obj, "new_socket", new_socket, -1))==NULL) { if((sockobj=js_CreateSocketObject(cx, obj, "new_socket", new_socket, -1))==NULL) {
closesocket(new_socket); closesocket(new_socket);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_ReportError(cx,"Error creating new socket object"); JS_ReportError(cx, __FUNCTION__ ": Error creating new socket object");
return(JS_TRUE); return(JS_TRUE);
} }
if((new_p=(js_socket_private_t*)JS_GetPrivate(cx,sockobj))==NULL) { if((new_p=(js_socket_private_t*)JS_GetPrivate(cx,sockobj))==NULL) {
...@@ -942,7 +942,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t ...@@ -942,7 +942,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t
jsval *argv=JS_ARGV(cx, arglist); jsval *argv=JS_ARGV(cx, arglist);
if (p->sock == INVALID_SOCKET) { if (p->sock == INVALID_SOCKET) {
JS_ReportError(cx, "invalid socket"); JS_ReportError(cx, __FUNCTION__ ": invalid socket");
return JS_FALSE; return JS_FALSE;
} }
...@@ -951,7 +951,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t ...@@ -951,7 +951,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t
} }
if (!cb->events_supported) { if (!cb->events_supported) {
JS_ReportError(cx, "events not supported"); JS_ReportError(cx, __FUNCTION__ ": events not supported");
return JS_FALSE; return JS_FALSE;
} }
...@@ -966,14 +966,14 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t ...@@ -966,14 +966,14 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t
#else #else
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) { if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
#endif #endif
JS_ReportError(cx, "Error %d creating socket pair", ERROR_VALUE); JS_ReportError(cx, __FUNCTION__ ": Error %d creating socket pair", ERROR_VALUE);
return JS_FALSE; return JS_FALSE;
} }
// Create event // Create event
ev = malloc(sizeof(*ev)); ev = malloc(sizeof(*ev));
if (ev == NULL) { if (ev == NULL) {
JS_ReportError(cx, "error allocating %lu bytes", sizeof(*ev)); JS_ReportError(cx, __FUNCTION__ ": error allocating %lu bytes", sizeof(*ev));
closesocket(sv[0]); closesocket(sv[0]);
closesocket(sv[1]); closesocket(sv[1]);
return JS_FALSE; return JS_FALSE;
...@@ -996,7 +996,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t ...@@ -996,7 +996,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t
// Start thread // Start thread
args = malloc(sizeof(*args)); args = malloc(sizeof(*args));
if (args == NULL) { if (args == NULL) {
JS_ReportError(cx, "error allocating %lu bytes", sizeof(*args)); JS_ReportError(cx, __FUNCTION__ ": error allocating %lu bytes", sizeof(*args));
closesocket(sv[0]); closesocket(sv[0]);
closesocket(sv[1]); closesocket(sv[1]);
return JS_FALSE; return JS_FALSE;
...@@ -1009,7 +1009,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t ...@@ -1009,7 +1009,7 @@ js_connect_event(JSContext *cx, uintN argc, jsval *arglist, js_socket_private_t
args->port = port; args->port = port;
args->nonblocking = p->nonblocking; args->nonblocking = p->nonblocking;
if (args->host == NULL) { if (args->host == NULL) {
JS_ReportError(cx, "error duplicating hostname"); JS_ReportError(cx, __FUNCTION__ ": error duplicating hostname");
closesocket(sv[0]); closesocket(sv[0]);
closesocket(sv[1]); closesocket(sv[1]);
free(args); free(args);
...@@ -1303,7 +1303,7 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1303,7 +1303,7 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist)
JSVALUE_TO_MSTRING(cx, argv[0], fname, NULL); JSVALUE_TO_MSTRING(cx, argv[0], fname, NULL);
HANDLE_PENDING(cx, fname); HANDLE_PENDING(cx, fname);
if(fname==NULL) { if(fname==NULL) {
JS_ReportError(cx,"Failure reading filename"); JS_ReportError(cx, __FUNCTION__ ": Failure reading filename");
return(JS_FALSE); return(JS_FALSE);
} }
...@@ -1417,7 +1417,7 @@ js_recv(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1417,7 +1417,7 @@ js_recv(JSContext *cx, uintN argc, jsval *arglist)
} }
if((buf=(char*)malloc(len+1))==NULL) { if((buf=(char*)malloc(len+1))==NULL) {
JS_ReportError(cx,"Error allocating %u bytes",len+1); JS_ReportError(cx, __FUNCTION__ ": Error allocating %u bytes",len+1);
return(JS_FALSE); return(JS_FALSE);
} }
...@@ -1524,7 +1524,7 @@ js_recvfrom(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1524,7 +1524,7 @@ js_recvfrom(JSContext *cx, uintN argc, jsval *arglist)
} else { /* String Data */ } else { /* String Data */
if((buf=(char*)malloc(len+1))==NULL) { if((buf=(char*)malloc(len+1))==NULL) {
JS_ReportError(cx,"Error allocating %u bytes",len+1); JS_ReportError(cx, __FUNCTION__ ": Error allocating %u bytes",len+1);
return(JS_FALSE); return(JS_FALSE);
} }
...@@ -1549,7 +1549,7 @@ js_recvfrom(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1549,7 +1549,7 @@ js_recvfrom(JSContext *cx, uintN argc, jsval *arglist)
if((retobj=JS_NewObject(cx,NULL,NULL,obj))==NULL) { if((retobj=JS_NewObject(cx,NULL,NULL,obj))==NULL) {
JS_ReportError(cx,"JS_NewObject failed"); JS_ReportError(cx, __FUNCTION__ ": JS_NewObject failed");
return(JS_FALSE); return(JS_FALSE);
} }
...@@ -1602,7 +1602,7 @@ js_peek(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1602,7 +1602,7 @@ js_peek(JSContext *cx, uintN argc, jsval *arglist)
JS_ValueToInt32(cx,argv[0],&len); JS_ValueToInt32(cx,argv[0],&len);
if((buf=(char*)malloc(len+1))==NULL) { if((buf=(char*)malloc(len+1))==NULL) {
JS_ReportError(cx,"Error allocating %u bytes",len+1); JS_ReportError(cx, __FUNCTION__ ": Error allocating %u bytes",len+1);
return(JS_FALSE); return(JS_FALSE);
} }
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
...@@ -1688,7 +1688,7 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1688,7 +1688,7 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist)
JS_ValueToInt32(cx,argv[0],&len); JS_ValueToInt32(cx,argv[0],&len);
if((buf=(char*)malloc(len+1))==NULL) { if((buf=(char*)malloc(len+1))==NULL) {
JS_ReportError(cx,"Error allocating %u bytes",len+1); JS_ReportError(cx, __FUNCTION__ ": Error allocating %u bytes",len+1);
return(JS_FALSE); return(JS_FALSE);
} }
...@@ -1999,7 +1999,7 @@ js_poll(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1999,7 +1999,7 @@ js_poll(JSContext *cx, uintN argc, jsval *arglist)
fds = calloc(nfds, sizeof(*fds)); fds = calloc(nfds, sizeof(*fds));
if (fds == NULL) { if (fds == NULL) {
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_ReportError(cx, "Error allocating %d elements of %lu bytes at %s:%d" JS_ReportError(cx, __FUNCTION__ ": Error allocating %d elements of %lu bytes at %s:%d"
, nfds, sizeof(*fds), getfname(__FILE__), __LINE__); , nfds, sizeof(*fds), getfname(__FILE__), __LINE__);
return JS_FALSE; return JS_FALSE;
} }
...@@ -2054,7 +2054,7 @@ js_get_callback(JSContext *cx) ...@@ -2054,7 +2054,7 @@ js_get_callback(JSContext *cx)
while ((!JS_LookupProperty(cx, pscope, "js", &val) || val==JSVAL_VOID || !JSVAL_IS_OBJECT(val)) && pscope != NULL) { while ((!JS_LookupProperty(cx, pscope, "js", &val) || val==JSVAL_VOID || !JSVAL_IS_OBJECT(val)) && pscope != NULL) {
pscope = JS_GetParent(cx, pscope); pscope = JS_GetParent(cx, pscope);
if (pscope == NULL) { if (pscope == NULL) {
JS_ReportError(cx, "Walked to global, no js object!"); JS_ReportError(cx, __FUNCTION__ ": Walked to global, no js object!");
return NULL; return NULL;
} }
} }
...@@ -2069,7 +2069,7 @@ js_install_one_socket_event(JSContext *cx, JSObject *obj, JSFunction *ecb, js_ca ...@@ -2069,7 +2069,7 @@ js_install_one_socket_event(JSContext *cx, JSObject *obj, JSFunction *ecb, js_ca
ev = malloc(sizeof(*ev)); ev = malloc(sizeof(*ev));
if (ev == NULL) { if (ev == NULL) {
JS_ReportError(cx, "error allocating %lu bytes", sizeof(*ev)); JS_ReportError(cx, __FUNCTION__ ": error allocating %lu bytes", sizeof(*ev));
return; return;
} }
ev->prev = NULL; ev->prev = NULL;
...@@ -2966,41 +2966,41 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -2966,41 +2966,41 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
scfg = JS_GetRuntimePrivate(JS_GetRuntime(cx)); scfg = JS_GetRuntimePrivate(JS_GetRuntime(cx));
if (scfg == NULL) { if (scfg == NULL) {
JS_ReportError(cx, "Unable to get private runtime"); JS_ReportError(cx, __FUNCTION__ ": Unable to get private runtime");
return JS_FALSE; return JS_FALSE;
} }
if (argc < 2) { if (argc < 2) {
JS_ReportError(cx, "At least two arguments required (hostname and port)"); JS_ReportError(cx, __FUNCTION__ ": At least two arguments required (hostname and port)");
return JS_FALSE; return JS_FALSE;
} }
// Optional arguments in an object... // Optional arguments in an object...
if (argc > 2) { if (argc > 2) {
if (!JS_ValueToObject(cx, argv[2], &obj)) { if (!JS_ValueToObject(cx, argv[2], &obj)) {
JS_ReportError(cx, "Invalid third argument"); JS_ReportError(cx, __FUNCTION__ ": Invalid third argument");
return JS_FALSE; return JS_FALSE;
} }
if (JS_GetProperty(cx, obj, "domain", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "domain", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &domain)) { if (!JS_ValueToInt32(cx, v, &domain)) {
JS_ReportError(cx, "Invalid domain property"); JS_ReportError(cx, __FUNCTION__ ": Invalid domain property");
return JS_FALSE; return JS_FALSE;
} }
} }
if (JS_GetProperty(cx, obj, "type", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "type", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &type)) { if (!JS_ValueToInt32(cx, v, &type)) {
JS_ReportError(cx, "Invalid type property"); JS_ReportError(cx, __FUNCTION__ ": Invalid type property");
return JS_FALSE; return JS_FALSE;
} }
} }
if (JS_GetProperty(cx, obj, "proto", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "proto", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &proto)) { if (!JS_ValueToInt32(cx, v, &proto)) {
JS_ReportError(cx, "Invalid proto property"); JS_ReportError(cx, __FUNCTION__ ": Invalid proto property");
return JS_FALSE; return JS_FALSE;
} }
} }
if (JS_GetProperty(cx, obj, "timeout", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "timeout", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &timeout)) { if (!JS_ValueToInt32(cx, v, &timeout)) {
JS_ReportError(cx, "Invalid timeout property"); JS_ReportError(cx, __FUNCTION__ ": Invalid timeout property");
return JS_FALSE; return JS_FALSE;
} }
} }
...@@ -3039,16 +3039,16 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3039,16 +3039,16 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
if (JSVAL_IS_OBJECT(v)) { if (JSVAL_IS_OBJECT(v)) {
ao = JSVAL_TO_OBJECT(v); ao = JSVAL_TO_OBJECT(v);
if (ao == NULL || !JS_IsArrayObject(cx, ao)) { if (ao == NULL || !JS_IsArrayObject(cx, ao)) {
JS_ReportError(cx, "Invalid bindaddrs list"); JS_ReportError(cx, __FUNCTION__ ": Invalid bindaddrs list");
goto fail; goto fail;
} }
if (!JS_GetArrayLength(cx, ao, &count)) { if (!JS_GetArrayLength(cx, ao, &count)) {
JS_ReportError(cx, "Unable to get bindaddrs length"); JS_ReportError(cx, __FUNCTION__ ": Unable to get bindaddrs length");
goto fail; goto fail;
} }
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (!JS_GetElement(cx, ao, i, &v)) { if (!JS_GetElement(cx, ao, i, &v)) {
JS_ReportError(cx, "Invalid bindaddrs entry"); JS_ReportError(cx, __FUNCTION__ ": Invalid bindaddrs entry");
goto fail; goto fail;
} }
JSVALUE_TO_MSTRING(cx, v, host, NULL); JSVALUE_TO_MSTRING(cx, v, host, NULL);
...@@ -3056,7 +3056,7 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3056,7 +3056,7 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
rc = JS_SUSPENDREQUEST(cx); rc = JS_SUSPENDREQUEST(cx);
if (!handle_addrs(host, &addr4, &addr4len, &addr6, &addr6len)) { if (!handle_addrs(host, &addr4, &addr4len, &addr6, &addr6len)) {
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_ReportError(cx, "Unparsable bindaddrs entry"); JS_ReportError(cx, __FUNCTION__ ": Unparsable bindaddrs entry");
goto fail; goto fail;
} }
FREE_AND_NULL(host); FREE_AND_NULL(host);
...@@ -3069,7 +3069,7 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3069,7 +3069,7 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
rc = JS_SUSPENDREQUEST(cx); rc = JS_SUSPENDREQUEST(cx);
if (!handle_addrs(host, &addr4, &addr4len, &addr6, &addr6len)) { if (!handle_addrs(host, &addr4, &addr4len, &addr6, &addr6len)) {
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_ReportError(cx, "Unparsable bindaddrs entry"); JS_ReportError(cx, __FUNCTION__ ": Unparsable bindaddrs entry");
goto fail; goto fail;
} }
FREE_AND_NULL(host); FREE_AND_NULL(host);
...@@ -3081,7 +3081,7 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3081,7 +3081,7 @@ js_connected_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
HANDLE_PENDING(cx, host); HANDLE_PENDING(cx, host);
port = js_port(cx, argv[1], type); port = js_port(cx, argv[1], type);
if (port == 0) { if (port == 0) {
JS_ReportError(cx, "Invalid port"); JS_ReportError(cx, __FUNCTION__ ": Invalid port");
goto fail; goto fail;
} }
...@@ -3184,7 +3184,7 @@ connected: ...@@ -3184,7 +3184,7 @@ connected:
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
if (p->sock == INVALID_SOCKET) { if (p->sock == INVALID_SOCKET) {
JS_ReportError(cx, "Unable to connect"); JS_ReportError(cx, __FUNCTION__ ": Unable to connect to %s:%u", host, port);
goto fail; goto fail;
} }
ioctlsocket(p->sock,FIONBIO,(ulong*)&(p->nonblocking)); ioctlsocket(p->sock,FIONBIO,(ulong*)&(p->nonblocking));
...@@ -3275,46 +3275,46 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3275,46 +3275,46 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
scfg = JS_GetRuntimePrivate(JS_GetRuntime(cx)); scfg = JS_GetRuntimePrivate(JS_GetRuntime(cx));
if (scfg == NULL) { if (scfg == NULL) {
JS_ReportError(cx, "Unable to get private runtime"); JS_ReportError(cx, __FUNCTION__ ": Unable to get private runtime");
goto fail; goto fail;
} }
cb.scfg = scfg; cb.scfg = scfg;
if (argc < 3) { if (argc < 3) {
JS_ReportError(cx, "At least three arguments required (interfaces, port, and protocol)"); JS_ReportError(cx, __FUNCTION__ ": At least three arguments required (interfaces, port, and protocol)");
goto fail; goto fail;
} }
if (argc > 3) { if (argc > 3) {
if (!JS_ValueToObject(cx, argv[3], &obj)) { if (!JS_ValueToObject(cx, argv[3], &obj)) {
JS_ReportError(cx, "Invalid fourth argument"); JS_ReportError(cx, __FUNCTION__ ": Invalid fourth argument");
goto fail; goto fail;
} }
if (JS_GetProperty(cx, obj, "domain", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "domain", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &domain)) { if (!JS_ValueToInt32(cx, v, &domain)) {
JS_ReportError(cx, "Invalid domain property"); JS_ReportError(cx, __FUNCTION__ ": Invalid domain property");
goto fail; goto fail;
} }
} }
if (JS_GetProperty(cx, obj, "type", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "type", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &type)) { if (!JS_ValueToInt32(cx, v, &type)) {
JS_ReportError(cx, "Invalid type property"); JS_ReportError(cx, __FUNCTION__ ": Invalid type property");
goto fail; goto fail;
} }
} }
if (JS_GetProperty(cx, obj, "proto", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "proto", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &proto)) { if (!JS_ValueToInt32(cx, v, &proto)) {
JS_ReportError(cx, "Invalid proto property"); JS_ReportError(cx, __FUNCTION__ ": Invalid proto property");
goto fail; goto fail;
} }
} }
if (JS_GetProperty(cx, obj, "retry_count", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "retry_count", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &retry_count)) { if (!JS_ValueToInt32(cx, v, &retry_count)) {
JS_ReportError(cx, "Invalid retry_count property"); JS_ReportError(cx, __FUNCTION__ ": Invalid retry_count property");
goto fail; goto fail;
} }
} }
if (JS_GetProperty(cx, obj, "retry_delay", &v) && !JSVAL_IS_VOID(v)) { if (JS_GetProperty(cx, obj, "retry_delay", &v) && !JSVAL_IS_VOID(v)) {
if (!JS_ValueToInt32(cx, v, &retry_delay)) { if (!JS_ValueToInt32(cx, v, &retry_delay)) {
JS_ReportError(cx, "Invalid retry_delay property"); JS_ReportError(cx, __FUNCTION__ ": Invalid retry_delay property");
goto fail; goto fail;
} }
} }
...@@ -3327,13 +3327,13 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3327,13 +3327,13 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
if (JSVAL_IS_OBJECT(argv[0])) { if (JSVAL_IS_OBJECT(argv[0])) {
obj = JSVAL_TO_OBJECT(argv[0]); obj = JSVAL_TO_OBJECT(argv[0]);
if (obj == NULL || !JS_IsArrayObject(cx, obj)) { if (obj == NULL || !JS_IsArrayObject(cx, obj)) {
JS_ReportError(cx, "Invalid interface list"); JS_ReportError(cx, __FUNCTION__ ": Invalid interface list");
goto fail; goto fail;
} }
} }
set = xpms_create(retry_count, retry_delay, lprintf); set = xpms_create(retry_count, retry_delay, lprintf);
if (set == NULL) { if (set == NULL) {
JS_ReportError(cx, "Unable to create socket set"); JS_ReportError(cx, __FUNCTION__ ": Unable to create socket set");
goto fail; goto fail;
} }
if (obj == NULL) { if (obj == NULL) {
...@@ -3342,14 +3342,14 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3342,14 +3342,14 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
rc = JS_SUSPENDREQUEST(cx); rc = JS_SUSPENDREQUEST(cx);
if (!xpms_add(set, domain, type, proto, interface, port, protocol, ls_cb, NULL, &cb)) { if (!xpms_add(set, domain, type, proto, interface, port, protocol, ls_cb, NULL, &cb)) {
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_ReportError(cx, "Unable to add host to socket set"); JS_ReportError(cx, __FUNCTION__ ": Unable to add host to socket set");
goto fail; goto fail;
} }
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
} }
else { else {
if (!JS_GetArrayLength(cx, obj, &count)) { if (!JS_GetArrayLength(cx, obj, &count)) {
JS_ReportError(cx, "zero-length array"); JS_ReportError(cx, __FUNCTION__ ": zero-length array");
goto fail; goto fail;
} }
for (i = 0; (jsuint)i < count; i++) { for (i = 0; (jsuint)i < count; i++) {
...@@ -3363,7 +3363,7 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3363,7 +3363,7 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
if (!xpms_add(set, domain, type, proto, interface, port, protocol, ls_cb, NULL, &cb)) { if (!xpms_add(set, domain, type, proto, interface, port, protocol, ls_cb, NULL, &cb)) {
free(interface); free(interface);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_ReportError(cx, "Unable to add host to socket set"); JS_ReportError(cx, __FUNCTION__ ": Unable to add host to socket set");
goto fail; goto fail;
} }
free(interface); free(interface);
...@@ -3448,12 +3448,12 @@ js_socket_constructor(JSContext *cx, uintN argc, jsval *arglist) ...@@ -3448,12 +3448,12 @@ js_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
if (from_descriptor) { if (from_descriptor) {
uint32 sock; uint32 sock;
if(!JS_ValueToECMAUint32(cx,argv[i],&sock)) { if(!JS_ValueToECMAUint32(cx,argv[i],&sock)) {
JS_ReportError(cx, "Failed to convert socket descriptor to uint32"); JS_ReportError(cx, __FUNCTION__ ": Failed to convert socket descriptor to uint32");
return JS_FALSE; return JS_FALSE;
} }
obj = js_CreateSocketObjectWithoutParent(cx, sock, -1); obj = js_CreateSocketObjectWithoutParent(cx, sock, -1);
if (obj == NULL) { if (obj == NULL) {
JS_ReportError(cx, "Failed to create external socket object"); JS_ReportError(cx, __FUNCTION__ ": Failed to create external socket object");
return JS_FALSE; return JS_FALSE;
} }
JS_SET_RVAL(cx, arglist, OBJECT_TO_JSVAL(obj)); JS_SET_RVAL(cx, arglist, OBJECT_TO_JSVAL(obj));
......
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