Hello everyone. When I use epoll (specifically external select), I can
create scenarios where the microhttpd library fails to detect client
disconnects. Assuming microtthpd is listening on 127.0.0.1:8080 and a
client does
$ echo -n GET | nc 127.0.0.1 8080
The microtthpd library receives two epoll events. Hence an strace shows
something along the lines of
epoll_wait(...)
recvfrom(..., "GET", ...)
recvfrom(..., "")
close(...)
However, if the client does something like this
$ { sleep 1; echo -n GET; } | nc 127.0.0.1 8080
Then in the above case microhttpd receives only one epoll event. Hence,
strace shows something along the lines of
epoll_wait(...)
recvfrom(..., "GET", ...)
Even futher calls to epoll_wait will not return additional events, and
microhttpd will never attempt a second recvfrom, and never figure out that
the client is gone.
I believe that because the epoll interface used by microhttpd is the edge
triggered one (which should be the more efficient one), microhttpd needs to
continue calling read until it receives EAGAIN, as documented under "man
epoll".
Otherwise, the connection ends up in the CLOSE-WAIT state. Note that in the
above example, none of the client handlers have been called either, so the
application cannot do anything about it either.
Lastly, I've attempted to subscribe to the mailing list, but have not
received a confirmation email, so please note that I may not be able to
read a reply that replies to the mailing list only.
Sincerely,
Chris P