libmicrohttpd

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

commit e58fbba00a9439fc918d0ebd44f943818cb664f7
parent 558a5c86b2f3b485dd0c162fb3204c9c00810920
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu,  8 Oct 2020 15:20:50 +0300

internal_add_connection: refuse blocking sockets in epoll mode

Diffstat:
Msrc/microhttpd/daemon.c | 19++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2404,9 +2404,8 @@ internal_add_connection (struct MHD_Daemon *daemon, } #endif - if ( (! MHD_SCKT_FD_FITS_FDSET_ (client_socket, - NULL)) && - (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) ) + if ( (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) && + (! MHD_SCKT_FD_FITS_FDSET_ (client_socket, NULL)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, @@ -2415,6 +2414,20 @@ internal_add_connection (struct MHD_Daemon *daemon, (int) FD_SETSIZE); #endif MHD_socket_close_chk_ (client_socket); +#if ENFILE + errno = ENFILE; +#endif + return MHD_NO; + } + + if ( (0 == (daemon->options & MHD_USE_EPOLL)) && + (! non_blck) ) + { +#ifdef HAVE_MESSAGES + MHD_DLOG (daemon, + _ ("Epoll mode supports only non-blocking sockets\n")); +#endif + MHD_socket_close_chk_ (client_socket); #if EINVAL errno = EINVAL; #endif