diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 710ba55b..b18885f0 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -6018,7 +6018,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
6018 | #ifdef HAVE_LISTEN_SHUTDOWN | 6018 | #ifdef HAVE_LISTEN_SHUTDOWN |
6019 | if (0 != (*pflags & MHD_USE_NO_LISTEN_SOCKET)) | 6019 | if (0 != (*pflags & MHD_USE_NO_LISTEN_SOCKET)) |
6020 | #endif | 6020 | #endif |
6021 | *pflags |= MHD_USE_ITC; /* yes, must use ITC to signal thread */ | 6021 | *pflags |= MHD_USE_ITC; /* yes, must use ITC to signal thread */ |
6022 | } | 6022 | } |
6023 | #ifdef DAUTH_SUPPORT | 6023 | #ifdef DAUTH_SUPPORT |
6024 | daemon->digest_auth_rand_size = 0; | 6024 | daemon->digest_auth_rand_size = 0; |
@@ -6594,10 +6594,21 @@ MHD_start_daemon_va (unsigned int flags, | |||
6594 | } | 6594 | } |
6595 | #endif /* HTTPS_SUPPORT */ | 6595 | #endif /* HTTPS_SUPPORT */ |
6596 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 6596 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
6597 | if ( (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) && | 6597 | /* Start threads if requested by parameters */ |
6598 | ( (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) || | 6598 | if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) |
6599 | (MHD_ITC_IS_VALID_ (daemon->itc)) ) ) | ||
6600 | { | 6599 | { |
6600 | /* Internal thread (or threads) is used. | ||
6601 | * Make sure that MHD will be able to communicate with threads. */ | ||
6602 | /* If using a thread pool ITC will be initialised later | ||
6603 | * for each individual worker thread. */ | ||
6604 | #ifdef HAVE_LISTEN_SHUTDOWN | ||
6605 | mhd_assert ((1 < daemon->worker_pool_size) || \ | ||
6606 | (MHD_ITC_IS_VALID_ (daemon->itc)) || \ | ||
6607 | (MHD_INVALID_SOCKET != daemon->listen_fd)); | ||
6608 | #else /* ! HAVE_LISTEN_SHUTDOWN */ | ||
6609 | mhd_assert ((1 < daemon->worker_pool_size) || \ | ||
6610 | (MHD_ITC_IS_VALID_ (daemon->itc))); | ||
6611 | #endif /* ! HAVE_LISTEN_SHUTDOWN */ | ||
6601 | if (0 == daemon->worker_pool_size) | 6612 | if (0 == daemon->worker_pool_size) |
6602 | { | 6613 | { |
6603 | if (! MHD_create_named_thread_ (&daemon->pid, | 6614 | if (! MHD_create_named_thread_ (&daemon->pid, |
@@ -6630,6 +6641,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
6630 | unsigned int leftover_conns = daemon->connection_limit | 6641 | unsigned int leftover_conns = daemon->connection_limit |
6631 | % daemon->worker_pool_size; | 6642 | % daemon->worker_pool_size; |
6632 | 6643 | ||
6644 | mhd_assert (2 <= daemon->worker_pool_size); | ||
6633 | i = 0; /* we need this in case fcntl or malloc fails */ | 6645 | i = 0; /* we need this in case fcntl or malloc fails */ |
6634 | 6646 | ||
6635 | /* Allocate memory for pooled objects */ | 6647 | /* Allocate memory for pooled objects */ |
@@ -6680,6 +6692,13 @@ MHD_start_daemon_va (unsigned int flags, | |||
6680 | else | 6692 | else |
6681 | MHD_itc_set_invalid_ (d->itc); | 6693 | MHD_itc_set_invalid_ (d->itc); |
6682 | 6694 | ||
6695 | #ifdef HAVE_LISTEN_SHUTDOWN | ||
6696 | mhd_assert ((MHD_ITC_IS_VALID_ (d->itc)) || \ | ||
6697 | (MHD_INVALID_SOCKET != d->listen_fd)); | ||
6698 | #else /* ! HAVE_LISTEN_SHUTDOWN */ | ||
6699 | mhd_assert (MHD_ITC_IS_VALID_ (d->itc)); | ||
6700 | #endif /* ! HAVE_LISTEN_SHUTDOWN */ | ||
6701 | |||
6683 | /* Divide available connections evenly amongst the threads. | 6702 | /* Divide available connections evenly amongst the threads. |
6684 | * Thread indexes in [0, leftover_conns) each get one of the | 6703 | * Thread indexes in [0, leftover_conns) each get one of the |
6685 | * leftover connections. */ | 6704 | * leftover connections. */ |