diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/microhttpd/connection.c | 18 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 60 | ||||
-rw-r--r-- | src/microhttpd/response.c | 2 |
3 files changed, 40 insertions, 40 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 3f11b4eb..304c8e64 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -1249,7 +1249,7 @@ MHD_connection_close_ (struct MHD_Connection *connection, | |||
1249 | 1249 | ||
1250 | mhd_assert (! connection->suspended); | 1250 | mhd_assert (! connection->suspended); |
1251 | #ifdef MHD_USE_THREADS | 1251 | #ifdef MHD_USE_THREADS |
1252 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 1252 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
1253 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); | 1253 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); |
1254 | #endif /* MHD_USE_THREADS */ | 1254 | #endif /* MHD_USE_THREADS */ |
1255 | if ( (NULL != daemon->notify_completed) && | 1255 | if ( (NULL != daemon->notify_completed) && |
@@ -1292,7 +1292,7 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection) | |||
1292 | struct MHD_UpgradeResponseHandle *urh = connection->urh; | 1292 | struct MHD_UpgradeResponseHandle *urh = connection->urh; |
1293 | 1293 | ||
1294 | #ifdef MHD_USE_THREADS | 1294 | #ifdef MHD_USE_THREADS |
1295 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 1295 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
1296 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ | 1296 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ |
1297 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 1297 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
1298 | #endif /* MHD_USE_THREADS */ | 1298 | #endif /* MHD_USE_THREADS */ |
@@ -3465,7 +3465,7 @@ handle_recv_no_space (struct MHD_Connection *c, | |||
3465 | { | 3465 | { |
3466 | /* The connection must not be in MHD_EVENT_LOOP_INFO_READ state | 3466 | /* The connection must not be in MHD_EVENT_LOOP_INFO_READ state |
3467 | when external polling is used and some data left unprocessed. */ | 3467 | when external polling is used and some data left unprocessed. */ |
3468 | mhd_assert (0 != (c->daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)); | 3468 | mhd_assert (MHD_D_IS_USING_THREADS_ (c->daemon)); |
3469 | /* failed to grow the read buffer, and the | 3469 | /* failed to grow the read buffer, and the |
3470 | client which is supposed to handle the | 3470 | client which is supposed to handle the |
3471 | received data in a *blocking* fashion | 3471 | received data in a *blocking* fashion |
@@ -3616,7 +3616,7 @@ check_and_grow_read_buffer_space (struct MHD_Connection *c) | |||
3616 | space in the read buffer must be available. */ | 3616 | space in the read buffer must be available. */ |
3617 | mhd_assert (0 == (MHD_EVENT_LOOP_INFO_PROCESS & c->event_loop_info)); | 3617 | mhd_assert (0 == (MHD_EVENT_LOOP_INFO_PROCESS & c->event_loop_info)); |
3618 | 3618 | ||
3619 | if ((0 == (c->daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 3619 | if ((! MHD_D_IS_USING_THREADS_ (c->daemon)) |
3620 | && (MHD_CONNECTION_BODY_RECEIVING == c->state) | 3620 | && (MHD_CONNECTION_BODY_RECEIVING == c->state) |
3621 | && has_unprocessed_upload_body_data_in_buffer (c)) | 3621 | && has_unprocessed_upload_body_data_in_buffer (c)) |
3622 | { | 3622 | { |
@@ -4629,7 +4629,7 @@ process_request_body (struct MHD_Connection *connection) | |||
4629 | /* client did not process any upload data, complain if | 4629 | /* client did not process any upload data, complain if |
4630 | the setup was incorrect, which may prevent us from | 4630 | the setup was incorrect, which may prevent us from |
4631 | handling the rest of the request */ | 4631 | handling the rest of the request */ |
4632 | if (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 4632 | if (MHD_D_IS_USING_THREADS_ (daemon)) |
4633 | MHD_DLOG (daemon, | 4633 | MHD_DLOG (daemon, |
4634 | _ ("WARNING: Access Handler Callback has not processed " \ | 4634 | _ ("WARNING: Access Handler Callback has not processed " \ |
4635 | "any upload data and connection is not suspended. " \ | 4635 | "any upload data and connection is not suspended. " \ |
@@ -6948,7 +6948,7 @@ cleanup_connection (struct MHD_Connection *connection) | |||
6948 | { | 6948 | { |
6949 | struct MHD_Daemon *daemon = connection->daemon; | 6949 | struct MHD_Daemon *daemon = connection->daemon; |
6950 | #ifdef MHD_USE_THREADS | 6950 | #ifdef MHD_USE_THREADS |
6951 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 6951 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
6952 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); | 6952 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); |
6953 | mhd_assert (NULL == daemon->worker_pool); | 6953 | mhd_assert (NULL == daemon->worker_pool); |
6954 | #endif /* MHD_USE_THREADS */ | 6954 | #endif /* MHD_USE_THREADS */ |
@@ -7155,7 +7155,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
7155 | struct MHD_Daemon *daemon = connection->daemon; | 7155 | struct MHD_Daemon *daemon = connection->daemon; |
7156 | enum MHD_Result ret; | 7156 | enum MHD_Result ret; |
7157 | #ifdef MHD_USE_THREADS | 7157 | #ifdef MHD_USE_THREADS |
7158 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 7158 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
7159 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); | 7159 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); |
7160 | #endif /* MHD_USE_THREADS */ | 7160 | #endif /* MHD_USE_THREADS */ |
7161 | /* 'daemon' is not used if epoll is not available and asserts are disabled */ | 7161 | /* 'daemon' is not used if epoll is not available and asserts are disabled */ |
@@ -7832,7 +7832,7 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
7832 | 7832 | ||
7833 | daemon = connection->daemon; | 7833 | daemon = connection->daemon; |
7834 | if ((! connection->in_access_handler) && (! connection->suspended) && | 7834 | if ((! connection->in_access_handler) && (! connection->suspended) && |
7835 | (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))) | 7835 | MHD_D_IS_USING_THREADS_ (daemon)) |
7836 | return MHD_NO; | 7836 | return MHD_NO; |
7837 | 7837 | ||
7838 | reply_icy = (0 != (status_code & MHD_ICY_FLAG)); | 7838 | reply_icy = (0 != (status_code & MHD_ICY_FLAG)); |
@@ -7840,7 +7840,7 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
7840 | 7840 | ||
7841 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 7841 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
7842 | if ( (! connection->suspended) && | 7842 | if ( (! connection->suspended) && |
7843 | (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) && | 7843 | MHD_D_IS_USING_THREADS_ (daemon) && |
7844 | (! MHD_thread_handle_ID_is_current_thread_ (connection->tid)) ) | 7844 | (! MHD_thread_handle_ID_is_current_thread_ (connection->tid)) ) |
7845 | { | 7845 | { |
7846 | #ifdef HAVE_MESSAGES | 7846 | #ifdef HAVE_MESSAGES |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 9fc7ac0b..9843866d 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -1145,7 +1145,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon, | |||
1145 | if ( (NULL == daemon) || | 1145 | if ( (NULL == daemon) || |
1146 | (NULL == read_fd_set) || | 1146 | (NULL == read_fd_set) || |
1147 | (NULL == write_fd_set) || | 1147 | (NULL == write_fd_set) || |
1148 | (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || | 1148 | MHD_D_IS_USING_THREADS_ (daemon) || |
1149 | MHD_D_IS_USING_POLL_ (daemon)) | 1149 | MHD_D_IS_USING_POLL_ (daemon)) |
1150 | return MHD_NO; | 1150 | return MHD_NO; |
1151 | 1151 | ||
@@ -1407,7 +1407,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
1407 | bool was_closed; | 1407 | bool was_closed; |
1408 | 1408 | ||
1409 | #ifdef MHD_USE_THREADS | 1409 | #ifdef MHD_USE_THREADS |
1410 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 1410 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
1411 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); | 1411 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); |
1412 | #endif /* MHD_USE_THREADS */ | 1412 | #endif /* MHD_USE_THREADS */ |
1413 | if (daemon->shutdown) | 1413 | if (daemon->shutdown) |
@@ -1753,7 +1753,7 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1753 | struct MHD_UpgradeResponseHandle *urh = con->urh; | 1753 | struct MHD_UpgradeResponseHandle *urh = con->urh; |
1754 | struct MHD_Daemon *daemon = con->daemon; | 1754 | struct MHD_Daemon *daemon = con->daemon; |
1755 | 1755 | ||
1756 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 1756 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
1757 | MHD_thread_handle_ID_is_current_thread_ (con->tid) ); | 1757 | MHD_thread_handle_ID_is_current_thread_ (con->tid) ); |
1758 | /* Here, we need to bi-directionally forward | 1758 | /* Here, we need to bi-directionally forward |
1759 | until the application tells us that it is done | 1759 | until the application tells us that it is done |
@@ -2830,7 +2830,7 @@ new_connection_process_ (struct MHD_Daemon *daemon, | |||
2830 | #ifdef MHD_USE_THREADS | 2830 | #ifdef MHD_USE_THREADS |
2831 | /* Function manipulate connection and timeout DL-lists, | 2831 | /* Function manipulate connection and timeout DL-lists, |
2832 | * must be called only within daemon thread. */ | 2832 | * must be called only within daemon thread. */ |
2833 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 2833 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
2834 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 2834 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
2835 | mhd_assert (NULL == daemon->worker_pool); | 2835 | mhd_assert (NULL == daemon->worker_pool); |
2836 | #endif /* MHD_USE_THREADS */ | 2836 | #endif /* MHD_USE_THREADS */ |
@@ -3101,7 +3101,7 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
3101 | return MHD_NO; | 3101 | return MHD_NO; |
3102 | 3102 | ||
3103 | if ((external_add) && | 3103 | if ((external_add) && |
3104 | (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))) | 3104 | MHD_D_IS_USING_THREADS_ (daemon)) |
3105 | { | 3105 | { |
3106 | /* Connection is added externally and MHD is handling its own threads. */ | 3106 | /* Connection is added externally and MHD is handling its own threads. */ |
3107 | MHD_mutex_lock_chk_ (&daemon->new_connections_mutex); | 3107 | MHD_mutex_lock_chk_ (&daemon->new_connections_mutex); |
@@ -3135,7 +3135,7 @@ new_connections_list_process_ (struct MHD_Daemon *daemon) | |||
3135 | struct MHD_Connection *local_head; | 3135 | struct MHD_Connection *local_head; |
3136 | struct MHD_Connection *local_tail; | 3136 | struct MHD_Connection *local_tail; |
3137 | mhd_assert (daemon->have_new); | 3137 | mhd_assert (daemon->have_new); |
3138 | mhd_assert (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)); | 3138 | mhd_assert (MHD_D_IS_USING_THREADS_ (daemon)); |
3139 | 3139 | ||
3140 | /* Detach DL-list of new connections from the daemon for | 3140 | /* Detach DL-list of new connections from the daemon for |
3141 | * following local processing. */ | 3141 | * following local processing. */ |
@@ -3188,7 +3188,7 @@ internal_suspend_connection_ (struct MHD_Connection *connection) | |||
3188 | mhd_assert (NULL == daemon->worker_pool); | 3188 | mhd_assert (NULL == daemon->worker_pool); |
3189 | 3189 | ||
3190 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 3190 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
3191 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 3191 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
3192 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ | 3192 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ |
3193 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 3193 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
3194 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); | 3194 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); |
@@ -3285,7 +3285,7 @@ MHD_suspend_connection (struct MHD_Connection *connection) | |||
3285 | struct MHD_Daemon *const daemon = connection->daemon; | 3285 | struct MHD_Daemon *const daemon = connection->daemon; |
3286 | 3286 | ||
3287 | #ifdef MHD_USE_THREADS | 3287 | #ifdef MHD_USE_THREADS |
3288 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 3288 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
3289 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ | 3289 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ |
3290 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 3290 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
3291 | #endif /* MHD_USE_THREADS */ | 3291 | #endif /* MHD_USE_THREADS */ |
@@ -3410,7 +3410,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
3410 | & MHD_USE_THREAD_PER_CONNECTION)); | 3410 | & MHD_USE_THREAD_PER_CONNECTION)); |
3411 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 3411 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
3412 | mhd_assert (NULL == daemon->worker_pool); | 3412 | mhd_assert (NULL == daemon->worker_pool); |
3413 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 3413 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
3414 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 3414 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
3415 | #endif | 3415 | #endif |
3416 | 3416 | ||
@@ -3571,12 +3571,12 @@ MHD_add_connection (struct MHD_Daemon *daemon, | |||
3571 | struct sockaddr_storage addrstorage; | 3571 | struct sockaddr_storage addrstorage; |
3572 | 3572 | ||
3573 | /* NOT thread safe with internal thread. TODO: fix thread safety. */ | 3573 | /* NOT thread safe with internal thread. TODO: fix thread safety. */ |
3574 | if ((0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) && | 3574 | if ((! MHD_D_IS_USING_THREADS_ (daemon)) && |
3575 | (daemon->connection_limit <= daemon->connections)) | 3575 | (daemon->connection_limit <= daemon->connections)) |
3576 | MHD_cleanup_connections (daemon); | 3576 | MHD_cleanup_connections (daemon); |
3577 | 3577 | ||
3578 | #ifdef HAVE_MESSAGES | 3578 | #ifdef HAVE_MESSAGES |
3579 | if ((0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) && | 3579 | if (MHD_D_IS_USING_THREADS_ (daemon) && |
3580 | (0 == (daemon->options & MHD_USE_ITC))) | 3580 | (0 == (daemon->options & MHD_USE_ITC))) |
3581 | { | 3581 | { |
3582 | MHD_DLOG (daemon, | 3582 | MHD_DLOG (daemon, |
@@ -3751,7 +3751,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
3751 | #endif /* ! USE_ACCEPT4 && ! _DEBUG */ | 3751 | #endif /* ! USE_ACCEPT4 && ! _DEBUG */ |
3752 | 3752 | ||
3753 | #ifdef MHD_USE_THREADS | 3753 | #ifdef MHD_USE_THREADS |
3754 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 3754 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
3755 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 3755 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
3756 | mhd_assert (NULL == daemon->worker_pool); | 3756 | mhd_assert (NULL == daemon->worker_pool); |
3757 | #endif /* MHD_USE_THREADS */ | 3757 | #endif /* MHD_USE_THREADS */ |
@@ -3975,7 +3975,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
3975 | { | 3975 | { |
3976 | struct MHD_Connection *pos; | 3976 | struct MHD_Connection *pos; |
3977 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 3977 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
3978 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 3978 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
3979 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 3979 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
3980 | mhd_assert (NULL == daemon->worker_pool); | 3980 | mhd_assert (NULL == daemon->worker_pool); |
3981 | 3981 | ||
@@ -4162,7 +4162,7 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon, | |||
4162 | struct MHD_Connection *earliest_tmot_conn; /**< the connection with earliest timeout */ | 4162 | struct MHD_Connection *earliest_tmot_conn; /**< the connection with earliest timeout */ |
4163 | 4163 | ||
4164 | #ifdef MHD_USE_THREADS | 4164 | #ifdef MHD_USE_THREADS |
4165 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 4165 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
4166 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 4166 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
4167 | #endif /* MHD_USE_THREADS */ | 4167 | #endif /* MHD_USE_THREADS */ |
4168 | 4168 | ||
@@ -4579,7 +4579,7 @@ MHD_run_from_select2 (struct MHD_Daemon *daemon, | |||
4579 | unsigned int fd_setsize) | 4579 | unsigned int fd_setsize) |
4580 | { | 4580 | { |
4581 | if (MHD_D_IS_USING_POLL_ (daemon) || | 4581 | if (MHD_D_IS_USING_POLL_ (daemon) || |
4582 | (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))) | 4582 | MHD_D_IS_USING_THREADS_ (daemon)) |
4583 | return MHD_NO; | 4583 | return MHD_NO; |
4584 | if ((NULL == read_fd_set) || (NULL == write_fd_set)) | 4584 | if ((NULL == read_fd_set) || (NULL == write_fd_set)) |
4585 | return MHD_NO; | 4585 | return MHD_NO; |
@@ -5313,7 +5313,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) | |||
5313 | struct MHD_UpgradeResponseHandle *prev; | 5313 | struct MHD_UpgradeResponseHandle *prev; |
5314 | 5314 | ||
5315 | #ifdef MHD_USE_THREADS | 5315 | #ifdef MHD_USE_THREADS |
5316 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 5316 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
5317 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 5317 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
5318 | #endif /* MHD_USE_THREADS */ | 5318 | #endif /* MHD_USE_THREADS */ |
5319 | 5319 | ||
@@ -5765,7 +5765,7 @@ _MHD_EXTERN enum MHD_Result | |||
5765 | MHD_run (struct MHD_Daemon *daemon) | 5765 | MHD_run (struct MHD_Daemon *daemon) |
5766 | { | 5766 | { |
5767 | if ( (daemon->shutdown) || | 5767 | if ( (daemon->shutdown) || |
5768 | (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) ) | 5768 | MHD_D_IS_USING_THREADS_ (daemon) ) |
5769 | return MHD_NO; | 5769 | return MHD_NO; |
5770 | 5770 | ||
5771 | (void) MHD_run_wait (daemon, 0); | 5771 | (void) MHD_run_wait (daemon, 0); |
@@ -5817,7 +5817,7 @@ MHD_run_wait (struct MHD_Daemon *daemon, | |||
5817 | { | 5817 | { |
5818 | enum MHD_Result res; | 5818 | enum MHD_Result res; |
5819 | if ( (daemon->shutdown) || | 5819 | if ( (daemon->shutdown) || |
5820 | (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) ) | 5820 | MHD_D_IS_USING_THREADS_ (daemon) ) |
5821 | return MHD_NO; | 5821 | return MHD_NO; |
5822 | 5822 | ||
5823 | mhd_assert (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid)); | 5823 | mhd_assert (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid)); |
@@ -5881,7 +5881,7 @@ close_connection (struct MHD_Connection *pos) | |||
5881 | struct MHD_Daemon *daemon = pos->daemon; | 5881 | struct MHD_Daemon *daemon = pos->daemon; |
5882 | 5882 | ||
5883 | #ifdef MHD_USE_THREADS | 5883 | #ifdef MHD_USE_THREADS |
5884 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 5884 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
5885 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 5885 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
5886 | mhd_assert (NULL == daemon->worker_pool); | 5886 | mhd_assert (NULL == daemon->worker_pool); |
5887 | #endif /* MHD_USE_THREADS */ | 5887 | #endif /* MHD_USE_THREADS */ |
@@ -6097,7 +6097,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) | |||
6097 | if (MHD_INVALID_SOCKET == ret) | 6097 | if (MHD_INVALID_SOCKET == ret) |
6098 | return MHD_INVALID_SOCKET; | 6098 | return MHD_INVALID_SOCKET; |
6099 | if ( (0 == (daemon->options & (MHD_USE_ITC))) && | 6099 | if ( (0 == (daemon->options & (MHD_USE_ITC))) && |
6100 | (0 != (daemon->options & (MHD_USE_INTERNAL_POLLING_THREAD))) ) | 6100 | MHD_D_IS_USING_THREADS_ (daemon) ) |
6101 | { | 6101 | { |
6102 | #ifdef HAVE_MESSAGES | 6102 | #ifdef HAVE_MESSAGES |
6103 | MHD_DLOG (daemon, | 6103 | MHD_DLOG (daemon, |
@@ -6662,7 +6662,7 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
6662 | #endif /* SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2) */ | 6662 | #endif /* SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2) */ |
6663 | else | 6663 | else |
6664 | { | 6664 | { |
6665 | if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 6665 | if (! MHD_D_IS_USING_THREADS_ (daemon)) |
6666 | { | 6666 | { |
6667 | #ifdef HAVE_MESSAGES | 6667 | #ifdef HAVE_MESSAGES |
6668 | MHD_DLOG (daemon, | 6668 | MHD_DLOG (daemon, |
@@ -7167,7 +7167,7 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
7167 | #endif | 7167 | #endif |
7168 | #endif /* HTTPS_SUPPORT */ | 7168 | #endif /* HTTPS_SUPPORT */ |
7169 | case MHD_OPTION_SIGPIPE_HANDLED_BY_APP: | 7169 | case MHD_OPTION_SIGPIPE_HANDLED_BY_APP: |
7170 | if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 7170 | if (! MHD_D_IS_USING_THREADS_ (daemon)) |
7171 | daemon->sigpipe_blocked = ( (va_arg (ap, | 7171 | daemon->sigpipe_blocked = ( (va_arg (ap, |
7172 | int)) != 0); | 7172 | int)) != 0); |
7173 | else | 7173 | else |
@@ -7284,7 +7284,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) | |||
7284 | 7284 | ||
7285 | mhd_assert (MHD_D_IS_USING_EPOLL_ (daemon)); | 7285 | mhd_assert (MHD_D_IS_USING_EPOLL_ (daemon)); |
7286 | mhd_assert (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); | 7286 | mhd_assert (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); |
7287 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 7287 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
7288 | (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) || \ | 7288 | (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) || \ |
7289 | MHD_ITC_IS_VALID_ (daemon->itc) ); | 7289 | MHD_ITC_IS_VALID_ (daemon->itc) ); |
7290 | daemon->epoll_fd = setup_epoll_fd (daemon); | 7290 | daemon->epoll_fd = setup_epoll_fd (daemon); |
@@ -7792,7 +7792,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
7792 | 7792 | ||
7793 | /* Thread polling currently works only with internal select thread mode */ | 7793 | /* Thread polling currently works only with internal select thread mode */ |
7794 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 7794 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
7795 | if ( (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) && | 7795 | if ( (! MHD_D_IS_USING_THREADS_ (daemon)) && |
7796 | (daemon->worker_pool_size > 0) ) | 7796 | (daemon->worker_pool_size > 0) ) |
7797 | { | 7797 | { |
7798 | #ifdef HAVE_MESSAGES | 7798 | #ifdef HAVE_MESSAGES |
@@ -8231,7 +8231,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
8231 | #endif /* HTTPS_SUPPORT */ | 8231 | #endif /* HTTPS_SUPPORT */ |
8232 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 8232 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
8233 | /* Start threads if requested by parameters */ | 8233 | /* Start threads if requested by parameters */ |
8234 | if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) | 8234 | if (MHD_D_IS_USING_THREADS_ (daemon)) |
8235 | { | 8235 | { |
8236 | /* Internal thread (or threads) is used. | 8236 | /* Internal thread (or threads) is used. |
8237 | * Make sure that MHD will be able to communicate with threads. */ | 8237 | * Make sure that MHD will be able to communicate with threads. */ |
@@ -8581,7 +8581,7 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
8581 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ | 8581 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ |
8582 | 8582 | ||
8583 | #ifdef MHD_USE_THREADS | 8583 | #ifdef MHD_USE_THREADS |
8584 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 8584 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
8585 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ | 8585 | (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \ |
8586 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); | 8586 | MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); |
8587 | mhd_assert (NULL == daemon->worker_pool); | 8587 | mhd_assert (NULL == daemon->worker_pool); |
@@ -8593,7 +8593,7 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
8593 | * not processed by the daemon thread. */ | 8593 | * not processed by the daemon thread. */ |
8594 | while (NULL != (pos = daemon->new_connections_tail)) | 8594 | while (NULL != (pos = daemon->new_connections_tail)) |
8595 | { | 8595 | { |
8596 | mhd_assert (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)); | 8596 | mhd_assert (MHD_D_IS_USING_THREADS_ (daemon)); |
8597 | DLL_remove (daemon->new_connections_head, | 8597 | DLL_remove (daemon->new_connections_head, |
8598 | daemon->new_connections_tail, | 8598 | daemon->new_connections_tail, |
8599 | pos); | 8599 | pos); |
@@ -8809,7 +8809,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
8809 | if (NULL != daemon->worker_pool) | 8809 | if (NULL != daemon->worker_pool) |
8810 | { /* Master daemon with worker pool. */ | 8810 | { /* Master daemon with worker pool. */ |
8811 | mhd_assert (1 < daemon->worker_pool_size); | 8811 | mhd_assert (1 < daemon->worker_pool_size); |
8812 | mhd_assert (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)); | 8812 | mhd_assert (MHD_D_IS_USING_THREADS_ (daemon)); |
8813 | 8813 | ||
8814 | /* Let workers shutdown in parallel. */ | 8814 | /* Let workers shutdown in parallel. */ |
8815 | for (i = 0; i < daemon->worker_pool_size; ++i) | 8815 | for (i = 0; i < daemon->worker_pool_size; ++i) |
@@ -8849,7 +8849,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
8849 | #endif | 8849 | #endif |
8850 | { /* Worker daemon or single daemon. */ | 8850 | { /* Worker daemon or single daemon. */ |
8851 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 8851 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
8852 | if (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 8852 | if (MHD_D_IS_USING_THREADS_ (daemon)) |
8853 | { /* Worker daemon or single daemon with internal thread(s). */ | 8853 | { /* Worker daemon or single daemon with internal thread(s). */ |
8854 | mhd_assert (0 == daemon->worker_pool_size); | 8854 | mhd_assert (0 == daemon->worker_pool_size); |
8855 | /* Separate thread(s) is used for polling sockets. */ | 8855 | /* Separate thread(s) is used for polling sockets. */ |
@@ -8997,7 +8997,7 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon, | |||
8997 | return NULL; | 8997 | return NULL; |
8998 | #endif /* ! EPOLL_SUPPORT */ | 8998 | #endif /* ! EPOLL_SUPPORT */ |
8999 | case MHD_DAEMON_INFO_CURRENT_CONNECTIONS: | 8999 | case MHD_DAEMON_INFO_CURRENT_CONNECTIONS: |
9000 | if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 9000 | if (! MHD_D_IS_USING_THREADS_ (daemon)) |
9001 | { | 9001 | { |
9002 | /* Assume that MHD_run() in not called in other thread | 9002 | /* Assume that MHD_run() in not called in other thread |
9003 | * at the same time. */ | 9003 | * at the same time. */ |
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index 78e874d0..9a762159 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -1940,7 +1940,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, | |||
1940 | size_t rbo; | 1940 | size_t rbo; |
1941 | 1941 | ||
1942 | #ifdef MHD_USE_THREADS | 1942 | #ifdef MHD_USE_THREADS |
1943 | mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ | 1943 | mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ |
1944 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); | 1944 | MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); |
1945 | #endif /* MHD_USE_THREADS */ | 1945 | #endif /* MHD_USE_THREADS */ |
1946 | 1946 | ||