libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] Epoll Connection Leak


From: Chris Penev
Subject: [libmicrohttpd] Epoll Connection Leak
Date: Tue, 10 May 2016 18:16:37 -0700

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]