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.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 1efcb43b..dadf70c3 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -962,7 +962,7 @@ MHD_handle_connection (void *data)
962 /* drain signaling pipe */ 962 /* drain signaling pipe */
963 if ( (MHD_INVALID_PIPE_ != spipe) && 963 if ( (MHD_INVALID_PIPE_ != spipe) &&
964 (FD_ISSET (spipe, &rs)) ) 964 (FD_ISSET (spipe, &rs)) )
965 (void) MHD_pipe_read_ (spipe, &tmp, sizeof (tmp)); 965 MHD_pipe_drain_ (spipe);
966#endif 966#endif
967 /* call appropriate connection handler if necessary */ 967 /* call appropriate connection handler if necessary */
968 if ( (FD_ISSET (con->socket_fd, &rs)) 968 if ( (FD_ISSET (con->socket_fd, &rs))
@@ -1034,7 +1034,7 @@ MHD_handle_connection (void *data)
1034 /* drain signaling pipe */ 1034 /* drain signaling pipe */
1035 if ( (MHD_INVALID_PIPE_ != spipe) && 1035 if ( (MHD_INVALID_PIPE_ != spipe) &&
1036 (0 != (p[1].revents & (POLLERR | POLLHUP))) ) 1036 (0 != (p[1].revents & (POLLERR | POLLHUP))) )
1037 (void) MHD_pipe_read_ (spipe, &tmp, sizeof (tmp)); 1037 MHD_pipe_drain_ (spipe);
1038#endif 1038#endif
1039 if ( (0 != (p[0].revents & POLLIN)) 1039 if ( (0 != (p[0].revents & POLLIN))
1040#if HTTPS_SUPPORT 1040#if HTTPS_SUPPORT
@@ -2247,7 +2247,6 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
2247 const fd_set *except_fd_set) 2247 const fd_set *except_fd_set)
2248{ 2248{
2249 MHD_socket ds; 2249 MHD_socket ds;
2250 char tmp;
2251 struct MHD_Connection *pos; 2250 struct MHD_Connection *pos;
2252 struct MHD_Connection *next; 2251 struct MHD_Connection *next;
2253 unsigned int mask = MHD_USE_SUSPEND_RESUME | MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY | 2252 unsigned int mask = MHD_USE_SUSPEND_RESUME | MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY |
@@ -2277,7 +2276,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
2277 /* drain signaling pipe to avoid spinning select */ 2276 /* drain signaling pipe to avoid spinning select */
2278 if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) && 2277 if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
2279 (FD_ISSET (daemon->wpipe[0], read_fd_set)) ) 2278 (FD_ISSET (daemon->wpipe[0], read_fd_set)) )
2280 (void) MHD_pipe_read_ (daemon->wpipe[0], &tmp, sizeof (tmp)); 2279 MHD_pipe_drain_ (daemon->wpipe[0]);
2281 2280
2282 if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) 2281 if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
2283 { 2282 {
@@ -2496,7 +2495,6 @@ MHD_poll_all (struct MHD_Daemon *daemon,
2496 unsigned int poll_server; 2495 unsigned int poll_server;
2497 int poll_listen; 2496 int poll_listen;
2498 int poll_pipe; 2497 int poll_pipe;
2499 char tmp;
2500 struct pollfd *p; 2498 struct pollfd *p;
2501 2499
2502 p = malloc(sizeof (struct pollfd) * (2 + num_connections)); 2500 p = malloc(sizeof (struct pollfd) * (2 + num_connections));
@@ -2640,7 +2638,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
2640 /* handle pipe FD */ 2638 /* handle pipe FD */
2641 if ( (-1 != poll_pipe) && 2639 if ( (-1 != poll_pipe) &&
2642 (0 != (p[poll_pipe].revents & POLLIN)) ) 2640 (0 != (p[poll_pipe].revents & POLLIN)) )
2643 (void) MHD_pipe_read_ (daemon->wpipe[0], &tmp, sizeof (tmp)); 2641 MHD_pipe_drain_ (daemon->wpipe[0]);
2644 2642
2645 free(p); 2643 free(p);
2646 } 2644 }
@@ -2768,7 +2766,6 @@ MHD_epoll (struct MHD_Daemon *daemon,
2768 int num_events; 2766 int num_events;
2769 unsigned int i; 2767 unsigned int i;
2770 unsigned int series_length; 2768 unsigned int series_length;
2771 char tmp;
2772 2769
2773 if (-1 == daemon->epoll_fd) 2770 if (-1 == daemon->epoll_fd)
2774 return MHD_NO; /* we're down! */ 2771 return MHD_NO; /* we're down! */
@@ -2850,7 +2847,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
2850 if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) && 2847 if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
2851 (daemon->wpipe[0] == events[i].data.fd) ) 2848 (daemon->wpipe[0] == events[i].data.fd) )
2852 { 2849 {
2853 (void) MHD_pipe_read_ (daemon->wpipe[0], &tmp, sizeof (tmp)); 2850 MHD_pipe_drain_ (daemon->wpipe[0]);
2854 continue; 2851 continue;
2855 } 2852 }
2856 if (daemon != events[i].data.ptr) 2853 if (daemon != events[i].data.ptr)
@@ -3778,6 +3775,8 @@ MHD_start_daemon_va (unsigned int flags,
3778 free (daemon); 3775 free (daemon);
3779 return NULL; 3776 return NULL;
3780 } 3777 }
3778 make_nonblocking (daemon, daemon->wpipe[0]);
3779 make_nonblocking (daemon, daemon->wpipe[1]);
3781#ifndef MHD_WINSOCK_SOCKETS 3780#ifndef MHD_WINSOCK_SOCKETS
3782 if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY))) && 3781 if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY))) &&
3783 (1 == use_pipe) && 3782 (1 == use_pipe) &&