internal_add_connection: refuse blocking sockets in epoll mode

This commit is contained in:
Evgeny Grin (Karlson2k)
2020-10-08 15:20:50 +03:00
parent 558a5c86b2
commit e58fbba00a
+16 -3
View File
@@ -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