diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/lib/daemon_destroy.c | 15 | ||||
-rw-r--r-- | src/lib/daemon_start.c | 51 | ||||
-rw-r--r-- | src/lib/request_resume.c | 8 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 25 | ||||
-rw-r--r-- | src/microhttpd/test_upgrade.c | 92 |
6 files changed, 129 insertions, 66 deletions
@@ -1,3 +1,7 @@ | |||
1 | Fri Mar 2 21:44:24 CET 2018 | ||
2 | Ensure MHD_RequestCompletedCallback is always called from | ||
3 | the correct thread (even on shutdown and for upgraded connections). -CG | ||
4 | |||
1 | Tue Feb 27 23:27:02 CET 2018 | 5 | Tue Feb 27 23:27:02 CET 2018 |
2 | Ensure MHD_RequestCompletedCallback is also called for | 6 | Ensure MHD_RequestCompletedCallback is also called for |
3 | upgraded connections. -CG | 7 | upgraded connections. -CG |
diff --git a/src/lib/daemon_destroy.c b/src/lib/daemon_destroy.c index a236ba8f..ae8c33d8 100644 --- a/src/lib/daemon_destroy.c +++ b/src/lib/daemon_destroy.c | |||
@@ -37,7 +37,7 @@ stop_workers (struct MHD_Daemon *daemon) | |||
37 | { | 37 | { |
38 | MHD_socket fd; | 38 | MHD_socket fd; |
39 | unsigned int i; | 39 | unsigned int i; |
40 | 40 | ||
41 | mhd_assert (1 < daemon->worker_pool_size); | 41 | mhd_assert (1 < daemon->worker_pool_size); |
42 | mhd_assert (1 < daemon->threading_model); | 42 | mhd_assert (1 < daemon->threading_model); |
43 | if (daemon->was_quiesced) | 43 | if (daemon->was_quiesced) |
@@ -102,7 +102,7 @@ MHD_daemon_destroy (struct MHD_Daemon *daemon) | |||
102 | fd = daemon->listen_socket; | 102 | fd = daemon->listen_socket; |
103 | 103 | ||
104 | /* FIXME: convert from here to microhttpd2-style API! */ | 104 | /* FIXME: convert from here to microhttpd2-style API! */ |
105 | 105 | ||
106 | if (NULL != daemon->worker_pool) | 106 | if (NULL != daemon->worker_pool) |
107 | { /* Master daemon with worker pool. */ | 107 | { /* Master daemon with worker pool. */ |
108 | stop_workers (daemon); | 108 | stop_workers (daemon); |
@@ -114,9 +114,6 @@ MHD_daemon_destroy (struct MHD_Daemon *daemon) | |||
114 | if (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_model) | 114 | if (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_model) |
115 | { | 115 | { |
116 | /* Worker daemon or single daemon with internal thread(s). */ | 116 | /* Worker daemon or single daemon with internal thread(s). */ |
117 | if (! daemon->disallow_suspend_resume) | ||
118 | (void) MHD_resume_suspended_connections_ (daemon); | ||
119 | |||
120 | /* Separate thread(s) is used for polling sockets. */ | 117 | /* Separate thread(s) is used for polling sockets. */ |
121 | if (MHD_ITC_IS_VALID_(daemon->itc)) | 118 | if (MHD_ITC_IS_VALID_(daemon->itc)) |
122 | { | 119 | { |
@@ -137,7 +134,7 @@ MHD_daemon_destroy (struct MHD_Daemon *daemon) | |||
137 | #endif /* HAVE_LISTEN_SHUTDOWN */ | 134 | #endif /* HAVE_LISTEN_SHUTDOWN */ |
138 | mhd_assert (false); /* Should never happen */ | 135 | mhd_assert (false); /* Should never happen */ |
139 | } | 136 | } |
140 | 137 | ||
141 | if (! MHD_join_thread_ (daemon->pid.handle)) | 138 | if (! MHD_join_thread_ (daemon->pid.handle)) |
142 | { | 139 | { |
143 | MHD_PANIC (_("Failed to join a thread\n")); | 140 | MHD_PANIC (_("Failed to join a thread\n")); |
@@ -171,10 +168,10 @@ MHD_daemon_destroy (struct MHD_Daemon *daemon) | |||
171 | return; | 168 | return; |
172 | /* Cleanup that should be done only one time in master/single daemon. | 169 | /* Cleanup that should be done only one time in master/single daemon. |
173 | * Do not perform this cleanup in worker daemons. */ | 170 | * Do not perform this cleanup in worker daemons. */ |
174 | 171 | ||
175 | if (MHD_INVALID_SOCKET != fd) | 172 | if (MHD_INVALID_SOCKET != fd) |
176 | MHD_socket_close_chk_ (fd); | 173 | MHD_socket_close_chk_ (fd); |
177 | 174 | ||
178 | /* TLS clean up */ | 175 | /* TLS clean up */ |
179 | #ifdef HTTPS_SUPPORT | 176 | #ifdef HTTPS_SUPPORT |
180 | if (NULL != daemon->tls_api) | 177 | if (NULL != daemon->tls_api) |
@@ -191,7 +188,7 @@ MHD_daemon_destroy (struct MHD_Daemon *daemon) | |||
191 | #endif | 188 | #endif |
192 | } | 189 | } |
193 | #endif /* HTTPS_SUPPORT */ | 190 | #endif /* HTTPS_SUPPORT */ |
194 | 191 | ||
195 | #ifdef DAUTH_SUPPORT | 192 | #ifdef DAUTH_SUPPORT |
196 | free (daemon->nnc); | 193 | free (daemon->nnc); |
197 | MHD_mutex_destroy_chk_ (&daemon->nnc_lock); | 194 | MHD_mutex_destroy_chk_ (&daemon->nnc_lock); |
diff --git a/src/lib/daemon_start.c b/src/lib/daemon_start.c index a3099d75..4705851d 100644 --- a/src/lib/daemon_start.c +++ b/src/lib/daemon_start.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "daemon_select.h" | 28 | #include "daemon_select.h" |
29 | #include "daemon_poll.h" | 29 | #include "daemon_poll.h" |
30 | #include "daemon_epoll.h" | 30 | #include "daemon_epoll.h" |
31 | #include "request_resume.h" | ||
31 | 32 | ||
32 | 33 | ||
33 | /** | 34 | /** |
@@ -159,7 +160,7 @@ open_listen_socket (struct MHD_Daemon *daemon) | |||
159 | const struct sockaddr *sa; | 160 | const struct sockaddr *sa; |
160 | int pf; | 161 | int pf; |
161 | bool use_v6; | 162 | bool use_v6; |
162 | 163 | ||
163 | if (MHD_INVALID_SOCKET != daemon->listen_socket) | 164 | if (MHD_INVALID_SOCKET != daemon->listen_socket) |
164 | return MHD_SC_OK; /* application opened it for us! */ | 165 | return MHD_SC_OK; /* application opened it for us! */ |
165 | 166 | ||
@@ -223,7 +224,7 @@ open_listen_socket (struct MHD_Daemon *daemon) | |||
223 | return MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD; | 224 | return MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD; |
224 | #endif | 225 | #endif |
225 | } | 226 | } |
226 | 227 | ||
227 | /* try to open listen socket */ | 228 | /* try to open listen socket */ |
228 | try_open_listen_socket: | 229 | try_open_listen_socket: |
229 | daemon->listen_socket = MHD_socket_create_listen_(pf); | 230 | daemon->listen_socket = MHD_socket_create_listen_(pf); |
@@ -235,7 +236,7 @@ open_listen_socket (struct MHD_Daemon *daemon) | |||
235 | pf = PF_INET; | 236 | pf = PF_INET; |
236 | goto try_open_listen_socket; | 237 | goto try_open_listen_socket; |
237 | } | 238 | } |
238 | if (MHD_INVALID_SOCKET == daemon->listen_socket) | 239 | if (MHD_INVALID_SOCKET == daemon->listen_socket) |
239 | { | 240 | { |
240 | #ifdef HAVE_MESSAGES | 241 | #ifdef HAVE_MESSAGES |
241 | MHD_DLOG (daemon, | 242 | MHD_DLOG (daemon, |
@@ -281,7 +282,7 @@ open_listen_socket (struct MHD_Daemon *daemon) | |||
281 | #endif | 282 | #endif |
282 | #endif | 283 | #endif |
283 | } | 284 | } |
284 | 285 | ||
285 | /* Determine address to bind to */ | 286 | /* Determine address to bind to */ |
286 | if (0 != daemon->listen_sa_len) | 287 | if (0 != daemon->listen_sa_len) |
287 | { | 288 | { |
@@ -332,8 +333,8 @@ open_listen_socket (struct MHD_Daemon *daemon) | |||
332 | } | 333 | } |
333 | sa = (const struct sockaddr *) &ss; | 334 | sa = (const struct sockaddr *) &ss; |
334 | } | 335 | } |
335 | 336 | ||
336 | /* actually do the bind() */ | 337 | /* actually do the bind() */ |
337 | if (-1 == bind (daemon->listen_socket, | 338 | if (-1 == bind (daemon->listen_socket, |
338 | sa, | 339 | sa, |
339 | addrlen)) | 340 | addrlen)) |
@@ -406,7 +407,7 @@ open_listen_socket (struct MHD_Daemon *daemon) | |||
406 | } | 407 | } |
407 | 408 | ||
408 | 409 | ||
409 | /** | 410 | /** |
410 | * Obtain the listen port number from the socket (if it | 411 | * Obtain the listen port number from the socket (if it |
411 | * was not explicitly set by us, i.e. if we were given | 412 | * was not explicitly set by us, i.e. if we were given |
412 | * a listen socket or if the port was 0 and the OS picked | 413 | * a listen socket or if the port was 0 and the OS picked |
@@ -419,7 +420,7 @@ get_listen_port_number (struct MHD_Daemon *daemon) | |||
419 | { | 420 | { |
420 | struct sockaddr_storage servaddr; | 421 | struct sockaddr_storage servaddr; |
421 | socklen_t addrlen; | 422 | socklen_t addrlen; |
422 | 423 | ||
423 | if ( (0 != daemon->listen_port) || | 424 | if ( (0 != daemon->listen_port) || |
424 | (MHD_INVALID_SOCKET == daemon->listen_socket) ) | 425 | (MHD_INVALID_SOCKET == daemon->listen_socket) ) |
425 | return; /* nothing to be done */ | 426 | return; /* nothing to be done */ |
@@ -457,7 +458,7 @@ get_listen_port_number (struct MHD_Daemon *daemon) | |||
457 | case AF_INET: | 458 | case AF_INET: |
458 | { | 459 | { |
459 | struct sockaddr_in *s4 = (struct sockaddr_in *) &servaddr; | 460 | struct sockaddr_in *s4 = (struct sockaddr_in *) &servaddr; |
460 | 461 | ||
461 | daemon->listen_port = ntohs (s4->sin_port); | 462 | daemon->listen_port = ntohs (s4->sin_port); |
462 | break; | 463 | break; |
463 | } | 464 | } |
@@ -465,7 +466,7 @@ get_listen_port_number (struct MHD_Daemon *daemon) | |||
465 | case AF_INET6: | 466 | case AF_INET6: |
466 | { | 467 | { |
467 | struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) &servaddr; | 468 | struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) &servaddr; |
468 | 469 | ||
469 | daemon->listen_port = ntohs(s6->sin6_port); | 470 | daemon->listen_port = ntohs(s6->sin6_port); |
470 | break; | 471 | break; |
471 | } | 472 | } |
@@ -630,7 +631,7 @@ MHD_polling_thread (void *cls) | |||
630 | MHD_YES); | 631 | MHD_YES); |
631 | break; | 632 | break; |
632 | case MHD_ELS_EPOLL: | 633 | case MHD_ELS_EPOLL: |
633 | #ifdef EPOLL_SUPPORT | 634 | #ifdef EPOLL_SUPPORT |
634 | MHD_daemon_epoll_ (daemon, | 635 | MHD_daemon_epoll_ (daemon, |
635 | MHD_YES); | 636 | MHD_YES); |
636 | #else | 637 | #else |
@@ -643,6 +644,8 @@ MHD_polling_thread (void *cls) | |||
643 | /* Resume any pending for resume connections, join | 644 | /* Resume any pending for resume connections, join |
644 | * all connection's threads (if any) and finally cleanup | 645 | * all connection's threads (if any) and finally cleanup |
645 | * everything. */ | 646 | * everything. */ |
647 | if (! daemon->disallow_suspend_resume) | ||
648 | MHD_resume_suspended_connections_ (daemon); | ||
646 | MHD_daemon_close_all_connections_ (daemon); | 649 | MHD_daemon_close_all_connections_ (daemon); |
647 | 650 | ||
648 | return (MHD_THRD_RTRN_TYPE_)0; | 651 | return (MHD_THRD_RTRN_TYPE_)0; |
@@ -673,13 +676,13 @@ setup_thread_pool (struct MHD_Daemon *daemon) | |||
673 | sizeof (struct MHD_Daemon)); | 676 | sizeof (struct MHD_Daemon)); |
674 | if (NULL == daemon->worker_pool) | 677 | if (NULL == daemon->worker_pool) |
675 | return MHD_SC_THREAD_POOL_MALLOC_FAILURE; | 678 | return MHD_SC_THREAD_POOL_MALLOC_FAILURE; |
676 | 679 | ||
677 | /* Start the workers in the pool */ | 680 | /* Start the workers in the pool */ |
678 | for (i = 0; i < daemon->threading_model; i++) | 681 | for (i = 0; i < daemon->threading_model; i++) |
679 | { | 682 | { |
680 | /* Create copy of the Daemon object for each worker */ | 683 | /* Create copy of the Daemon object for each worker */ |
681 | struct MHD_Daemon *d = &daemon->worker_pool[i]; | 684 | struct MHD_Daemon *d = &daemon->worker_pool[i]; |
682 | 685 | ||
683 | memcpy (d, | 686 | memcpy (d, |
684 | daemon, | 687 | daemon, |
685 | sizeof (struct MHD_Daemon)); | 688 | sizeof (struct MHD_Daemon)); |
@@ -695,8 +698,8 @@ setup_thread_pool (struct MHD_Daemon *daemon) | |||
695 | d->global_connection_limit = conns_per_thread; | 698 | d->global_connection_limit = conns_per_thread; |
696 | if (((unsigned int) i) < leftover_conns) | 699 | if (((unsigned int) i) < leftover_conns) |
697 | ++d->global_connection_limit; | 700 | ++d->global_connection_limit; |
698 | 701 | ||
699 | if (! daemon->disable_itc) | 702 | if (! daemon->disable_itc) |
700 | { | 703 | { |
701 | if (! MHD_itc_init_ (d->itc)) | 704 | if (! MHD_itc_init_ (d->itc)) |
702 | { | 705 | { |
@@ -727,13 +730,13 @@ setup_thread_pool (struct MHD_Daemon *daemon) | |||
727 | { | 730 | { |
728 | MHD_itc_set_invalid_ (d->itc); | 731 | MHD_itc_set_invalid_ (d->itc); |
729 | } | 732 | } |
730 | 733 | ||
731 | #ifdef EPOLL_SUPPORT | 734 | #ifdef EPOLL_SUPPORT |
732 | if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && | 735 | if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && |
733 | (MHD_SC_OK != (sc = setup_epoll_to_listen (d))) ) | 736 | (MHD_SC_OK != (sc = setup_epoll_to_listen (d))) ) |
734 | goto thread_failed; | 737 | goto thread_failed; |
735 | #endif | 738 | #endif |
736 | 739 | ||
737 | /* Must init cleanup connection mutex for each worker */ | 740 | /* Must init cleanup connection mutex for each worker */ |
738 | if (! MHD_mutex_init_ (&d->cleanup_connection_mutex)) | 741 | if (! MHD_mutex_init_ (&d->cleanup_connection_mutex)) |
739 | { | 742 | { |
@@ -747,7 +750,7 @@ setup_thread_pool (struct MHD_Daemon *daemon) | |||
747 | sc = MHD_SC_THREAD_POOL_CREATE_MUTEX_FAILURE; | 750 | sc = MHD_SC_THREAD_POOL_CREATE_MUTEX_FAILURE; |
748 | goto thread_failed; | 751 | goto thread_failed; |
749 | } | 752 | } |
750 | 753 | ||
751 | /* Spawn the worker thread */ | 754 | /* Spawn the worker thread */ |
752 | if (! MHD_create_named_thread_ (&d->pid, | 755 | if (! MHD_create_named_thread_ (&d->pid, |
753 | "MHD-worker", | 756 | "MHD-worker", |
@@ -867,10 +870,10 @@ MHD_daemon_start (struct MHD_Daemon *daemon) | |||
867 | return MHD_SC_ITC_DESCRIPTOR_TOO_LARGE; | 870 | return MHD_SC_ITC_DESCRIPTOR_TOO_LARGE; |
868 | } | 871 | } |
869 | } | 872 | } |
870 | 873 | ||
871 | if (MHD_SC_OK != (sc = open_listen_socket (daemon))) | 874 | if (MHD_SC_OK != (sc = open_listen_socket (daemon))) |
872 | return sc; | 875 | return sc; |
873 | 876 | ||
874 | /* Check listen socket is in range (if we are limited) */ | 877 | /* Check listen socket is in range (if we are limited) */ |
875 | if ( (MHD_INVALID_SOCKET != daemon->listen_socket) && | 878 | if ( (MHD_INVALID_SOCKET != daemon->listen_socket) && |
876 | (MHD_ELS_SELECT == daemon->event_loop_syscall) && | 879 | (MHD_ELS_SELECT == daemon->event_loop_syscall) && |
@@ -886,7 +889,7 @@ MHD_daemon_start (struct MHD_Daemon *daemon) | |||
886 | #endif | 889 | #endif |
887 | return MHD_SC_LISTEN_SOCKET_TOO_LARGE; | 890 | return MHD_SC_LISTEN_SOCKET_TOO_LARGE; |
888 | } | 891 | } |
889 | 892 | ||
890 | /* set listen socket to non-blocking */ | 893 | /* set listen socket to non-blocking */ |
891 | if ( (MHD_INVALID_SOCKET != daemon->listen_socket) && | 894 | if ( (MHD_INVALID_SOCKET != daemon->listen_socket) && |
892 | (! MHD_socket_nonblocking_ (daemon->listen_socket)) ) | 895 | (! MHD_socket_nonblocking_ (daemon->listen_socket)) ) |
@@ -907,7 +910,7 @@ MHD_daemon_start (struct MHD_Daemon *daemon) | |||
907 | return MHD_SC_LISTEN_SOCKET_NONBLOCKING_FAILURE; | 910 | return MHD_SC_LISTEN_SOCKET_NONBLOCKING_FAILURE; |
908 | } | 911 | } |
909 | } | 912 | } |
910 | 913 | ||
911 | #ifdef EPOLL_SUPPORT | 914 | #ifdef EPOLL_SUPPORT |
912 | /* Setup epoll */ | 915 | /* Setup epoll */ |
913 | if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && | 916 | if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && |
@@ -916,7 +919,7 @@ MHD_daemon_start (struct MHD_Daemon *daemon) | |||
916 | (MHD_SC_OK != (sc = setup_epoll_to_listen (daemon))) ) | 919 | (MHD_SC_OK != (sc = setup_epoll_to_listen (daemon))) ) |
917 | return sc; | 920 | return sc; |
918 | #endif | 921 | #endif |
919 | 922 | ||
920 | /* Setup main listen thread (only if we have no thread pool or | 923 | /* Setup main listen thread (only if we have no thread pool or |
921 | external event loop and do have a listen socket) */ | 924 | external event loop and do have a listen socket) */ |
922 | /* FIXME: why no worker thread if we have no listen socket? */ | 925 | /* FIXME: why no worker thread if we have no listen socket? */ |
@@ -949,7 +952,7 @@ MHD_daemon_start (struct MHD_Daemon *daemon) | |||
949 | 952 | ||
950 | /* make sure we know our listen port (if any) */ | 953 | /* make sure we know our listen port (if any) */ |
951 | get_listen_port_number (daemon); | 954 | get_listen_port_number (daemon); |
952 | 955 | ||
953 | return MHD_SC_OK; | 956 | return MHD_SC_OK; |
954 | } | 957 | } |
955 | 958 | ||
diff --git a/src/lib/request_resume.c b/src/lib/request_resume.c index b4bd651e..8fdffb87 100644 --- a/src/lib/request_resume.c +++ b/src/lib/request_resume.c | |||
@@ -156,9 +156,17 @@ MHD_resume_suspended_connections_ (struct MHD_Daemon *daemon) | |||
156 | #ifdef UPGRADE_SUPPORT | 156 | #ifdef UPGRADE_SUPPORT |
157 | else | 157 | else |
158 | { | 158 | { |
159 | struct MHD_Response *response = pos->request.response; | ||
160 | |||
159 | /* Data forwarding was finished (for TLS connections) AND | 161 | /* Data forwarding was finished (for TLS connections) AND |
160 | * application was closed upgraded connection. | 162 | * application was closed upgraded connection. |
161 | * Insert connection into cleanup list. */ | 163 | * Insert connection into cleanup list. */ |
164 | if ( (NULL != response) && | ||
165 | (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_model) && | ||
166 | (NULL != response->termination_cb) ) | ||
167 | response->termination_cb (response->termination_cb_cls, | ||
168 | MHD_REQUEST_TERMINATED_COMPLETED_OK, | ||
169 | &pos->request.client_context); | ||
162 | DLL_insert (daemon->cleanup_head, | 170 | DLL_insert (daemon->cleanup_head, |
163 | daemon->cleanup_tail, | 171 | daemon->cleanup_tail, |
164 | pos); | 172 | pos); |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 8c196421..6179f2bc 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -2750,7 +2750,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
2750 | DLL_insert (daemon->connections_head, | 2750 | DLL_insert (daemon->connections_head, |
2751 | daemon->connections_tail, | 2751 | daemon->connections_tail, |
2752 | pos); | 2752 | pos); |
2753 | if (!used_thr_p_c) | 2753 | if (! used_thr_p_c) |
2754 | { | 2754 | { |
2755 | /* Reset timeout timer on resume. */ | 2755 | /* Reset timeout timer on resume. */ |
2756 | if (0 != pos->connection_timeout) | 2756 | if (0 != pos->connection_timeout) |
@@ -2787,6 +2787,15 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
2787 | /* Data forwarding was finished (for TLS connections) AND | 2787 | /* Data forwarding was finished (for TLS connections) AND |
2788 | * application was closed upgraded connection. | 2788 | * application was closed upgraded connection. |
2789 | * Insert connection into cleanup list. */ | 2789 | * Insert connection into cleanup list. */ |
2790 | |||
2791 | if ( (NULL != daemon->notify_completed) && | ||
2792 | (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | ||
2793 | (pos->client_aware) ) | ||
2794 | daemon->notify_completed (daemon->notify_completed_cls, | ||
2795 | pos, | ||
2796 | &pos->client_context, | ||
2797 | MHD_REQUEST_TERMINATED_COMPLETED_OK); | ||
2798 | pos->client_aware = false; | ||
2790 | DLL_insert (daemon->cleanup_head, | 2799 | DLL_insert (daemon->cleanup_head, |
2791 | daemon->cleanup_tail, | 2800 | daemon->cleanup_tail, |
2792 | pos); | 2801 | pos); |
@@ -3780,7 +3789,7 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon, | |||
3780 | } | 3789 | } |
3781 | 3790 | ||
3782 | if (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) | 3791 | if (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) |
3783 | (void)resume_suspended_connections (daemon); | 3792 | (void) resume_suspended_connections (daemon); |
3784 | 3793 | ||
3785 | if (MHD_NO == may_block) | 3794 | if (MHD_NO == may_block) |
3786 | timeout = 0; | 3795 | timeout = 0; |
@@ -4385,7 +4394,7 @@ close_connection (struct MHD_Connection *pos) | |||
4385 | 4394 | ||
4386 | mhd_assert (! pos->suspended); | 4395 | mhd_assert (! pos->suspended); |
4387 | mhd_assert (! pos->resuming); | 4396 | mhd_assert (! pos->resuming); |
4388 | if (pos->connection_timeout == pos->daemon->connection_timeout) | 4397 | if (pos->connection_timeout == daemon->connection_timeout) |
4389 | XDLL_remove (daemon->normal_timeout_head, | 4398 | XDLL_remove (daemon->normal_timeout_head, |
4390 | daemon->normal_timeout_tail, | 4399 | daemon->normal_timeout_tail, |
4391 | pos); | 4400 | pos); |
@@ -4433,6 +4442,8 @@ MHD_polling_thread (void *cls) | |||
4433 | /* Resume any pending for resume connections, join | 4442 | /* Resume any pending for resume connections, join |
4434 | * all connection's threads (if any) and finally cleanup | 4443 | * all connection's threads (if any) and finally cleanup |
4435 | * everything. */ | 4444 | * everything. */ |
4445 | if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options)) | ||
4446 | resume_suspended_connections (daemon); | ||
4436 | close_all_connections (daemon); | 4447 | close_all_connections (daemon); |
4437 | 4448 | ||
4438 | return (MHD_THRD_RTRN_TYPE_)0; | 4449 | return (MHD_THRD_RTRN_TYPE_)0; |
@@ -6304,7 +6315,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
6304 | daemon->worker_pool[i].shutdown = true; | 6315 | daemon->worker_pool[i].shutdown = true; |
6305 | if (MHD_ITC_IS_VALID_(daemon->worker_pool[i].itc)) | 6316 | if (MHD_ITC_IS_VALID_(daemon->worker_pool[i].itc)) |
6306 | { | 6317 | { |
6307 | if (! MHD_itc_activate_ (daemon->worker_pool[i].itc, "e")) | 6318 | if (! MHD_itc_activate_ (daemon->worker_pool[i].itc, |
6319 | "e")) | ||
6308 | MHD_PANIC (_("Failed to signal shutdown via inter-thread communication channel.")); | 6320 | MHD_PANIC (_("Failed to signal shutdown via inter-thread communication channel.")); |
6309 | } | 6321 | } |
6310 | else | 6322 | else |
@@ -6335,11 +6347,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
6335 | if (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 6347 | if (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) |
6336 | { /* Worker daemon or single daemon with internal thread(s). */ | 6348 | { /* Worker daemon or single daemon with internal thread(s). */ |
6337 | mhd_assert (0 == daemon->worker_pool_size); | 6349 | mhd_assert (0 == daemon->worker_pool_size); |
6338 | if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options)) | ||
6339 | resume_suspended_connections (daemon); | ||
6340 | |||
6341 | /* Separate thread(s) is used for polling sockets. */ | 6350 | /* Separate thread(s) is used for polling sockets. */ |
6342 | if (MHD_ITC_IS_VALID_(daemon->itc)) | 6351 | if (MHD_ITC_IS_VALID_ (daemon->itc)) |
6343 | { | 6352 | { |
6344 | if (! MHD_itc_activate_ (daemon->itc, | 6353 | if (! MHD_itc_activate_ (daemon->itc, |
6345 | "e")) | 6354 | "e")) |
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c index 1b018ad4..6c26104e 100644 --- a/src/microhttpd/test_upgrade.c +++ b/src/microhttpd/test_upgrade.c | |||
@@ -447,7 +447,8 @@ notify_completed_cb (void *cls, | |||
447 | { | 447 | { |
448 | pthread_t* ppth = *con_cls; | 448 | pthread_t* ppth = *con_cls; |
449 | 449 | ||
450 | (void)cls; (void)connection; /* Unused. Silent compiler warning. */ | 450 | (void) cls; |
451 | (void) connection; /* Unused. Silent compiler warning. */ | ||
451 | if ( (toe != MHD_REQUEST_TERMINATED_COMPLETED_OK) && | 452 | if ( (toe != MHD_REQUEST_TERMINATED_COMPLETED_OK) && |
452 | (toe != MHD_REQUEST_TERMINATED_CLIENT_ABORT) && | 453 | (toe != MHD_REQUEST_TERMINATED_CLIENT_ABORT) && |
453 | (toe != MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN) ) | 454 | (toe != MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN) ) |
@@ -474,13 +475,14 @@ log_cb (void *cls, | |||
474 | const char *uri, | 475 | const char *uri, |
475 | struct MHD_Connection *connection) | 476 | struct MHD_Connection *connection) |
476 | { | 477 | { |
477 | pthread_t* ppth; | 478 | pthread_t *ppth; |
478 | (void)cls; (void)connection; /* Unused. Silent compiler warning. */ | ||
479 | 479 | ||
480 | (void) cls; | ||
481 | (void) connection; /* Unused. Silent compiler warning. */ | ||
480 | if (0 != strcmp (uri, | 482 | if (0 != strcmp (uri, |
481 | "/")) | 483 | "/")) |
482 | abort (); | 484 | abort (); |
483 | ppth = (pthread_t*) malloc (sizeof(pthread_t)); | 485 | ppth = malloc (sizeof (pthread_t)); |
484 | if (NULL == ppth) | 486 | if (NULL == ppth) |
485 | abort(); | 487 | abort(); |
486 | *ppth = pthread_self (); | 488 | *ppth = pthread_self (); |
@@ -514,8 +516,9 @@ notify_connection_cb (void *cls, | |||
514 | enum MHD_ConnectionNotificationCode toe) | 516 | enum MHD_ConnectionNotificationCode toe) |
515 | { | 517 | { |
516 | static int started; | 518 | static int started; |
517 | (void)cls; (void)connection; /* Unused. Silent compiler warning. */ | ||
518 | 519 | ||
520 | (void) cls; | ||
521 | (void) connection; /* Unused. Silent compiler warning. */ | ||
519 | switch (toe) | 522 | switch (toe) |
520 | { | 523 | { |
521 | case MHD_CONNECTION_NOTIFY_STARTED: | 524 | case MHD_CONNECTION_NOTIFY_STARTED: |
@@ -773,7 +776,11 @@ upgrade_cb (void *cls, | |||
773 | MHD_socket sock, | 776 | MHD_socket sock, |
774 | struct MHD_UpgradeResponseHandle *urh) | 777 | struct MHD_UpgradeResponseHandle *urh) |
775 | { | 778 | { |
776 | (void)cls; (void)connection; (void)con_cls; (void)extra_in; /* Unused. Silent compiler warning. */ | 779 | (void) cls; |
780 | (void) connection; | ||
781 | (void) con_cls; | ||
782 | (void) extra_in; /* Unused. Silent compiler warning. */ | ||
783 | |||
777 | usock = wr_create_from_plain_sckt (sock); | 784 | usock = wr_create_from_plain_sckt (sock); |
778 | if (0 != extra_in_size) | 785 | if (0 != extra_in_size) |
779 | abort (); | 786 | abort (); |
@@ -836,8 +843,12 @@ ahc_upgrade (void *cls, | |||
836 | { | 843 | { |
837 | struct MHD_Response *resp; | 844 | struct MHD_Response *resp; |
838 | int ret; | 845 | int ret; |
839 | (void)cls;(void)url;(void)method; /* Unused. Silent compiler warning. */ | 846 | (void) cls; |
840 | (void)version;(void)upload_data;(void)upload_data_size; /* Unused. Silent compiler warning. */ | 847 | (void) url; |
848 | (void) method; /* Unused. Silent compiler warning. */ | ||
849 | (void) version; | ||
850 | (void) upload_data; | ||
851 | (void) upload_data_size; /* Unused. Silent compiler warning. */ | ||
841 | 852 | ||
842 | if (NULL == *con_cls) | 853 | if (NULL == *con_cls) |
843 | abort (); | 854 | abort (); |
@@ -1061,7 +1072,8 @@ test_upgrade (int flags, | |||
1061 | { | 1072 | { |
1062 | #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) | 1073 | #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) |
1063 | MHD_socket tls_fork_sock; | 1074 | MHD_socket tls_fork_sock; |
1064 | if (-1 == (pid = gnutlscli_connect (&tls_fork_sock, dinfo->port))) | 1075 | if (-1 == (pid = gnutlscli_connect (&tls_fork_sock, |
1076 | dinfo->port))) | ||
1065 | { | 1077 | { |
1066 | MHD_stop_daemon (d); | 1078 | MHD_stop_daemon (d); |
1067 | return 4; | 1079 | return 4; |
@@ -1105,7 +1117,8 @@ main (int argc, | |||
1105 | test_tls = has_in_name(argv[0], "_tls"); | 1117 | test_tls = has_in_name(argv[0], "_tls"); |
1106 | 1118 | ||
1107 | verbose = 1; | 1119 | verbose = 1; |
1108 | if (has_param(argc, argv, "-q") || has_param(argc, argv, "--quiet")) | 1120 | if (has_param(argc, argv, "-q") || |
1121 | has_param(argc, argv, "--quiet")) | ||
1109 | verbose = 0; | 1122 | verbose = 0; |
1110 | 1123 | ||
1111 | if (test_tls) | 1124 | if (test_tls) |
@@ -1154,13 +1167,16 @@ main (int argc, | |||
1154 | 1167 | ||
1155 | /* run tests */ | 1168 | /* run tests */ |
1156 | if (verbose) | 1169 | if (verbose) |
1157 | printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", test_tls ? "TLS" : "plain"); | 1170 | printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", |
1171 | test_tls ? "TLS" : "plain"); | ||
1158 | /* try external select */ | 1172 | /* try external select */ |
1159 | res = test_upgrade (0, | 1173 | res = test_upgrade (0, |
1160 | 0); | 1174 | 0); |
1161 | error_count += res; | 1175 | error_count += res; |
1162 | if (res) | 1176 | if (res) |
1163 | fprintf (stderr, "FAILED: Upgrade with external select, return code %d.\n", res); | 1177 | fprintf (stderr, |
1178 | "FAILED: Upgrade with external select, return code %d.\n", | ||
1179 | res); | ||
1164 | else if (verbose) | 1180 | else if (verbose) |
1165 | printf ("PASSED: Upgrade with external select.\n"); | 1181 | printf ("PASSED: Upgrade with external select.\n"); |
1166 | 1182 | ||
@@ -1169,7 +1185,9 @@ main (int argc, | |||
1169 | 0); | 1185 | 0); |
1170 | error_count += res; | 1186 | error_count += res; |
1171 | if (res) | 1187 | if (res) |
1172 | fprintf (stderr, "FAILED: Upgrade with external 'auto', return code %d.\n", res); | 1188 | fprintf (stderr, |
1189 | "FAILED: Upgrade with external 'auto', return code %d.\n", | ||
1190 | res); | ||
1173 | else if (verbose) | 1191 | else if (verbose) |
1174 | printf ("PASSED: Upgrade with external 'auto'.\n"); | 1192 | printf ("PASSED: Upgrade with external 'auto'.\n"); |
1175 | 1193 | ||
@@ -1178,7 +1196,9 @@ main (int argc, | |||
1178 | 0); | 1196 | 0); |
1179 | error_count += res; | 1197 | error_count += res; |
1180 | if (res) | 1198 | if (res) |
1181 | fprintf (stderr, "FAILED: Upgrade with external select with EPOLL, return code %d.\n", res); | 1199 | fprintf (stderr, |
1200 | "FAILED: Upgrade with external select with EPOLL, return code %d.\n", | ||
1201 | res); | ||
1182 | else if (verbose) | 1202 | else if (verbose) |
1183 | printf ("PASSED: Upgrade with external select with EPOLL.\n"); | 1203 | printf ("PASSED: Upgrade with external select with EPOLL.\n"); |
1184 | #endif | 1204 | #endif |
@@ -1188,7 +1208,9 @@ main (int argc, | |||
1188 | 0); | 1208 | 0); |
1189 | error_count += res; | 1209 | error_count += res; |
1190 | if (res) | 1210 | if (res) |
1191 | fprintf (stderr, "FAILED: Upgrade with thread per connection, return code %d.\n", res); | 1211 | fprintf (stderr, |
1212 | "FAILED: Upgrade with thread per connection, return code %d.\n", | ||
1213 | res); | ||
1192 | else if (verbose) | 1214 | else if (verbose) |
1193 | printf ("PASSED: Upgrade with thread per connection.\n"); | 1215 | printf ("PASSED: Upgrade with thread per connection.\n"); |
1194 | 1216 | ||
@@ -1196,7 +1218,9 @@ main (int argc, | |||
1196 | 0); | 1218 | 0); |
1197 | error_count += res; | 1219 | error_count += res; |
1198 | if (res) | 1220 | if (res) |
1199 | fprintf (stderr, "FAILED: Upgrade with thread per connection and 'auto', return code %d.\n", res); | 1221 | fprintf (stderr, |
1222 | "FAILED: Upgrade with thread per connection and 'auto', return code %d.\n", | ||
1223 | res); | ||
1200 | else if (verbose) | 1224 | else if (verbose) |
1201 | printf ("PASSED: Upgrade with thread per connection and 'auto'.\n"); | 1225 | printf ("PASSED: Upgrade with thread per connection and 'auto'.\n"); |
1202 | #ifdef HAVE_POLL | 1226 | #ifdef HAVE_POLL |
@@ -1204,7 +1228,9 @@ main (int argc, | |||
1204 | 0); | 1228 | 0); |
1205 | error_count += res; | 1229 | error_count += res; |
1206 | if (res) | 1230 | if (res) |
1207 | fprintf (stderr, "FAILED: Upgrade with thread per connection and poll, return code %d.\n", res); | 1231 | fprintf (stderr, |
1232 | "FAILED: Upgrade with thread per connection and poll, return code %d.\n", | ||
1233 | res); | ||
1208 | else if (verbose) | 1234 | else if (verbose) |
1209 | printf ("PASSED: Upgrade with thread per connection and poll.\n"); | 1235 | printf ("PASSED: Upgrade with thread per connection and poll.\n"); |
1210 | #endif /* HAVE_POLL */ | 1236 | #endif /* HAVE_POLL */ |
@@ -1214,28 +1240,36 @@ main (int argc, | |||
1214 | 0); | 1240 | 0); |
1215 | error_count += res; | 1241 | error_count += res; |
1216 | if (res) | 1242 | if (res) |
1217 | fprintf (stderr, "FAILED: Upgrade with internal select, return code %d.\n", res); | 1243 | fprintf (stderr, |
1244 | "FAILED: Upgrade with internal select, return code %d.\n", | ||
1245 | res); | ||
1218 | else if (verbose) | 1246 | else if (verbose) |
1219 | printf ("PASSED: Upgrade with internal select.\n"); | 1247 | printf ("PASSED: Upgrade with internal select.\n"); |
1220 | res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, | 1248 | res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, |
1221 | 2); | 1249 | 2); |
1222 | error_count += res; | 1250 | error_count += res; |
1223 | if (res) | 1251 | if (res) |
1224 | fprintf (stderr, "FAILED: Upgrade with internal select with thread pool, return code %d.\n", res); | 1252 | fprintf (stderr, |
1253 | "FAILED: Upgrade with internal select with thread pool, return code %d.\n", | ||
1254 | res); | ||
1225 | else if (verbose) | 1255 | else if (verbose) |
1226 | printf ("PASSED: Upgrade with internal select with thread pool.\n"); | 1256 | printf ("PASSED: Upgrade with internal select with thread pool.\n"); |
1227 | res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, | 1257 | res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, |
1228 | 0); | 1258 | 0); |
1229 | error_count += res; | 1259 | error_count += res; |
1230 | if (res) | 1260 | if (res) |
1231 | fprintf (stderr, "FAILED: Upgrade with internal 'auto' return code %d.\n", res); | 1261 | fprintf (stderr, |
1262 | "FAILED: Upgrade with internal 'auto' return code %d.\n", | ||
1263 | res); | ||
1232 | else if (verbose) | 1264 | else if (verbose) |
1233 | printf ("PASSED: Upgrade with internal 'auto'.\n"); | 1265 | printf ("PASSED: Upgrade with internal 'auto'.\n"); |
1234 | res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, | 1266 | res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, |
1235 | 2); | 1267 | 2); |
1236 | error_count += res; | 1268 | error_count += res; |
1237 | if (res) | 1269 | if (res) |
1238 | fprintf (stderr, "FAILED: Upgrade with internal 'auto' with thread pool, return code %d.\n", res); | 1270 | fprintf (stderr, |
1271 | "FAILED: Upgrade with internal 'auto' with thread pool, return code %d.\n", | ||
1272 | res); | ||
1239 | else if (verbose) | 1273 | else if (verbose) |
1240 | printf ("PASSED: Upgrade with internal 'auto' with thread pool.\n"); | 1274 | printf ("PASSED: Upgrade with internal 'auto' with thread pool.\n"); |
1241 | #ifdef HAVE_POLL | 1275 | #ifdef HAVE_POLL |
@@ -1243,13 +1277,17 @@ main (int argc, | |||
1243 | 0); | 1277 | 0); |
1244 | error_count += res; | 1278 | error_count += res; |
1245 | if (res) | 1279 | if (res) |
1246 | fprintf (stderr, "FAILED: Upgrade with internal poll, return code %d.\n", res); | 1280 | fprintf (stderr, |
1281 | "FAILED: Upgrade with internal poll, return code %d.\n", | ||
1282 | res); | ||
1247 | else if (verbose) | 1283 | else if (verbose) |
1248 | printf ("PASSED: Upgrade with internal poll.\n"); | 1284 | printf ("PASSED: Upgrade with internal poll.\n"); |
1249 | res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, | 1285 | res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, |
1250 | 2); | 1286 | 2); |
1251 | if (res) | 1287 | if (res) |
1252 | fprintf (stderr, "FAILED: Upgrade with internal poll with thread pool, return code %d.\n", res); | 1288 | fprintf (stderr, |
1289 | "FAILED: Upgrade with internal poll with thread pool, return code %d.\n", | ||
1290 | res); | ||
1253 | else if (verbose) | 1291 | else if (verbose) |
1254 | printf ("PASSED: Upgrade with internal poll with thread pool.\n"); | 1292 | printf ("PASSED: Upgrade with internal poll with thread pool.\n"); |
1255 | #endif | 1293 | #endif |
@@ -1257,13 +1295,17 @@ main (int argc, | |||
1257 | res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, | 1295 | res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, |
1258 | 0); | 1296 | 0); |
1259 | if (res) | 1297 | if (res) |
1260 | fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %d.\n", res); | 1298 | fprintf (stderr, |
1299 | "FAILED: Upgrade with internal epoll, return code %d.\n", | ||
1300 | res); | ||
1261 | else if (verbose) | 1301 | else if (verbose) |
1262 | printf ("PASSED: Upgrade with internal epoll.\n"); | 1302 | printf ("PASSED: Upgrade with internal epoll.\n"); |
1263 | res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, | 1303 | res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, |
1264 | 2); | 1304 | 2); |
1265 | if (res) | 1305 | if (res) |
1266 | fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %d.\n", res); | 1306 | fprintf (stderr, |
1307 | "FAILED: Upgrade with internal epoll, return code %d.\n", | ||
1308 | res); | ||
1267 | else if (verbose) | 1309 | else if (verbose) |
1268 | printf ("PASSED: Upgrade with internal epoll.\n"); | 1310 | printf ("PASSED: Upgrade with internal epoll.\n"); |
1269 | #endif | 1311 | #endif |