[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37093 - in branches/mhd-0.9.50: . src/microhttpd
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37093 - in branches/mhd-0.9.50: . src/microhttpd |
Date: |
Fri, 29 Apr 2016 23:14:24 +0200 |
Author: Karlson2k
Date: 2016-04-29 23:14:23 +0200 (Fri, 29 Apr 2016)
New Revision: 37093
Modified:
branches/mhd-0.9.50/ChangeLog
branches/mhd-0.9.50/src/microhttpd/daemon.c
Log:
Fixed rare situations when suspended connection can't be resumed.
Modified: branches/mhd-0.9.50/ChangeLog
===================================================================
--- branches/mhd-0.9.50/ChangeLog 2016-04-29 21:14:21 UTC (rev 37092)
+++ branches/mhd-0.9.50/ChangeLog 2016-04-29 21:14:23 UTC (rev 37093)
@@ -1,3 +1,9 @@
+Mon Apr 18 19:35:14 CET 2016
+ Fixed handling of MHD_OPTION_THREAD_POOL_SIZE with
+ MHD_USE_SUSPEND_RESUME (regression in 0.9.49).
+ Fixed data races leading to inability in rare situations to
+ resume suspended connection. -EG
+
Tue Apr 13 21:46:01 CET 2016
Ignored specific errors in 'test_post' test until libcurl
will implement workaround for WinSock bug.
Modified: branches/mhd-0.9.50/src/microhttpd/daemon.c
===================================================================
--- branches/mhd-0.9.50/src/microhttpd/daemon.c 2016-04-29 21:14:21 UTC (rev
37092)
+++ branches/mhd-0.9.50/src/microhttpd/daemon.c 2016-04-29 21:14:23 UTC (rev
37093)
@@ -958,7 +958,7 @@
break;
}
#if WINDOWS
- /* drain signaling pipe */
+ /* drain signaling pipe before other processing */
if ( (MHD_INVALID_PIPE_ != spipe) &&
(FD_ISSET (spipe, &rs)) )
MHD_pipe_drain_ (spipe);
@@ -1030,7 +1030,7 @@
break;
}
#if WINDOWS
- /* drain signaling pipe */
+ /* drain signaling pipe before other processing */
if ( (MHD_INVALID_PIPE_ != spipe) &&
(0 != (p[1].revents & (POLLERR | POLLHUP))) )
MHD_pipe_drain_ (spipe);
@@ -1811,9 +1811,11 @@
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
(MHD_YES != MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) )
MHD_PANIC ("Failed to acquire cleanup mutex\n");
- if (MHD_YES == daemon->resuming)
+ if (MHD_NO != daemon->resuming)
next = daemon->suspended_connections_head;
-
+
+ if (NULL != next)
+ daemon->resuming = MHD_NO;
while (NULL != (pos = next))
{
next = pos->next;
@@ -1851,7 +1853,6 @@
pos->suspended = MHD_NO;
pos->resuming = MHD_NO;
}
- daemon->resuming = MHD_NO;
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
(MHD_YES != MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
MHD_PANIC ("Failed to release cleanup mutex\n");
@@ -2249,6 +2250,13 @@
unsigned int mask = MHD_USE_SUSPEND_RESUME |
MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY |
MHD_USE_SELECT_INTERNALLY | MHD_USE_POLL_INTERNALLY |
MHD_USE_THREAD_PER_CONNECTION;
+ /* 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[0]) &&
+ (FD_ISSET (daemon->wpipe[0], read_fd_set)))
+ MHD_pipe_drain_ (daemon->wpipe[0]);
+
/* Resuming external connections when using an extern mainloop */
if (MHD_USE_SUSPEND_RESUME == (daemon->options & mask))
resume_suspended_connections (daemon);
@@ -2270,10 +2278,6 @@
if ( (MHD_INVALID_SOCKET != (ds = daemon->socket_fd)) &&
(FD_ISSET (ds, read_fd_set)) )
(void) MHD_accept_connection (daemon);
- /* drain signaling pipe to avoid spinning select */
- if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
- (FD_ISSET (daemon->wpipe[0], read_fd_set)) )
- MHD_pipe_drain_ (daemon->wpipe[0]);
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
@@ -2578,6 +2582,13 @@
free(p);
return MHD_NO;
}
+ /* handle pipe FD */
+ /* do it before any other processing so
+ new signals will be processed in next loop */
+ if ( (-1 != poll_pipe) &&
+ (0 != (p[poll_pipe].revents & POLLIN)) )
+ MHD_pipe_drain_ (daemon->wpipe[0]);
+
/* handle shutdown */
if (MHD_YES == daemon->shutdown)
{
@@ -2632,11 +2643,6 @@
(0 != (p[poll_listen].revents & POLLIN)) )
(void) MHD_accept_connection (daemon);
- /* handle pipe FD */
- if ( (-1 != poll_pipe) &&
- (0 != (p[poll_pipe].revents & POLLIN)) )
- MHD_pipe_drain_ (daemon->wpipe[0]);
-
free(p);
}
return MHD_YES;
@@ -2844,6 +2850,8 @@
if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
(daemon->wpipe[0] == events[i].data.fd) )
{
+ /* It's OK to drain pipe here as all external
+ conditions will be processed later. */
MHD_pipe_drain_ (daemon->wpipe[0]);
continue;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37093 - in branches/mhd-0.9.50: . src/microhttpd,
gnunet <=