fix bug added with wrong continue

This commit is contained in:
Adam D. Ruppe 2023-08-16 10:04:02 -04:00
parent 7150cd81f4
commit 682ddd0563
1 changed files with 22 additions and 6 deletions

20
cgi.d
View File

@ -6296,7 +6296,7 @@ class WorkerThread : Thread {
// might have beat us to it, but the wakeup event thundered our herds. // might have beat us to it, but the wakeup event thundered our herds.
try try
sn = listener.accept(); // don't need to do the acceptCancelable here since the epoll checks it better sn = listener.accept(); // don't need to do the acceptCancelable here since the epoll checks it better
catch(SocketAcceptException e) { continue; } catch(SocketAcceptException e) { continue outer; }
cloexec(sn); cloexec(sn);
if(lcm.tcp) { if(lcm.tcp) {
@ -6310,11 +6310,13 @@ class WorkerThread : Thread {
dg(sn); dg(sn);
continue outer; continue outer;
} else {
// writeln(events[idx].data.ptr);
} }
} }
if(cast(size_t) events[idx].data.ptr < 1024) { if(cast(size_t) events[idx].data.ptr < 1024) {
throw new Exception("this doesn't look like a fiber pointer..."); throw arsd.core.ArsdException!"this doesn't look like a fiber pointer... "(cast(size_t) events[idx].data.ptr);
} }
auto fiber = cast(CgiFiber) events[idx].data.ptr; auto fiber = cast(CgiFiber) events[idx].data.ptr;
fiber.proceed(); fiber.proceed();
@ -9921,10 +9923,24 @@ html", true, true);
case "html": case "html":
presentExceptionAsHtml(cgi, t, meta); presentExceptionAsHtml(cgi, t, meta);
break; break;
case "json":
presentExceptionAsJsonImpl(cgi, t);
break;
default: default:
} }
} }
private void presentExceptionAsJsonImpl()(Cgi cgi, Throwable t) {
cgi.setResponseStatus("500 Internal Server Error");
cgi.setResponseContentType("application/json");
import arsd.jsvar;
var v = var.emptyObject;
v.type = typeid(t).toString;
v.msg = t.msg;
v.fullString = t.toString();
cgi.write(v.toJson(), true);
}
/++ /++
If you override this, you will need to cast the exception type `t` dynamically, If you override this, you will need to cast the exception type `t` dynamically,