libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit c36a7c7f305d3aaab29ab88b3ef49fa192988965
parent abb31c0a77bdf16f247f0540e022f09fb8456eac
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue, 28 Feb 2017 22:34:16 +0300

Fixed attempts to accept incoming connection on shutdown of listen socket

Diffstat:
Msrc/microhttpd/daemon.c | 25+++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -3915,16 +3915,21 @@ MHD_epoll (struct MHD_Daemon *daemon, } if (daemon == events[i].data.ptr) { - unsigned int series_length = 0; - /* Run 'accept' until it fails or daemon at limit of connections. - * Do not accept more then 10 connections at once. The rest will - * be accepted on next turn (level trigger is used for listen - * socket). */ - while ( (MHD_YES == MHD_accept_connection (daemon)) && - (series_length < 10) && - (daemon->connections < daemon->connection_limit) && - (! daemon->at_limit) ) - series_length++; + /* Check for error conditions on listen socket. */ + /* FIXME: Initiate MHD_quiesce_daemon() to prevent busy waiting? */ + if (0 == (events[i].events & (EPOLLERR | EPOLLHUP))) + { + unsigned int series_length = 0; + /* Run 'accept' until it fails or daemon at limit of connections. + * Do not accept more then 10 connections at once. The rest will + * be accepted on next turn (level trigger is used for listen + * socket). */ + while ( (MHD_YES == MHD_accept_connection (daemon)) && + (series_length < 10) && + (daemon->connections < daemon->connection_limit) && + (! daemon->at_limit) ) + series_length++; + } continue; } /* this is an event relating to a 'normal' connection,