X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fnetwork%2Fhttpd.c;h=26d0f4cd13a4918051262308558c9440e6cffeb5;hb=533d6dbf37d7a32ee339058f6657f64ba1009525;hp=e54bcca244c9ee504264dbb04de8dd9c2bb16289;hpb=e611fdaed9c43584597eba1d1a7002cda5c9961a;p=vlc diff --git a/src/network/httpd.c b/src/network/httpd.c index e54bcca244..26d0f4cd13 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -2436,6 +2436,7 @@ static void httpd_HostThread( httpd_host_t *host ) struct sockaddr_storage sock; fd = accept( fd, (struct sockaddr *)&sock, &i_sock_size ); + if( fd >= 0 ) { int i_state = 0; @@ -2447,9 +2448,20 @@ static void httpd_HostThread( httpd_host_t *host ) ioctlsocket( fd, FIONBIO, &i_dummy ); } #else - fcntl( fd, F_SETFL, O_NONBLOCK ); -#endif + fcntl( fd, F_SETFD, FD_CLOEXEC ); + { + int i_val = fcntl( fd, F_GETFL ); + fcntl( fd, F_SETFL, + O_NONBLOCK | (i_val != -1) ? i_val : 0 ); + } + if( fd >= FD_SETSIZE ) + { + net_Close( fd ); + fd = -1; + } + else +#endif if( p_tls != NULL) { switch ( tls_ServerSessionHandshake( p_tls, fd ) )