jeremycw / httpserver.h

Single header library for writing non-blocking HTTP servers in C
MIT License
1.78k stars 143 forks source link

Fix broken connection after interrupted write #60

Closed suyjuris closed 1 year ago

suyjuris commented 2 years ago

Fixes #59.

When writing the answer to an HTTP request into the socket, the write might have to proceed in multiple parts. (E.g. if the receiver is not able to receive the data fast enough.) To deal with this situation, the server continues execution after a partial write, but changes the flag on the request's epoll object to trigger once the request's socket becomes writable again. However, once the response is fully written, the flags are not changed back, so that subsequent requests (for a keep-alive connection) do not trigger epoll, resulting in the server missing requests.

jeremycw commented 1 year ago

I've incorporated a similar fix into the latest release.