aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 14009c92..219fb1be 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -71,10 +71,10 @@
71/** 71/**
72 * Default connection limit. 72 * Default connection limit.
73 */ 73 */
74#ifndef MHD_WINSOCK_SOCKETS 74#ifdef MHD_POSIX_SOCKETS
75#define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 4) 75#define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 4)
76#else 76#else
77#define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE 77#define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 2)
78#endif 78#endif
79 79
80/** 80/**
@@ -2338,7 +2338,12 @@ MHD_select (struct MHD_Daemon *daemon,
2338 2338
2339 /* single-threaded, go over everything */ 2339 /* single-threaded, go over everything */
2340 if (MHD_NO == MHD_get_fdset2 (daemon, &rs, &ws, &es, &max, FD_SETSIZE)) 2340 if (MHD_NO == MHD_get_fdset2 (daemon, &rs, &ws, &es, &max, FD_SETSIZE))
2341 return MHD_NO; 2341 {
2342#if HAVE_MESSAGES
2343 MHD_DLOG (daemon, "Could not obtain daemon fdsets");
2344#endif
2345 return MHD_NO;
2346 }
2342 2347
2343 /* If we're at the connection limit, no need to 2348 /* If we're at the connection limit, no need to
2344 accept new connections; however, make sure 2349 accept new connections; however, make sure
@@ -2358,14 +2363,42 @@ MHD_select (struct MHD_Daemon *daemon,
2358 &rs, 2363 &rs,
2359 &max, 2364 &max,
2360 FD_SETSIZE)) ) 2365 FD_SETSIZE)) )
2361 return MHD_NO; 2366 {
2367#if HAVE_MESSAGES
2368 MHD_DLOG (daemon, "Could not add listen socket to fdset");
2369#endif
2370 return MHD_NO;
2371 }
2362 } 2372 }
2363 if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) && 2373 if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
2364 (MHD_YES != add_to_fd_set (daemon->wpipe[0], 2374 (MHD_YES != add_to_fd_set (daemon->wpipe[0],
2365 &rs, 2375 &rs,
2366 &max, 2376 &max,
2367 FD_SETSIZE)) ) 2377 FD_SETSIZE)) )
2368 return MHD_NO; 2378 {
2379#if defined(MHD_WINSOCK_SOCKETS)
2380 /* fdset limit reached, new connections
2381 cannot be handled. Remove listen socket FD
2382 from fdset and retry to add pipe FD. */
2383 if (MHD_INVALID_SOCKET != daemon->socket_fd)
2384 {
2385 FD_CLR (daemon->socket_fd, &rs);
2386 if (MHD_YES != add_to_fd_set (daemon->wpipe[0],
2387 &rs,
2388 &max,
2389 FD_SETSIZE))
2390 {
2391#endif /* MHD_WINSOCK_SOCKETS */
2392#if HAVE_MESSAGES
2393 MHD_DLOG (daemon,
2394 "Could not add control pipe FD to fdset");
2395#endif
2396 return MHD_NO;
2397#if defined(MHD_WINSOCK_SOCKETS)
2398 }
2399 }
2400#endif /* MHD_WINSOCK_SOCKETS */
2401 }
2369 2402
2370 tv = NULL; 2403 tv = NULL;
2371 if (MHD_NO == may_block) 2404 if (MHD_NO == may_block)