stop segfault on mac

This commit is contained in:
Adam D. Ruppe 2023-02-10 17:32:08 -05:00
parent e1a575f390
commit 853835196e
1 changed files with 11 additions and 4 deletions

15
cgi.d
View File

@ -3513,7 +3513,11 @@ string toHexUpper(long num) {
// the generic mixins // the generic mixins
/// Use this instead of writing your own main /++
Use this instead of writing your own main
It ultimately calls [cgiMainImpl] which creates a [RequestServer] for you.
+/
mixin template GenericMain(alias fun, long maxContentLength = defaultMaxContentLength) { mixin template GenericMain(alias fun, long maxContentLength = defaultMaxContentLength) {
mixin CustomCgiMain!(Cgi, fun, maxContentLength); mixin CustomCgiMain!(Cgi, fun, maxContentLength);
} }
@ -5478,7 +5482,8 @@ class ListeningConnectionManager {
fd_set read_fds; fd_set read_fds;
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
FD_SET(listener.handle, &read_fds); FD_SET(listener.handle, &read_fds);
FD_SET(cancelfd, &read_fds); if(cancelfd != -1)
FD_SET(cancelfd, &read_fds);
auto max = listener.handle > cancelfd ? listener.handle : cancelfd; auto max = listener.handle > cancelfd ? listener.handle : cancelfd;
auto ret = select(max + 1, &read_fds, null, null, null); auto ret = select(max + 1, &read_fds, null, null, null);
if(ret == -1) { if(ret == -1) {
@ -5489,7 +5494,7 @@ class ListeningConnectionManager {
throw new Exception("wtf select"); throw new Exception("wtf select");
} }
if(FD_ISSET(cancelfd, &read_fds)) { if(cancelfd != -1 && FD_ISSET(cancelfd, &read_fds)) {
return null; return null;
} }
@ -9480,8 +9485,10 @@ css";
Element htmlContainer() { Element htmlContainer() {
auto document = new Document(q"html auto document = new Document(q"html
<!DOCTYPE html> <!DOCTYPE html>
<html> <html class="no-script">
<head> <head>
<script>document.documentElement.classList.remove("no-script");</script>
<style>.no-script requires-script { display: none; }</style>
<title>D Application</title> <title>D Application</title>
<link rel="stylesheet" href="style.css" /> <link rel="stylesheet" href="style.css" />
</head> </head>