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.c91
1 files changed, 73 insertions, 18 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 209a6f86..09d58b8e 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1171,6 +1171,13 @@ call_handlers (struct MHD_Connection *con,
1171 bool on_fasttrack = (con->state == MHD_CONNECTION_INIT); 1171 bool on_fasttrack = (con->state == MHD_CONNECTION_INIT);
1172 ret = MHD_YES; 1172 ret = MHD_YES;
1173 1173
1174 mhd_assert ((0 == (con->daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
1175 (MHD_thread_handle_ID_is_valid_ID_ (con->tid)));
1176 mhd_assert ((0 != (con->daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
1177 (! MHD_thread_handle_ID_is_valid_ID_ (con->tid)));
1178 mhd_assert ((0 == (con->daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
1179 (MHD_thread_handle_ID_is_current_thread_ (con->tid)));
1180
1174#ifdef HTTPS_SUPPORT 1181#ifdef HTTPS_SUPPORT
1175 if (con->tls_read_ready) 1182 if (con->tls_read_ready)
1176 read_ready = true; 1183 read_ready = true;
@@ -1322,7 +1329,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
1322 1329
1323#ifdef MHD_USE_THREADS 1330#ifdef MHD_USE_THREADS
1324 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 1331 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
1325 MHD_thread_ID_is_current_thread_ (connection->tid) ); 1332 MHD_thread_handle_ID_is_current_thread_ (connection->tid) );
1326#endif /* MHD_USE_THREADS */ 1333#endif /* MHD_USE_THREADS */
1327 if (daemon->shutdown) 1334 if (daemon->shutdown)
1328 { 1335 {
@@ -1670,7 +1677,7 @@ thread_main_connection_upgrade (struct MHD_Connection *con)
1670 struct MHD_Daemon *daemon = con->daemon; 1677 struct MHD_Daemon *daemon = con->daemon;
1671 1678
1672 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 1679 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
1673 MHD_thread_ID_is_current_thread_ (con->tid) ); 1680 MHD_thread_handle_ID_is_current_thread_ (con->tid) );
1674 /* Here, we need to bi-directionally forward 1681 /* Here, we need to bi-directionally forward
1675 until the application tells us that it is done 1682 until the application tells us that it is done
1676 with the socket; */ 1683 with the socket; */
@@ -1896,7 +1903,7 @@ thread_main_handle_connection (void *data)
1896 const bool use_poll = 0; 1903 const bool use_poll = 0;
1897#endif /* ! HAVE_POLL */ 1904#endif /* ! HAVE_POLL */
1898 bool was_suspended = false; 1905 bool was_suspended = false;
1899 MHD_thread_init_ (&(con->tid)); 1906 MHD_thread_handle_ID_set_current_thread_ID_ (&(con->tid));
1900 1907
1901 while ( (! daemon->shutdown) && 1908 while ( (! daemon->shutdown) &&
1902 (MHD_CONNECTION_CLOSED != con->state) ) 1909 (MHD_CONNECTION_CLOSED != con->state) )
@@ -2524,6 +2531,9 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
2524 connection->sk_nonblck = non_blck; 2531 connection->sk_nonblck = non_blck;
2525 connection->is_nonip = sk_is_nonip; 2532 connection->is_nonip = sk_is_nonip;
2526 connection->sk_spipe_suppress = sk_spipe_supprs; 2533 connection->sk_spipe_suppress = sk_spipe_supprs;
2534#ifdef MHD_USE_THREADS
2535 MHD_thread_handle_ID_set_invalid_ (&connection->tid);
2536#endif /* MHD_USE_THREADS */
2527 connection->daemon = daemon; 2537 connection->daemon = daemon;
2528 connection->connection_timeout_ms = daemon->connection_timeout_ms; 2538 connection->connection_timeout_ms = daemon->connection_timeout_ms;
2529 connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; 2539 connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
@@ -2743,7 +2753,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
2743 /* Function manipulate connection and timeout DL-lists, 2753 /* Function manipulate connection and timeout DL-lists,
2744 * must be called only within daemon thread. */ 2754 * must be called only within daemon thread. */
2745 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 2755 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
2746 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 2756 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
2747 mhd_assert (NULL == daemon->worker_pool); 2757 mhd_assert (NULL == daemon->worker_pool);
2748#endif /* MHD_USE_THREADS */ 2758#endif /* MHD_USE_THREADS */
2749 2759
@@ -3102,7 +3112,7 @@ internal_suspend_connection_ (struct MHD_Connection *connection)
3102#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3112#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3103 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 3113 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
3104 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ 3114 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
3105 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 3115 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
3106 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); 3116 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
3107#endif 3117#endif
3108 if (connection->resuming) 3118 if (connection->resuming)
@@ -3199,7 +3209,7 @@ MHD_suspend_connection (struct MHD_Connection *connection)
3199#ifdef MHD_USE_THREADS 3209#ifdef MHD_USE_THREADS
3200 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 3210 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
3201 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ 3211 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
3202 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 3212 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
3203#endif /* MHD_USE_THREADS */ 3213#endif /* MHD_USE_THREADS */
3204 3214
3205 if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) 3215 if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
@@ -3323,7 +3333,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
3323#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3333#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3324 mhd_assert (NULL == daemon->worker_pool); 3334 mhd_assert (NULL == daemon->worker_pool);
3325 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 3335 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
3326 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 3336 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
3327#endif 3337#endif
3328 3338
3329 ret = MHD_NO; 3339 ret = MHD_NO;
@@ -3664,7 +3674,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
3664 3674
3665#ifdef MHD_USE_THREADS 3675#ifdef MHD_USE_THREADS
3666 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 3676 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
3667 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 3677 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
3668 mhd_assert (NULL == daemon->worker_pool); 3678 mhd_assert (NULL == daemon->worker_pool);
3669#endif /* MHD_USE_THREADS */ 3679#endif /* MHD_USE_THREADS */
3670 3680
@@ -3888,7 +3898,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
3888 struct MHD_Connection *pos; 3898 struct MHD_Connection *pos;
3889#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3899#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3890 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 3900 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
3891 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 3901 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
3892 mhd_assert (NULL == daemon->worker_pool); 3902 mhd_assert (NULL == daemon->worker_pool);
3893 3903
3894 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); 3904 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -3902,7 +3912,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
3902 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); 3912 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
3903 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && 3913 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
3904 (! pos->thread_joined) && 3914 (! pos->thread_joined) &&
3905 (! MHD_join_thread_tid_ (&pos->tid)) ) 3915 (! MHD_thread_handle_ID_join_thread_ (pos->tid)) )
3906 MHD_PANIC (_ ("Failed to join a thread.\n")); 3916 MHD_PANIC (_ ("Failed to join a thread.\n"));
3907#endif 3917#endif
3908#ifdef UPGRADE_SUPPORT 3918#ifdef UPGRADE_SUPPORT
@@ -4075,7 +4085,7 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon,
4075 4085
4076#ifdef MHD_USE_THREADS 4086#ifdef MHD_USE_THREADS
4077 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 4087 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
4078 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 4088 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
4079#endif /* MHD_USE_THREADS */ 4089#endif /* MHD_USE_THREADS */
4080 4090
4081 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) 4091 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
@@ -4340,6 +4350,13 @@ internal_run_from_select (struct MHD_Daemon *daemon,
4340 (fd_set *) _MHD_DROP_CONST (read_fd_set))) ) 4350 (fd_set *) _MHD_DROP_CONST (read_fd_set))) )
4341 MHD_itc_clear_ (daemon->itc); 4351 MHD_itc_clear_ (daemon->itc);
4342 4352
4353 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
4354 (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid)));
4355 mhd_assert ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
4356 (! MHD_thread_handle_ID_is_valid_ID_ (daemon->tid)));
4357 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
4358 (MHD_thread_handle_ID_is_current_thread_ (daemon->tid)));
4359
4343 /* Process externally added connection if any */ 4360 /* Process externally added connection if any */
4344 if (daemon->have_new) 4361 if (daemon->have_new)
4345 new_connections_list_process_ (daemon); 4362 new_connections_list_process_ (daemon);
@@ -4693,6 +4710,13 @@ MHD_poll_all (struct MHD_Daemon *daemon,
4693 struct MHD_UpgradeResponseHandle *urhn; 4710 struct MHD_UpgradeResponseHandle *urhn;
4694#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 4711#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
4695 4712
4713 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
4714 (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid)));
4715 mhd_assert ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
4716 (! MHD_thread_handle_ID_is_valid_ID_ (daemon->tid)));
4717 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
4718 (MHD_thread_handle_ID_is_current_thread_ (daemon->tid)));
4719
4696 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && 4720 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) &&
4697 (MHD_NO != resume_suspended_connections (daemon)) ) 4721 (MHD_NO != resume_suspended_connections (daemon)) )
4698 millisec = 0; 4722 millisec = 0;
@@ -4907,6 +4931,9 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
4907 int poll_itc_idx; 4931 int poll_itc_idx;
4908 MHD_socket ls; 4932 MHD_socket ls;
4909 4933
4934 mhd_assert (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid));
4935 mhd_assert (MHD_thread_handle_ID_is_current_thread_ (daemon->tid));
4936
4910 memset (&p, 4937 memset (&p,
4911 0, 4938 0,
4912 sizeof (p)); 4939 sizeof (p));
@@ -5070,7 +5097,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon)
5070 5097
5071#ifdef MHD_USE_THREADS 5098#ifdef MHD_USE_THREADS
5072 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 5099 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
5073 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 5100 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
5074#endif /* MHD_USE_THREADS */ 5101#endif /* MHD_USE_THREADS */
5075 5102
5076 num_events = MAX_EVENTS; 5103 num_events = MAX_EVENTS;
@@ -5209,6 +5236,13 @@ MHD_epoll (struct MHD_Daemon *daemon,
5209#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 5236#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
5210 bool need_to_accept; 5237 bool need_to_accept;
5211 5238
5239 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
5240 (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid)));
5241 mhd_assert ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
5242 (! MHD_thread_handle_ID_is_valid_ID_ (daemon->tid)));
5243 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
5244 (MHD_thread_handle_ID_is_current_thread_ (daemon->tid)));
5245
5212 if (-1 == daemon->epoll_fd) 5246 if (-1 == daemon->epoll_fd)
5213 return MHD_NO; /* we're down! */ 5247 return MHD_NO; /* we're down! */
5214 if (daemon->shutdown) 5248 if (daemon->shutdown)
@@ -5569,6 +5603,8 @@ MHD_run_wait (struct MHD_Daemon *daemon,
5569 (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) ) 5603 (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) )
5570 return MHD_NO; 5604 return MHD_NO;
5571 5605
5606 mhd_assert (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid));
5607
5572 if (0 > millisec) 5608 if (0 > millisec)
5573 millisec = -1; 5609 millisec = -1;
5574#ifdef HAVE_POLL 5610#ifdef HAVE_POLL
@@ -5611,7 +5647,7 @@ close_connection (struct MHD_Connection *pos)
5611 5647
5612#ifdef MHD_USE_THREADS 5648#ifdef MHD_USE_THREADS
5613 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 5649 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
5614 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 5650 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
5615 mhd_assert (NULL == daemon->worker_pool); 5651 mhd_assert (NULL == daemon->worker_pool);
5616#endif /* MHD_USE_THREADS */ 5652#endif /* MHD_USE_THREADS */
5617 5653
@@ -5665,7 +5701,7 @@ MHD_polling_thread (void *cls)
5665 int err; 5701 int err;
5666#endif /* HAVE_PTHREAD_SIGMASK */ 5702#endif /* HAVE_PTHREAD_SIGMASK */
5667 5703
5668 MHD_thread_init_ (&(daemon->tid)); 5704 MHD_thread_handle_ID_set_current_thread_ID_ (&(daemon->tid));
5669#ifdef HAVE_PTHREAD_SIGMASK 5705#ifdef HAVE_PTHREAD_SIGMASK
5670 if ((0 == sigemptyset (&s_mask)) && 5706 if ((0 == sigemptyset (&s_mask)) &&
5671 (0 == sigaddset (&s_mask, SIGPIPE))) 5707 (0 == sigaddset (&s_mask, SIGPIPE)))
@@ -7173,6 +7209,9 @@ MHD_start_daemon_va (unsigned int flags,
7173 daemon->unescape_callback = &unescape_wrapper; 7209 daemon->unescape_callback = &unescape_wrapper;
7174 daemon->connection_timeout_ms = 0; /* no timeout */ 7210 daemon->connection_timeout_ms = 0; /* no timeout */
7175 MHD_itc_set_invalid_ (daemon->itc); 7211 MHD_itc_set_invalid_ (daemon->itc);
7212#ifdef MHD_USE_THREADS
7213 MHD_thread_handle_ID_set_invalid_ (&daemon->tid);
7214#endif /* MHD_USE_THREADS */
7176#ifdef SOMAXCONN 7215#ifdef SOMAXCONN
7177 daemon->listen_backlog_size = SOMAXCONN; 7216 daemon->listen_backlog_size = SOMAXCONN;
7178#else /* !SOMAXCONN */ 7217#else /* !SOMAXCONN */
@@ -8175,7 +8214,7 @@ close_all_connections (struct MHD_Daemon *daemon)
8175#ifdef MHD_USE_THREADS 8214#ifdef MHD_USE_THREADS
8176 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 8215 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
8177 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ 8216 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
8178 MHD_thread_ID_is_current_thread_ (daemon->tid) ); 8217 MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
8179 mhd_assert (NULL == daemon->worker_pool); 8218 mhd_assert (NULL == daemon->worker_pool);
8180#endif /* MHD_USE_THREADS */ 8219#endif /* MHD_USE_THREADS */
8181 mhd_assert (daemon->shutdown); 8220 mhd_assert (daemon->shutdown);
@@ -8288,7 +8327,7 @@ close_all_connections (struct MHD_Daemon *daemon)
8288 * MHD_resume_connection() during finishing of "upgraded" 8327 * MHD_resume_connection() during finishing of "upgraded"
8289 * thread. */ 8328 * thread. */
8290 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); 8329 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
8291 if (! MHD_join_thread_tid_ (&pos->tid)) 8330 if (! MHD_thread_handle_ID_join_thread_ (pos->tid))
8292 MHD_PANIC (_ ("Failed to join a thread.\n")); 8331 MHD_PANIC (_ ("Failed to join a thread.\n"));
8293 pos->thread_joined = true; 8332 pos->thread_joined = true;
8294 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); 8333 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -8320,7 +8359,7 @@ close_all_connections (struct MHD_Daemon *daemon)
8320 if (! pos->thread_joined) 8359 if (! pos->thread_joined)
8321 { 8360 {
8322 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); 8361 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
8323 if (! MHD_join_thread_tid_ (&pos->tid)) 8362 if (! MHD_thread_handle_ID_join_thread_ (pos->tid))
8324 MHD_PANIC (_ ("Failed to join a thread.\n")); 8363 MHD_PANIC (_ ("Failed to join a thread.\n"));
8325 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); 8364 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
8326 pos->thread_joined = true; 8365 pos->thread_joined = true;
@@ -8380,6 +8419,14 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
8380 return; 8419 return;
8381 if ( (daemon->shutdown) && (NULL == daemon->master) ) 8420 if ( (daemon->shutdown) && (NULL == daemon->master) )
8382 MHD_PANIC (_ ("MHD_stop_daemon() was called twice.")); 8421 MHD_PANIC (_ ("MHD_stop_daemon() was called twice."));
8422
8423 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
8424 (NULL != daemon->worker_pool) || \
8425 (MHD_thread_handle_ID_is_valid_handle_ (daemon->tid)));
8426 mhd_assert (((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) &&
8427 (NULL == daemon->worker_pool)) || \
8428 (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid)));
8429
8383 /* Slave daemons must be stopped by master daemon. */ 8430 /* Slave daemons must be stopped by master daemon. */
8384 mhd_assert ( (NULL == daemon->master) || (daemon->shutdown) ); 8431 mhd_assert ( (NULL == daemon->master) || (daemon->shutdown) );
8385 8432
@@ -8458,7 +8505,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
8458 mhd_assert (false); /* Should never happen */ 8505 mhd_assert (false); /* Should never happen */
8459 } 8506 }
8460 8507
8461 if (! MHD_join_thread_tid_ (&daemon->tid)) 8508 if (! MHD_thread_handle_ID_join_thread_ (daemon->tid))
8462 { 8509 {
8463 MHD_PANIC (_ ("Failed to join a thread.\n")); 8510 MHD_PANIC (_ ("Failed to join a thread.\n"));
8464 } 8511 }
@@ -8556,6 +8603,14 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon,
8556{ 8603{
8557 if (NULL == daemon) 8604 if (NULL == daemon)
8558 return NULL; 8605 return NULL;
8606
8607 mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \
8608 (NULL != daemon->worker_pool) || \
8609 (MHD_thread_handle_ID_is_valid_handle_ (daemon->tid)));
8610 mhd_assert (((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) &&
8611 (NULL == daemon->worker_pool)) || \
8612 (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid)));
8613
8559 switch (info_type) 8614 switch (info_type)
8560 { 8615 {
8561 case MHD_DAEMON_INFO_KEY_SIZE: 8616 case MHD_DAEMON_INFO_KEY_SIZE: