Browse Source

Renamed 'MHD_pipe_drain_' -> 'MHD_itc_clear_'

Evgeny Grin (Karlson2k) 9 years ago
parent
commit
faa231001d
2 changed files with 26 additions and 19 deletions
  1. 6 6
      src/microhttpd/daemon.c
  2. 20 13
      src/microhttpd/mhd_itc.h

+ 6 - 6
src/microhttpd/daemon.c

@@ -1416,7 +1416,7 @@ thread_main_handle_connection (void *data)
           if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
                (FD_ISSET (MHD_itc_r_fd_ (daemon->itc),
                           &rs)) )
-            MHD_pipe_drain_ (daemon->itc);
+            MHD_itc_clear_ (daemon->itc);
 #endif
           if (MHD_NO ==
               call_handlers (con,
@@ -1487,7 +1487,7 @@ thread_main_handle_connection (void *data)
           /* drain signaling pipe before other processing */
           if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
                (0 != (p[1].revents & (POLLERR | POLLHUP | POLLIN))) )
-            MHD_pipe_drain_ (daemon->itc);
+            MHD_itc_clear_ (daemon->itc);
 #endif
           if (MHD_NO ==
               call_handlers (con,
@@ -2707,7 +2707,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
   if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
        (FD_ISSET (MHD_itc_r_fd_ (daemon->itc),
                   read_fd_set)) )
-    MHD_pipe_drain_ (daemon->itc);
+    MHD_itc_clear_ (daemon->itc);
 
   /* Resuming external connections when using an extern mainloop  */
   if (MHD_USE_SUSPEND_RESUME == (daemon->options & mask))
@@ -3088,7 +3088,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
        new signals will be processed in next loop */
     if ( (-1 != poll_pipe) &&
          (0 != (p[poll_pipe].revents & POLLIN)) )
-      MHD_pipe_drain_ (daemon->itc);
+      MHD_itc_clear_ (daemon->itc);
 
     /* handle shutdown */
     if (MHD_YES == daemon->shutdown)
@@ -3214,7 +3214,7 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
     }
   if ( (-1 != poll_pipe) &&
        (0 != (p[poll_pipe].revents & POLLIN)) )
-    MHD_pipe_drain_ (daemon->itc);
+    MHD_itc_clear_ (daemon->itc);
 
   /* handle shutdown */
   if (MHD_YES == daemon->shutdown)
@@ -3497,7 +3497,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
             {
               /* It's OK to drain pipe here as all external
                  conditions will be processed later. */
-              MHD_pipe_drain_ (daemon->itc);
+              MHD_itc_clear_ (daemon->itc);
               continue;
             }
 	  if (daemon == events[i].data.ptr)

+ 20 - 13
src/microhttpd/mhd_itc.h

@@ -90,12 +90,13 @@ static const uint64_t _MHD_itc_wr_data = 1;
 #define MHD_itc_w_fd_(itc) ((int)(itc))
 
 /**
- * drain data from real pipe
+ * Clear signaled state on @a itc
+ * @param itc the itc to clear
  */
-#define MHD_pipe_drain_(pip) do { \
-   uint64_t tmp; \
-   read (pip, &tmp, sizeof (tmp)); \
- } while (0)
+#define MHD_itc_clear_(itc)                  \
+  do { uint64_t __b; int __r;                \
+       __r = read((itc), &__b, sizeof(__b)); \
+       (void)__r; } while(0)
 
 /**
  * Close any FDs of the pipe (non-W32)
@@ -178,12 +179,13 @@ static const uint64_t _MHD_itc_wr_data = 1;
 #define MHD_itc_w_fd_(itc) ((itc).fd[1])
 
 /**
- * drain data from real pipe
+ * Clear signaled state on @a itc
+ * @param itc the itc to clear
  */
-#define MHD_pipe_drain_(pip) do { \
-   long tmp; \
-   while (0 < read((pip).fd[0], (void*)&tmp, sizeof (tmp))) ; \
- } while (0)
+#define MHD_itc_clear_(itc) do                      \
+  { long __b;                                       \
+    while(0 < read((itc).fd[0], &__b, sizeof(__b))) \
+    {} } while(0)
 
 /**
  * Close any FDs of the pipe (non-W32)
@@ -263,10 +265,15 @@ MHD_itc_nonblocking_ (MHD_itc_ itc);
 #define MHD_itc_w_fd_(itc) ((itc).sk[1])
 
 /**
- * Drain data from emulated pipe
+ * Clear signaled state on @a itc
+ * @param itc the itc to clear
  */
-#define MHD_pipe_drain_(pip) do { long tmp; while (0 < recv((pip).sk[0], (void*)&tmp, sizeof (tmp), 0)) ; } while (0)
-
+#define MHD_itc_clear_(itc) do      \
+  { long __b;                       \
+    while(0 < recv((itc).sk[0],     \
+                   (char*)&__b,     \
+                   sizeof(__b), 0)) \
+    {} } while(0)
 
 /**
  * Close emulated pipe FDs