From 680003ae8750a202d0d156abe4120031587d8b2e Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Thu, 9 Mar 2023 21:49:45 -0500 Subject: [PATCH] a stop hack for embedded httpd threads on windows --- cgi.d | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cgi.d b/cgi.d index 785e486..6558fd1 100644 --- a/cgi.d +++ b/cgi.d @@ -5521,8 +5521,25 @@ class ListeningConnectionManager { return listener.accept(); return null; - } else - return listener.accept(); // FIXME: check the cancel flag! + } else { + + Socket socket = listener; + + auto check = new SocketSet(); + + keep_looping: + check.reset(); + check.add(socket); + + // just to check the stop flag on a kinda busy loop. i hate this FIXME + auto got = Socket.select(check, null, null, 3.seconds); + if(got > 0) + return listener.accept(); + if(globalStopFlag) + return null; + else + goto keep_looping; + } } int defaultNumberOfThreads() {