aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-03-02 22:56:41 +0100
committerChristian Grothoff <christian@grothoff.org>2018-03-02 22:56:41 +0100
commitf60a569e51224a9b6bb4de0c95fe8503d6951168 (patch)
tree6a22010965593cbcc81427aac8d5201e6d2c6956 /src/microhttpd/daemon.c
parentf754fafcd60ec71f63d4adc3bcad530cf754fe25 (diff)
downloadlibmicrohttpd-f60a569e51224a9b6bb4de0c95fe8503d6951168.tar.gz
libmicrohttpd-f60a569e51224a9b6bb4de0c95fe8503d6951168.zip
fix 'race' between MHD_epoll and MHD_daemon_quiesce on epoll listen FD removal, resolve simply by allowing syscall to fail with ENOENT
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 6179f2bc..0b85764b 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4079,10 +4079,12 @@ MHD_epoll (struct MHD_Daemon *daemon,
4079 if ( (daemon->was_quiesced) && 4079 if ( (daemon->was_quiesced) &&
4080 (daemon->listen_socket_in_epoll) ) 4080 (daemon->listen_socket_in_epoll) )
4081 { 4081 {
4082 if (0 != epoll_ctl (daemon->epoll_fd, 4082 if ( (0 != epoll_ctl (daemon->epoll_fd,
4083 EPOLL_CTL_DEL, 4083 EPOLL_CTL_DEL,
4084 ls, 4084 ls,
4085 NULL)) 4085 NULL)) &&
4086 (ENOENT != errno) ) /* ENOENT can happen due to race with
4087 #MHD_quiesce_daemon() */
4086 MHD_PANIC ("Failed to remove listen FD from epoll set\n"); 4088 MHD_PANIC ("Failed to remove listen FD from epoll set\n");
4087 daemon->listen_socket_in_epoll = false; 4089 daemon->listen_socket_in_epoll = false;
4088 } 4090 }
@@ -4586,10 +4588,12 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
4586 (-1 != daemon->epoll_fd) && 4588 (-1 != daemon->epoll_fd) &&
4587 (daemon->listen_socket_in_epoll) ) 4589 (daemon->listen_socket_in_epoll) )
4588 { 4590 {
4589 if (0 != epoll_ctl (daemon->epoll_fd, 4591 if ( (0 != epoll_ctl (daemon->epoll_fd,
4590 EPOLL_CTL_DEL, 4592 EPOLL_CTL_DEL,
4591 ret, 4593 ret,
4592 NULL)) 4594 NULL)) &&
4595 (ENOENT != errno) ) /* ENOENT can happen due to race with
4596 #MHD_epoll() */
4593 MHD_PANIC ("Failed to remove listen FD from epoll set\n"); 4597 MHD_PANIC ("Failed to remove listen FD from epoll set\n");
4594 daemon->listen_socket_in_epoll = false; 4598 daemon->listen_socket_in_epoll = false;
4595 } 4599 }