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.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 82438bfa..6f010ec7 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2900,6 +2900,15 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
2900 return MHD_YES; 2900 return MHD_YES;
2901 } 2901 }
2902#endif /* HTTPS_SUPPORT */ 2902#endif /* HTTPS_SUPPORT */
2903#ifdef EPOLL_SUPPORT
2904 if ( (0 != (daemon->options & MHD_USE_EPOLL)) &&
2905 (NULL != daemon->eready_head) )
2906 {
2907 /* Some connection(s) already have some data pending. */
2908 *timeout = 0;
2909 return MHD_YES;
2910 }
2911#endif /* EPOLL_SUPPORT */
2903 2912
2904 have_timeout = MHD_NO; 2913 have_timeout = MHD_NO;
2905 earliest_deadline = 0; /* avoid compiler warnings */ 2914 earliest_deadline = 0; /* avoid compiler warnings */
@@ -3685,6 +3694,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
3685#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 3694#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
3686 struct MHD_Connection *pos; 3695 struct MHD_Connection *pos;
3687 struct MHD_Connection *next; 3696 struct MHD_Connection *next;
3697 struct MHD_Connection *prev;
3688 struct epoll_event events[MAX_EVENTS]; 3698 struct epoll_event events[MAX_EVENTS];
3689 struct epoll_event event; 3699 struct epoll_event event;
3690 int timeout_ms; 3700 int timeout_ms;
@@ -3887,16 +3897,31 @@ MHD_epoll (struct MHD_Daemon *daemon,
3887 (void) resume_suspended_connections (daemon); 3897 (void) resume_suspended_connections (daemon);
3888 3898
3889 /* process events for connections */ 3899 /* process events for connections */
3890 while (NULL != (pos = daemon->eready_tail)) 3900 prev = daemon->eready_tail;
3901 while (NULL != (pos = prev))
3891 { 3902 {
3892 EDLL_remove (daemon->eready_head, 3903 prev = pos->prevE;
3893 daemon->eready_tail, 3904 /* FIXME: use (0 != pos->epoll_state & MHD_EPOLL_STATE_READ_READY) ? MHD_YES : MHD_NO
3894 pos); 3905 * and (0 != pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY) ? MHD_YES : MHD_NO */
3895 pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL;
3896 call_handlers (pos, 3906 call_handlers (pos,
3897 MHD_EVENT_LOOP_INFO_READ == pos->event_loop_info, 3907 (MHD_EVENT_LOOP_INFO_READ == pos->event_loop_info) ? MHD_YES : MHD_NO,
3898 MHD_EVENT_LOOP_INFO_WRITE == pos->event_loop_info, 3908 (MHD_EVENT_LOOP_INFO_WRITE == pos->event_loop_info) ? MHD_YES : MHD_NO,
3899 MHD_NO); 3909 MHD_NO);
3910 if (MHD_EPOLL_STATE_IN_EREADY_EDLL ==
3911 (pos->epoll_state & (MHD_EPOLL_STATE_SUSPENDED | MHD_EPOLL_STATE_IN_EREADY_EDLL)))
3912 {
3913 if ( (MHD_EVENT_LOOP_INFO_READ == pos->event_loop_info &&
3914 0 == (pos->epoll_state & MHD_EPOLL_STATE_READ_READY) ) ||
3915 (MHD_EVENT_LOOP_INFO_WRITE == pos->event_loop_info &&
3916 0 == (pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY) ) ||
3917 MHD_EVENT_LOOP_INFO_CLEANUP == pos->event_loop_info)
3918 {
3919 EDLL_remove (daemon->eready_head,
3920 daemon->eready_tail,
3921 pos);
3922 pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL;
3923 }
3924 }
3900 } 3925 }
3901 3926
3902 /* Finally, handle timed-out connections; we need to do this here 3927 /* Finally, handle timed-out connections; we need to do this here