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

Fix up request debugging code.

parent 3bf32372
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@ static char str[1024];
static void logstr(void)
{
#if 0
FILE *f;
if((f=fopen("../data/logs/JS_RequestErrors.log", "a"))!=NULL) {
......@@ -51,6 +52,9 @@ static void logstr(void)
else {
fputs(str, stderr);
}
#else
fputs(str, stderr);
#endif
}
static struct request_log *match_request(JSContext *cx)
......@@ -104,7 +108,7 @@ void js_debug_beginrequest(JSContext *cx, const char *file, unsigned long line)
case LAST_REQUEST_TYPE_BEGIN:
case LAST_REQUEST_TYPE_SUSPEND:
case LAST_REQUEST_TYPE_RESUME:
sprintf(str,"Begin after %s from %s:%u at %s:%u (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"Begin after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
......@@ -113,7 +117,7 @@ void js_debug_beginrequest(JSContext *cx, const char *file, unsigned long line)
break;
case 1:
default:
sprintf(str,"depth=%u at Begin after %s from %s:%u at %s:%u (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"depth=%u at Begin after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
......@@ -121,8 +125,8 @@ void js_debug_beginrequest(JSContext *cx, const char *file, unsigned long line)
req->type=LAST_REQUEST_TYPE_BEGIN;
req->file=file;
req->line=line;
JS_BeginRequest(cx);
pthread_mutex_unlock(&req_mutex);
JS_BeginRequest(cx);
}
void js_debug_endrequest(JSContext *cx, const char *file, unsigned long line)
......@@ -142,7 +146,7 @@ void js_debug_endrequest(JSContext *cx, const char *file, unsigned long line)
case LAST_REQUEST_TYPE_BEGIN:
if(req->file) {
if(strcmp(req->file, file) != 0 || line < req->line) {
sprintf(str,"Suspicious End after %s from %s:%u at %s:%u (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"Suspicious End after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
}
break;
}
......@@ -151,19 +155,27 @@ void js_debug_endrequest(JSContext *cx, const char *file, unsigned long line)
case LAST_REQUEST_TYPE_NONE:
case LAST_REQUEST_TYPE_END:
case LAST_REQUEST_TYPE_SUSPEND:
sprintf(str,"End after %s from %s:%u at %s:%u (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"End after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
switch(JS_RequestDepth(cx)) {
case 0:
default:
sprintf(str,"depth=%u at End after %s from %s:%u at %s:%u (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"depth=%u at End after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
case 1:
break;
}
switch(JS_SuspendDepth(cx)) {
case 0:
break;
default:
sprintf(str,"Suspend depth=%u at End after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
req->type=LAST_REQUEST_TYPE_END;
req->file=file;
......@@ -208,19 +220,28 @@ jsrefcount js_debug_suspendrequest(JSContext *cx, const char *file, unsigned lon
break;
case LAST_REQUEST_TYPE_END:
case LAST_REQUEST_TYPE_SUSPEND:
sprintf(str,"Suspend after %s from %s:%u at %s:%u (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"Suspend after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
switch(JS_RequestDepth(cx)) {
case 0:
default:
sprintf(str,"depth=%u at Suspend after %s from %s:%u at %s:%u (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"depth=%u at Suspend after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
case 1:
break;
}
switch(JS_SuspendDepth(cx)) {
case 0:
break;
default:
sprintf(str,"Suspend depth=%u at Suspend after %s from %s:%lu at %s:%lu (%p)\n",JS_SuspendDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
req->type=LAST_REQUEST_TYPE_SUSPEND;
req->file=file;
......@@ -250,25 +271,35 @@ void js_debug_resumerequest(JSContext *cx, jsrefcount rc, const char *file, unsi
case LAST_REQUEST_TYPE_END:
case LAST_REQUEST_TYPE_BEGIN:
case LAST_REQUEST_TYPE_RESUME:
sprintf(str,"Resume after %s from %s:%u at %s:%u (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"Resume after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
switch(JS_RequestDepth(cx)) {
case 1:
case 0:
default:
sprintf(str,"depth=%u at Suspend after %s from %s:%u at %s:%u (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
sprintf(str,"depth=%u at Resume after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
case 1:
break;
}
switch(JS_SuspendDepth(cx)) {
case 1:
break;
case 0:
default:
sprintf(str,"Suspend depth=%u at Resume after %s from %s:%lu at %s:%lu (%p)\n",JS_SuspendDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
logstr();
break;
}
req->type=LAST_REQUEST_TYPE_RESUME;
req->file=file;
req->line=line;
JS_ResumeRequest(cx, rc);
pthread_mutex_unlock(&req_mutex);
JS_ResumeRequest(cx, rc);
}
#endif
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