Jelajahi Sumber

Renamed 'MHD_Daemon.wpipe' -> 'MHD_Daemon.itc'

Evgeny Grin (Karlson2k) 9 tahun lalu
induk
melakukan
787696975f
3 mengubah file dengan 67 tambahan dan 67 penghapusan
  1. 2 2
      src/microhttpd/connection.c
  2. 64 64
      src/microhttpd/daemon.c
  3. 1 1
      src/microhttpd/internal.h

+ 2 - 2
src/microhttpd/connection.c

@@ -520,8 +520,8 @@ MHD_connection_close_ (struct MHD_Connection *connection,
      thread-per-connection mode, signal the main thread
      to resume accepting connections */
   if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-       (! MHD_INVALID_PIPE_ (daemon->wpipe)) &&
-       (1 != MHD_pipe_write_ (daemon->wpipe,
+       (! MHD_INVALID_PIPE_ (daemon->itc)) &&
+       (1 != MHD_pipe_write_ (daemon->itc,
                               "c",
                               1)) )
     {

+ 64 - 64
src/microhttpd/daemon.c

@@ -1374,9 +1374,9 @@ thread_main_handle_connection (void *data)
 	      goto exit;
 	    }
 #if WINDOWS
-          if (! MHD_INVALID_PIPE_(daemon->wpipe) )
+          if (! MHD_INVALID_PIPE_(daemon->itc) )
             {
-              if (! MHD_add_to_fd_set_ (MHD_pipe_get_read_fd_ (daemon->wpipe),
+              if (! MHD_add_to_fd_set_ (MHD_pipe_get_read_fd_ (daemon->itc),
                                         &rs,
                                         &maxsock,
                                         FD_SETSIZE))
@@ -1413,10 +1413,10 @@ thread_main_handle_connection (void *data)
 	    }
 #if WINDOWS
           /* drain signaling pipe before other processing */
-          if ( (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
-               (FD_ISSET (MHD_pipe_get_read_fd_ (daemon->wpipe),
+          if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
+               (FD_ISSET (MHD_pipe_get_read_fd_ (daemon->itc),
                           &rs)) )
-            MHD_pipe_drain_ (daemon->wpipe);
+            MHD_pipe_drain_ (daemon->itc);
 #endif
           if (MHD_NO ==
               call_handlers (con,
@@ -1458,10 +1458,10 @@ thread_main_handle_connection (void *data)
 	    }
 #if WINDOWS
           extra_slot = 0;
-          if (! MHD_INVALID_PIPE_(daemon->wpipe))
+          if (! MHD_INVALID_PIPE_(daemon->itc))
             {
               p[1].events |= POLLIN;
-              p[1].fd = MHD_pipe_get_read_fd_ (daemon->wpipe);
+              p[1].fd = MHD_pipe_get_read_fd_ (daemon->itc);
               p[1].revents = 0;
               extra_slot = 1;
             }
@@ -1485,9 +1485,9 @@ thread_main_handle_connection (void *data)
 	    }
 #if WINDOWS
           /* drain signaling pipe before other processing */
-          if ( (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
+          if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
                (0 != (p[1].revents & (POLLERR | POLLHUP | POLLIN))) )
-            MHD_pipe_drain_ (daemon->wpipe);
+            MHD_pipe_drain_ (daemon->itc);
 #endif
           if (MHD_NO ==
               call_handlers (con,
@@ -2028,8 +2028,8 @@ internal_add_connection (struct MHD_Daemon *daemon,
     }
   else
     if ( (MHD_YES == external_add) &&
-	 (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
-	 (1 != MHD_pipe_write_ (daemon->wpipe,
+	 (! MHD_INVALID_PIPE_(daemon->itc)) &&
+	 (1 != MHD_pipe_write_ (daemon->itc,
                                 "n",
                                 1)) )
       {
@@ -2211,8 +2211,8 @@ MHD_resume_connection (struct MHD_Connection *connection)
     MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
   connection->resuming = MHD_YES;
   daemon->resuming = MHD_YES;
-  if ( (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
-       (1 != MHD_pipe_write_ (daemon->wpipe, "r", 1)) )
+  if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
+       (1 != MHD_pipe_write_ (daemon->itc, "r", 1)) )
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
@@ -2706,10 +2706,10 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
   /* drain signaling pipe to avoid spinning select */
   /* Do it before any other processing so new signals
      will trigger select again and will be processed */
-  if ( (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
-       (FD_ISSET (MHD_pipe_get_read_fd_ (daemon->wpipe),
+  if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
+       (FD_ISSET (MHD_pipe_get_read_fd_ (daemon->itc),
                   read_fd_set)) )
-    MHD_pipe_drain_ (daemon->wpipe);
+    MHD_pipe_drain_ (daemon->itc);
 
   /* Resuming external connections when using an extern mainloop  */
   if (MHD_USE_SUSPEND_RESUME == (daemon->options & mask))
@@ -2842,8 +2842,8 @@ MHD_select (struct MHD_Daemon *daemon,
           return MHD_NO;
         }
     }
-  if ( (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
-       (! MHD_add_to_fd_set_ (MHD_pipe_get_read_fd_ (daemon->wpipe),
+  if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
+       (! MHD_add_to_fd_set_ (MHD_pipe_get_read_fd_ (daemon->itc),
                               &rs,
                               &maxsock,
                               FD_SETSIZE)) )
@@ -2856,7 +2856,7 @@ MHD_select (struct MHD_Daemon *daemon,
         {
           FD_CLR (daemon->socket_fd,
                   &rs);
-          if (! MHD_add_to_fd_set_ (MHD_pipe_get_read_fd_(daemon->wpipe),
+          if (! MHD_add_to_fd_set_ (MHD_pipe_get_read_fd_(daemon->itc),
                                     &rs,
                                     &maxsock,
                                     FD_SETSIZE))
@@ -2879,7 +2879,7 @@ MHD_select (struct MHD_Daemon *daemon,
      only do this optimization if we have a signaling pipe in
      place. */
   if ( (MHD_INVALID_SOCKET != daemon->socket_fd) &&
-       (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
+       (! MHD_INVALID_PIPE_(daemon->itc)) &&
        (0 != (daemon->options & MHD_USE_PIPE_FOR_SHUTDOWN)) &&
        ( (daemon->connections == daemon->connection_limit) ||
          (MHD_YES == daemon->at_limit) ) )
@@ -3004,9 +3004,9 @@ MHD_poll_all (struct MHD_Daemon *daemon,
 	poll_server++;
       }
     poll_pipe = -1;
-    if (! MHD_INVALID_PIPE_(daemon->wpipe))
+    if (! MHD_INVALID_PIPE_(daemon->itc))
       {
-	p[poll_server].fd = MHD_pipe_get_read_fd_ (daemon->wpipe);
+	p[poll_server].fd = MHD_pipe_get_read_fd_ (daemon->itc);
 	p[poll_server].events = POLLIN;
 	p[poll_server].revents = 0;
         poll_pipe = (int) poll_server;
@@ -3090,7 +3090,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->wpipe);
+      MHD_pipe_drain_ (daemon->itc);
 
     /* handle shutdown */
     if (MHD_YES == daemon->shutdown)
@@ -3185,9 +3185,9 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
       poll_listen = poll_count;
       poll_count++;
     }
-  if (! MHD_INVALID_PIPE_(daemon->wpipe))
+  if (! MHD_INVALID_PIPE_(daemon->itc))
     {
-      p[poll_count].fd = MHD_pipe_get_read_fd_ (daemon->wpipe);
+      p[poll_count].fd = MHD_pipe_get_read_fd_ (daemon->itc);
       p[poll_count].events = POLLIN;
       p[poll_count].revents = 0;
       poll_pipe = poll_count;
@@ -3216,7 +3216,7 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
     }
   if ( (-1 != poll_pipe) &&
        (0 != (p[poll_pipe].revents & POLLIN)) )
-    MHD_pipe_drain_ (daemon->wpipe);
+    MHD_pipe_drain_ (daemon->itc);
 
   /* handle shutdown */
   if (MHD_YES == daemon->shutdown)
@@ -3491,15 +3491,15 @@ MHD_epoll (struct MHD_Daemon *daemon,
 #endif
           /* UGH: we're storing pointers and fds in the same union
              here; incredibly ugly and somewhat risky, even though a
-             pointer with the same numeric value as the wpipe.fd[0] can
+             pointer with the same numeric value as the itc.fd[0] can
              be expected to be rare... FIXME (a construction similar
              to what we did with the `upgrade_marker` should do) */
-          if ( (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
-               (MHD_pipe_get_read_fd_ (daemon->wpipe) == events[i].data.fd) )
+          if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
+               (MHD_pipe_get_read_fd_ (daemon->itc) == events[i].data.fd) )
             {
               /* It's OK to drain pipe here as all external
                  conditions will be processed later. */
-              MHD_pipe_drain_ (daemon->wpipe);
+              MHD_pipe_drain_ (daemon->itc);
               continue;
             }
 	  if (daemon == events[i].data.ptr)
@@ -3762,7 +3762,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
   ret = daemon->socket_fd;
   if (MHD_INVALID_SOCKET == ret)
     return MHD_INVALID_SOCKET;
-  if ( (MHD_INVALID_PIPE_(daemon->wpipe)) &&
+  if ( (MHD_INVALID_PIPE_(daemon->itc)) &&
        (0 != (daemon->options & (MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION))) )
     {
 #ifdef HAVE_MESSAGES
@@ -3790,9 +3790,9 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
 	  }
         else
 #endif
-        if (! MHD_INVALID_PIPE_(daemon->worker_pool[i].wpipe))
+        if (! MHD_INVALID_PIPE_(daemon->worker_pool[i].itc))
           {
-            if (1 != MHD_pipe_write_ (daemon->worker_pool[i].wpipe,
+            if (1 != MHD_pipe_write_ (daemon->worker_pool[i].itc,
                                       "q",
                                       1))
               MHD_PANIC (_("Failed to signal quiesce via pipe"));
@@ -3813,9 +3813,9 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
     }
   else
 #endif
-    if (! MHD_INVALID_PIPE_(daemon->wpipe))
+    if (! MHD_INVALID_PIPE_(daemon->itc))
     {
-      if (1 != MHD_pipe_write_ (daemon->wpipe,
+      if (1 != MHD_pipe_write_ (daemon->itc,
                                 "q",
                                 1))
 	MHD_PANIC (_("failed to signal quiesce via pipe"));
@@ -4328,15 +4328,15 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
 #endif
       return MHD_NO;
     }
-  if ( (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
+  if ( (! MHD_INVALID_PIPE_(daemon->itc)) &&
        (MHD_USE_SUSPEND_RESUME == (daemon->options & MHD_USE_SUSPEND_RESUME)) )
     {
       event.events = EPOLLIN | EPOLLET;
       event.data.ptr = NULL;
-      event.data.fd = MHD_pipe_get_read_fd_ (daemon->wpipe);
+      event.data.fd = MHD_pipe_get_read_fd_ (daemon->itc);
       if (0 != epoll_ctl (daemon->epoll_fd,
                           EPOLL_CTL_ADD,
-                          MHD_pipe_get_read_fd_ (daemon->wpipe),
+                          MHD_pipe_get_read_fd_ (daemon->itc),
                           &event))
         {
 #ifdef HAVE_MESSAGES
@@ -4443,7 +4443,7 @@ MHD_start_daemon_va (unsigned int flags,
   daemon->pool_increment = MHD_BUF_INC_SIZE;
   daemon->unescape_callback = &unescape_wrapper;
   daemon->connection_timeout = 0;       /* no timeout */
-  MHD_make_invalid_pipe_ (daemon->wpipe);
+  MHD_make_invalid_pipe_ (daemon->itc);
 #ifdef SOMAXCONN
   daemon->listen_backlog_size = SOMAXCONN;
 #else  /* !SOMAXCONN */
@@ -4462,7 +4462,7 @@ MHD_start_daemon_va (unsigned int flags,
     use_pipe = 0; /* useless if we are using 'external' select */
   if (use_pipe)
   {
-    if (! MHD_itc_init_ (daemon->wpipe))
+    if (! MHD_itc_init_ (daemon->itc))
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
@@ -4472,28 +4472,28 @@ MHD_start_daemon_va (unsigned int flags,
       free (daemon);
       return NULL;
     }
-    if (! MHD_itc_nonblocking_ (daemon->wpipe))
+    if (! MHD_itc_nonblocking_ (daemon->itc))
       {
 #ifdef HAVE_MESSAGES
         MHD_DLOG (daemon,
 		  _("Failed to make read side of inter-thread control channel non-blocking: %s\n"),
 		  MHD_pipe_last_strerror_ ());
 #endif
-        MHD_pipe_close_ (daemon->wpipe);
+        MHD_pipe_close_ (daemon->itc);
         free (daemon);
         return NULL;
       }
   }
   if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) &&
        (1 == use_pipe) &&
-       (! MHD_SCKT_FD_FITS_FDSET_(MHD_pipe_get_read_fd_ (daemon->wpipe),
+       (! MHD_SCKT_FD_FITS_FDSET_(MHD_pipe_get_read_fd_ (daemon->itc),
                                   NULL)) )
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
 		_("file descriptor for control pipe exceeds maximum value\n"));
 #endif
-      MHD_pipe_close_ (daemon->wpipe);
+      MHD_pipe_close_ (daemon->itc);
       free (daemon);
       return NULL;
     }
@@ -4984,7 +4984,7 @@ MHD_start_daemon_va (unsigned int flags,
           /* Always use individual control pipes */
           if (1)
             {
-              if (! MHD_itc_init_ (d->wpipe))
+              if (! MHD_itc_init_ (d->itc))
                 {
 #ifdef HAVE_MESSAGES
                   MHD_DLOG (daemon,
@@ -4993,7 +4993,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
                   goto thread_failed;
                 }
-              if (! MHD_itc_nonblocking_(d->wpipe))
+              if (! MHD_itc_nonblocking_(d->itc))
                 {
 #ifdef HAVE_MESSAGES
                   MHD_DLOG (daemon,
@@ -5004,14 +5004,14 @@ MHD_start_daemon_va (unsigned int flags,
                 }
             }
           if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) &&
-               (! MHD_SCKT_FD_FITS_FDSET_(MHD_pipe_get_read_fd_ (daemon->wpipe),
+               (! MHD_SCKT_FD_FITS_FDSET_(MHD_pipe_get_read_fd_ (daemon->itc),
                                           NULL)) )
             {
 #ifdef HAVE_MESSAGES
               MHD_DLOG (daemon,
                         _("File descriptor for worker control pipe exceeds maximum value\n"));
 #endif
-              MHD_pipe_close_ (d->wpipe);
+              MHD_pipe_close_ (d->itc);
               goto thread_failed;
             }
 
@@ -5117,8 +5117,8 @@ thread_failed:
   if (0 != (flags & MHD_USE_SSL))
     gnutls_priority_deinit (daemon->priority_cache);
 #endif
-  if (! MHD_INVALID_PIPE_(daemon->wpipe))
-    MHD_pipe_close_ (daemon->wpipe);
+  if (! MHD_INVALID_PIPE_(daemon->itc))
+    MHD_pipe_close_ (daemon->itc);
   free (daemon);
   return NULL;
 }
@@ -5185,8 +5185,8 @@ close_all_connections (struct MHD_Daemon *daemon)
       shutdown (pos->socket_fd, SHUT_RDWR);
 #if MHD_WINSOCK_SOCKETS
       if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-           (! MHD_INVALID_PIPE_(daemon->wpipe)) &&
-           (1 != MHD_pipe_write_ (daemon->wpipe, "e", 1)) )
+           (! MHD_INVALID_PIPE_(daemon->itc)) &&
+           (1 != MHD_pipe_write_ (daemon->itc, "e", 1)) )
         MHD_PANIC (_("Failed to signal shutdown via pipe"));
 #endif
     }
@@ -5226,7 +5226,7 @@ close_all_connections (struct MHD_Daemon *daemon)
 
 #ifdef EPOLL_SUPPORT
 /**
- * Shutdown epoll()-event loop by adding write end of 'wpipe' to its event set.
+ * Shutdown epoll()-event loop by adding write end of 'itc' to its event set.
  *
  * @param daemon daemon of which the epoll() instance must be signalled
  */
@@ -5235,16 +5235,16 @@ epoll_shutdown (struct MHD_Daemon *daemon)
 {
   struct epoll_event event;
 
-  if (MHD_INVALID_PIPE_(daemon->wpipe))
+  if (MHD_INVALID_PIPE_(daemon->itc))
     {
-      /* wpipe was required in this mode, how could this happen? */
+      /* itc was required in this mode, how could this happen? */
       MHD_PANIC (_("Internal error\n"));
     }
   event.events = EPOLLOUT;
   event.data.ptr = NULL;
   if (0 != epoll_ctl (daemon->epoll_fd,
 		      EPOLL_CTL_ADD,
-		      MHD_pipe_get_write_fd_ (daemon->wpipe),
+		      MHD_pipe_get_write_fd_ (daemon->itc),
 		      &event))
     MHD_PANIC (_("Failed to add wpipe to epoll set to signal termination\n"));
 }
@@ -5287,9 +5287,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
 #endif
 	}
     }
-  if (! MHD_INVALID_PIPE_(daemon->wpipe))
+  if (! MHD_INVALID_PIPE_(daemon->itc))
     {
-      if (1 != MHD_pipe_write_ (daemon->wpipe, "e", 1))
+      if (1 != MHD_pipe_write_ (daemon->itc, "e", 1))
 	MHD_PANIC (_("Failed to signal shutdown via pipe"));
     }
 #ifdef HAVE_LISTEN_SHUTDOWN
@@ -5323,9 +5323,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
       /* MHD_USE_NO_LISTEN_SOCKET disables thread pools, hence we need to check */
       for (i = 0; i < daemon->worker_pool_size; ++i)
 	{
-	  if (! MHD_INVALID_PIPE_(daemon->worker_pool[i].wpipe))
+	  if (! MHD_INVALID_PIPE_(daemon->worker_pool[i].itc))
 	    {
-	      if (1 != MHD_pipe_write_ (daemon->worker_pool[i].wpipe,
+	      if (1 != MHD_pipe_write_ (daemon->worker_pool[i].itc,
                                         "e",
                                         1))
 		MHD_PANIC (_("Failed to signal shutdown via pipe."));
@@ -5345,9 +5345,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
           /* Individual pipes are always used */
           if (1)
             {
-              if (! MHD_INVALID_PIPE_ (daemon->worker_pool[i].wpipe) )
+              if (! MHD_INVALID_PIPE_ (daemon->worker_pool[i].itc) )
                 {
-                  MHD_pipe_close_ (daemon->worker_pool[i].wpipe);
+                  MHD_pipe_close_ (daemon->worker_pool[i].itc);
                 }
 	    }
 	}
@@ -5402,8 +5402,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
   MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex);
   MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex);
 
-  if (! MHD_INVALID_PIPE_(daemon->wpipe))
-    MHD_pipe_close_ (daemon->wpipe);
+  if (! MHD_INVALID_PIPE_(daemon->itc))
+    MHD_pipe_close_ (daemon->itc);
   free (daemon);
 }
 

+ 1 - 1
src/microhttpd/internal.h

@@ -1354,7 +1354,7 @@ struct MHD_Daemon
   /**
    * Inter-thread communication channel.
    */
-  MHD_itc_ wpipe;
+  MHD_itc_ itc;
 
   /**
    * Are we shutting down?