gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36741 - libmicrohttpd/src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r36741 - libmicrohttpd/src/microhttpd
Date: Tue, 8 Dec 2015 20:35:42 +0100

Author: Karlson2k
Date: 2015-12-08 20:35:42 +0100 (Tue, 08 Dec 2015)
New Revision: 36741

Modified:
   libmicrohttpd/src/microhttpd/daemon.c
Log:
daemon.c: print log messages when dealing with fdsets on all platforms;
replace listen socket in fdset with pipe FD instead of failing if no fdset 
space is available on W32.

Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c       2015-12-08 14:25:00 UTC (rev 
36740)
+++ libmicrohttpd/src/microhttpd/daemon.c       2015-12-08 19:35:42 UTC (rev 
36741)
@@ -71,10 +71,10 @@
 /**
  * Default connection limit.
  */
-#ifndef MHD_WINSOCK_SOCKETS
+#ifdef MHD_POSIX_SOCKETS
 #define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 4)
 #else
-#define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE
+#define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 2)
 #endif
 
 /**
@@ -2338,7 +2338,12 @@
 
       /* single-threaded, go over everything */
       if (MHD_NO == MHD_get_fdset2 (daemon, &rs, &ws, &es, &max, FD_SETSIZE))
-        return MHD_NO;
+        {
+#if HAVE_MESSAGES
+        MHD_DLOG (daemon, "Could not obtain daemon fdsets");
+#endif
+          return MHD_NO;
+        }
 
       /* If we're at the connection limit, no need to
          accept new connections; however, make sure
@@ -2358,7 +2363,12 @@
                                       &rs,
                                       &max,
                                       FD_SETSIZE)) )
-        return MHD_NO;
+        {
+#if HAVE_MESSAGES
+          MHD_DLOG (daemon, "Could not add listen socket to fdset");
+#endif
+          return MHD_NO;
+        }
     }
   if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
        (MHD_YES != add_to_fd_set (daemon->wpipe[0],
@@ -2365,7 +2375,30 @@
                                   &rs,
                                   &max,
                                   FD_SETSIZE)) )
-    return MHD_NO;
+    {
+#if defined(MHD_WINSOCK_SOCKETS)
+      /* fdset limit reached, new connections
+         cannot be handled. Remove listen socket FD
+         from fdset and retry to add pipe FD. */
+      if (MHD_INVALID_SOCKET != daemon->socket_fd)
+        {
+          FD_CLR (daemon->socket_fd, &rs);
+          if (MHD_YES != add_to_fd_set (daemon->wpipe[0],
+                                        &rs,
+                                        &max,
+                                        FD_SETSIZE))
+            {
+#endif /* MHD_WINSOCK_SOCKETS */
+#if HAVE_MESSAGES
+              MHD_DLOG (daemon,
+                        "Could not add control pipe FD to fdset");
+#endif
+              return MHD_NO;
+#if defined(MHD_WINSOCK_SOCKETS)
+            }
+        }
+#endif /* MHD_WINSOCK_SOCKETS */
+    }
 
   tv = NULL;
   if (MHD_NO == may_block)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]