From e58fbba00a9439fc918d0ebd44f943818cb664f7 Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Thu, 8 Oct 2020 15:20:50 +0300 Subject: [PATCH] internal_add_connection: refuse blocking sockets in epoll mode --- src/microhttpd/daemon.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 42c21b6c..c5e51d37 100644 --- 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