Skip to content

Commit

Permalink
Run: enable threading only when required for the protocol (>= HTTP/1.1)
Browse files Browse the repository at this point in the history
When threaded, the server is more likely to crash from socket send/recv/select issues, for reasons that are currently unclear. However, HTTP/1.0 seems to respond fast enough from a single thread, so threading isn't strictly needed there.
  • Loading branch information
joshtynjala committed Aug 6, 2024
1 parent dfc8b3c commit bf22773
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/snake/Run.hx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ class Run {
RunHTTPRequestHandler.cacheEnabled = cacheEnabled;
RunHTTPRequestHandler.silent = silent;
var httpServer = new RunHTTPServer(new Host(address), port, RunHTTPRequestHandler, true, directory);
httpServer.threading = true;
// HTTP/1.1 basically requires threads due to keeping the connection
// open after response, so we have no choice but to enable threading.
// ideally, it would be threaded for HTTP/1.0 too, but for reasons that
// are currently unclear, socket errors are causing crashes when
// threaded. better to prefer stability until it can be resolved.
httpServer.threading = protocol >= "HTTP/1.1";

if (openBrowser) {
var url = 'http://${address}:${port}';
Expand Down

0 comments on commit bf22773

Please sign in to comment.