aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/include/microhttpd.h2
-rw-r--r--src/include/platform_interface.h8
-rw-r--r--src/microhttpd/daemon.c15
4 files changed, 15 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 024ee195..d0daf4b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
1Wed Feb 3 15:41:57 CET 2016
2 Make signal-pipe non-blocking and drain it. -CG
3
1Sat Jan 30 15:49:07 CET 2016 4Sat Jan 30 15:49:07 CET 2016
2 Fix running select() with empty fdsets on W32. -EG 5 Fix running select() with empty fdsets on W32. -EG
3 6
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 5bcb58ec..c7f23c15 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -130,7 +130,7 @@ typedef intptr_t ssize_t;
130 * Current version of the library. 130 * Current version of the library.
131 * 0x01093001 = 1.9.30-1. 131 * 0x01093001 = 1.9.30-1.
132 */ 132 */
133#define MHD_VERSION 0x00094801 133#define MHD_VERSION 0x00094802
134 134
135/** 135/**
136 * MHD-internal return code for "YES". 136 * MHD-internal return code for "YES".
diff --git a/src/include/platform_interface.h b/src/include/platform_interface.h
index aa8d7317..cf08e8dc 100644
--- a/src/include/platform_interface.h
+++ b/src/include/platform_interface.h
@@ -161,12 +161,12 @@ typedef int _MHD_socket_funcs_size;
161#define MHD_pipe_write_(fd, ptr, sz) send((fd), (const char*)(ptr), (sz), 0) 161#define MHD_pipe_write_(fd, ptr, sz) send((fd), (const char*)(ptr), (sz), 0)
162#endif 162#endif
163 163
164/* MHD_pipe_read_ read data from real pipe (!MHD_DONT_USE_PIPES) / 164/* MHD_pipe_drain_ drain data from real pipe (!MHD_DONT_USE_PIPES) /
165 * read data from emulated pipe (MHD_DONT_USE_PIPES) */ 165 * drain data from emulated pipe (MHD_DONT_USE_PIPES) */
166#ifndef MHD_DONT_USE_PIPES 166#ifndef MHD_DONT_USE_PIPES
167#define MHD_pipe_read_(fd, ptr, sz) read((fd), (void*)(ptr), (sz)) 167#define MHD_pipe_drain_(fd) do { char tmp; while (0 < read((fd), &tmp, sizeof (tmp))) ; } while (0)
168#else 168#else
169#define MHD_pipe_read_(fd, ptr, sz) recv((fd), (char*)(ptr), (sz), 0) 169#define MHD_pipe_drain_(fd) do { char tmp; while (0 < recv((fd), &tmp, sizeof (tmp))) ; } while (0)
170#endif 170#endif
171 171
172/* MHD_pipe_close_(fd) close any FDs (non-W32) / 172/* MHD_pipe_close_(fd) close any FDs (non-W32) /
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) &&