diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index bbd7b42d..14786042 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | Copyright (C) 2007-2014 Daniel Pittman and Christian Grothoff | 3 | Copyright (C) 2007-2016 Daniel Pittman and Christian Grothoff |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
@@ -2081,30 +2081,32 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
2081 | MHD_CONNECTION_NOTIFY_CLOSED); | 2081 | MHD_CONNECTION_NOTIFY_CLOSED); |
2082 | MHD_ip_limit_del (daemon, pos->addr, pos->addr_len); | 2082 | MHD_ip_limit_del (daemon, pos->addr, pos->addr_len); |
2083 | #if EPOLL_SUPPORT | 2083 | #if EPOLL_SUPPORT |
2084 | if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) | 2084 | if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) |
2085 | { | 2085 | { |
2086 | EDLL_remove (daemon->eready_head, | 2086 | if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) |
2087 | daemon->eready_tail, | 2087 | { |
2088 | pos); | 2088 | EDLL_remove (daemon->eready_head, |
2089 | pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL; | 2089 | daemon->eready_tail, |
2090 | } | 2090 | pos); |
2091 | if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && | 2091 | pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL; |
2092 | (MHD_INVALID_SOCKET != daemon->epoll_fd) && | 2092 | } |
2093 | (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) ) | 2093 | if ( (MHD_INVALID_SOCKET != daemon->epoll_fd) && |
2094 | { | 2094 | (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) ) |
2095 | /* epoll documentation suggests that closing a FD | 2095 | { |
2096 | automatically removes it from the epoll set; however, | 2096 | /* epoll documentation suggests that closing a FD |
2097 | this is not true as if we fail to do manually remove it, | 2097 | automatically removes it from the epoll set; however, |
2098 | we are still seeing an event for this fd in epoll, | 2098 | this is not true as if we fail to do manually remove it, |
2099 | causing grief (use-after-free...) --- at least on my | 2099 | we are still seeing an event for this fd in epoll, |
2100 | system. */ | 2100 | causing grief (use-after-free...) --- at least on my |
2101 | if (0 != epoll_ctl (daemon->epoll_fd, | 2101 | system. */ |
2102 | EPOLL_CTL_DEL, | 2102 | if (0 != epoll_ctl (daemon->epoll_fd, |
2103 | pos->socket_fd, | 2103 | EPOLL_CTL_DEL, |
2104 | NULL)) | 2104 | pos->socket_fd, |
2105 | MHD_PANIC ("Failed to remove FD from epoll set\n"); | 2105 | NULL)) |
2106 | pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; | 2106 | MHD_PANIC ("Failed to remove FD from epoll set\n"); |
2107 | } | 2107 | pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; |
2108 | } | ||
2109 | } | ||
2108 | #endif | 2110 | #endif |
2109 | if (NULL != pos->response) | 2111 | if (NULL != pos->response) |
2110 | { | 2112 | { |
@@ -3766,7 +3768,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
3766 | if (0 == (flags & (MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION))) | 3768 | if (0 == (flags & (MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION))) |
3767 | use_pipe = 0; /* useless if we are using 'external' select */ | 3769 | use_pipe = 0; /* useless if we are using 'external' select */ |
3768 | if (use_pipe) | 3770 | if (use_pipe) |
3769 | { | 3771 | { |
3770 | if (0 != MHD_pipe_ (daemon->wpipe)) | 3772 | if (0 != MHD_pipe_ (daemon->wpipe)) |
3771 | { | 3773 | { |
3772 | #ifdef HAVE_MESSAGES | 3774 | #ifdef HAVE_MESSAGES |