Closed vphantom closed 1 year ago
I still need to address two issues:
[x] There is a small time window between thread creation and its blocking of SIGINT/SIGHUP where it might be made to handle those signals. That's okay, but it would make the main accept()
loop only terminate after the next incoming connection so it's not ideal. I need to experiment with blocking them in the root thread and to unblock again after cloning to see if the OCaml runtime discards or spools them.
[ ] How to interrupt threads while they're reading between web requests but not in a manner which interferes with reading a long request already in progress. That might mean surviving an exception in read()
and looking at the global flag before doing a between-requests read. It's not elegant.
Yikes, I'm not touching my 2nd point with a 10-foot pole. Your call stack is deep to finally get to the actual Unix.read
from parse_req_start
so my chances of refactoring that to exit between requests in a decent number of days is zero. 😬
Basically we would have to offer a high-level option to the line reading function, which we would use only when reading the first line of a new request, that we want to trickle down to the low actual I/O function that we want to keep an eye on our running bool every second with Unix.select
wrapped around the Unix.read
. This would affect a ton of stuff I don't really understand so I'll just tolerate the 60-second delay in shutting down.
This is thus ready for review.
Yup, great idea. Will do within the hour.
Thank you!
Just creating the work environment, I'm not done yet.