mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-18 19:40:57 +00:00
stop() takes the listening socket away, and listen() then waits for every handler to return. A WebSocket handler waiting in read() on a client that stays connected never learned of the stop: with no read timeout it waited for the 300 s backstop, and with one it got Timeout back on an open connection, so a `while (ws.read(msg) != Fail)` loop went on forever and listen() with it. The server now hands each WebSocket a predicate for its own stop, and the WebSocket's read interrupt answers to it as it does to a pong timeout. A read cut short while the server stops, between messages or in the middle of a fragmented one, sends a Close with 1001 Going Away and returns Fail. That close does not wait for the peer's reply, so a stop is not held up per connection. A server WebSocket's reads now wait in the interruptible slices whatever the heartbeat settings, as keep-alive connections already do for the same check.