gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r36890 - in libmicrohttpd: . src/include src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r36890 - in libmicrohttpd: . src/include src/microhttpd
Date: Wed, 3 Feb 2016 15:43:27 +0100

Author: grothoff
Date: 2016-02-03 15:43:27 +0100 (Wed, 03 Feb 2016)
New Revision: 36890

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/include/microhttpd.h
   libmicrohttpd/src/include/platform_interface.h
   libmicrohttpd/src/microhttpd/daemon.c
Log:
trying to fix full signal pipe issue reported on ML

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2016-02-01 14:59:22 UTC (rev 36889)
+++ libmicrohttpd/ChangeLog     2016-02-03 14:43:27 UTC (rev 36890)
@@ -1,3 +1,6 @@
+Wed Feb  3 15:41:57 CET 2016
+       Make signal-pipe non-blocking and drain it. -CG
+
 Sat Jan 30 15:49:07 CET 2016
        Fix running select() with empty fdsets on W32. -EG
 

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2016-02-01 14:59:22 UTC (rev 
36889)
+++ libmicrohttpd/src/include/microhttpd.h      2016-02-03 14:43:27 UTC (rev 
36890)
@@ -130,7 +130,7 @@
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00094801
+#define MHD_VERSION 0x00094802
 
 /**
  * MHD-internal return code for "YES".

Modified: libmicrohttpd/src/include/platform_interface.h
===================================================================
--- libmicrohttpd/src/include/platform_interface.h      2016-02-01 14:59:22 UTC 
(rev 36889)
+++ libmicrohttpd/src/include/platform_interface.h      2016-02-03 14:43:27 UTC 
(rev 36890)
@@ -161,12 +161,12 @@
 #define MHD_pipe_write_(fd, ptr, sz) send((fd), (const char*)(ptr), (sz), 0)
 #endif
 
-/* MHD_pipe_read_ read data from real pipe (!MHD_DONT_USE_PIPES) /
- *                read data from emulated pipe (MHD_DONT_USE_PIPES) */
+/* MHD_pipe_drain_ drain data from real pipe (!MHD_DONT_USE_PIPES) /
+ *                drain data from emulated pipe (MHD_DONT_USE_PIPES) */
 #ifndef MHD_DONT_USE_PIPES
-#define MHD_pipe_read_(fd, ptr, sz) read((fd), (void*)(ptr), (sz))
+#define MHD_pipe_drain_(fd) do { char tmp; while (0 < read((fd), &tmp, sizeof 
(tmp))) ; } while (0)
 #else
-#define MHD_pipe_read_(fd, ptr, sz) recv((fd), (char*)(ptr), (sz), 0)
+#define MHD_pipe_drain_(fd) do { char tmp; while (0 < recv((fd), &tmp, sizeof 
(tmp))) ; } while (0)
 #endif
 
 /* MHD_pipe_close_(fd) close any FDs (non-W32) /

Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c       2016-02-01 14:59:22 UTC (rev 
36889)
+++ libmicrohttpd/src/microhttpd/daemon.c       2016-02-03 14:43:27 UTC (rev 
36890)
@@ -962,7 +962,7 @@
           /* drain signaling pipe */
           if ( (MHD_INVALID_PIPE_ != spipe) &&
                (FD_ISSET (spipe, &rs)) )
-            (void) MHD_pipe_read_ (spipe, &tmp, sizeof (tmp));
+            MHD_pipe_drain_ (spipe);
 #endif
          /* call appropriate connection handler if necessary */
          if ( (FD_ISSET (con->socket_fd, &rs))
@@ -1034,7 +1034,7 @@
           /* drain signaling pipe */
           if ( (MHD_INVALID_PIPE_ != spipe) &&
                (0 != (p[1].revents & (POLLERR | POLLHUP))) )
-            (void) MHD_pipe_read_ (spipe, &tmp, sizeof (tmp));
+            MHD_pipe_drain_ (spipe);
 #endif
          if ( (0 != (p[0].revents & POLLIN))
 #if HTTPS_SUPPORT
@@ -2247,7 +2247,6 @@
                     const fd_set *except_fd_set)
 {
   MHD_socket ds;
-  char tmp;
   struct MHD_Connection *pos;
   struct MHD_Connection *next;
   unsigned int mask = MHD_USE_SUSPEND_RESUME | 
MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY |
@@ -2277,7 +2276,7 @@
   /* drain signaling pipe to avoid spinning select */
   if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
        (FD_ISSET (daemon->wpipe[0], read_fd_set)) )
-    (void) MHD_pipe_read_ (daemon->wpipe[0], &tmp, sizeof (tmp));
+    MHD_pipe_drain_ (daemon->wpipe[0]);
 
   if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
@@ -2496,7 +2495,6 @@
     unsigned int poll_server;
     int poll_listen;
     int poll_pipe;
-    char tmp;
     struct pollfd *p;
 
     p = malloc(sizeof (struct pollfd) * (2 + num_connections));
@@ -2640,7 +2638,7 @@
     /* handle pipe FD */
     if ( (-1 != poll_pipe) &&
          (0 != (p[poll_pipe].revents & POLLIN)) )
-      (void) MHD_pipe_read_ (daemon->wpipe[0], &tmp, sizeof (tmp));
+      MHD_pipe_drain_ (daemon->wpipe[0]);
 
     free(p);
   }
@@ -2768,7 +2766,6 @@
   int num_events;
   unsigned int i;
   unsigned int series_length;
-  char tmp;
 
   if (-1 == daemon->epoll_fd)
     return MHD_NO; /* we're down! */
@@ -2850,7 +2847,7 @@
           if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
                (daemon->wpipe[0] == events[i].data.fd) )
             {
-              (void) MHD_pipe_read_ (daemon->wpipe[0], &tmp, sizeof (tmp));
+              MHD_pipe_drain_ (daemon->wpipe[0]);
               continue;
             }
          if (daemon != events[i].data.ptr)
@@ -3778,6 +3775,8 @@
       free (daemon);
       return NULL;
     }
+  make_nonblocking (daemon, daemon->wpipe[0]);
+  make_nonblocking (daemon, daemon->wpipe[1]);
 #ifndef MHD_WINSOCK_SOCKETS
   if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY))) &&
        (1 == use_pipe) &&




reply via email to

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