mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-05 13:40:08 +08:00
Since we only have LDAP_MAXTHR thread_keys, allow max LDAP_MAXTHR
threads per pool, even when ltp_max_count <= 0 ("unlimited"). Keep ltp_max_count in range [0, LDAP_MAXTHR].
This commit is contained in:
parent
f0a1511422
commit
810b2389dc
@ -269,6 +269,9 @@ ldap_pvt_thread_pool_init (
|
|||||||
ldap_pvt_thread_pool_t pool;
|
ldap_pvt_thread_pool_t pool;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (! (0 <= max_threads && max_threads <= LDAP_MAXTHR))
|
||||||
|
max_threads = 0;
|
||||||
|
|
||||||
*tpool = NULL;
|
*tpool = NULL;
|
||||||
pool = (ldap_pvt_thread_pool_t) LDAP_CALLOC(1,
|
pool = (ldap_pvt_thread_pool_t) LDAP_CALLOC(1,
|
||||||
sizeof(struct ldap_int_thread_pool_s));
|
sizeof(struct ldap_int_thread_pool_s));
|
||||||
@ -383,8 +386,8 @@ ldap_pvt_thread_pool_submit (
|
|||||||
}
|
}
|
||||||
ldap_pvt_thread_cond_signal(&pool->ltp_cond);
|
ldap_pvt_thread_cond_signal(&pool->ltp_cond);
|
||||||
if (pool->ltp_open_count < pool->ltp_active_count + pool->ltp_pending_count
|
if (pool->ltp_open_count < pool->ltp_active_count + pool->ltp_pending_count
|
||||||
&& (pool->ltp_open_count < pool->ltp_max_count ||
|
&& (pool->ltp_open_count <
|
||||||
pool->ltp_max_count <= 0 ))
|
(pool->ltp_max_count ? pool->ltp_max_count : LDAP_MAXTHR)))
|
||||||
{
|
{
|
||||||
pool->ltp_open_count++;
|
pool->ltp_open_count++;
|
||||||
pool->ltp_starting++;
|
pool->ltp_starting++;
|
||||||
@ -449,6 +452,9 @@ ldap_pvt_thread_pool_maxthreads ( ldap_pvt_thread_pool_t *tpool, int max_threads
|
|||||||
{
|
{
|
||||||
struct ldap_int_thread_pool_s *pool;
|
struct ldap_int_thread_pool_s *pool;
|
||||||
|
|
||||||
|
if (! (0 <= max_threads && max_threads <= LDAP_MAXTHR))
|
||||||
|
max_threads = 0;
|
||||||
|
|
||||||
if (tpool == NULL)
|
if (tpool == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
@ -681,8 +687,8 @@ ldap_int_thread_pool_wrapper (
|
|||||||
if (pool->ltp_state == LDAP_INT_THREAD_POOL_FINISHING)
|
if (pool->ltp_state == LDAP_INT_THREAD_POOL_FINISHING)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (pool->ltp_max_count > 0
|
if (pool->ltp_open_count >
|
||||||
&& pool->ltp_open_count > pool->ltp_max_count)
|
(pool->ltp_max_count ? pool->ltp_max_count : LDAP_MAXTHR))
|
||||||
{
|
{
|
||||||
/* too many threads running (can happen if the
|
/* too many threads running (can happen if the
|
||||||
* maximum threads value is set during ongoing
|
* maximum threads value is set during ongoing
|
||||||
|
Loading…
Reference in New Issue
Block a user