Skip to content
Snippets Groups Projects
Commit a287573d authored by Howard Chu's avatar Howard Chu
Browse files

ITS#5407 more checks for pool pausing

parent 26c08cb6
No related branches found
No related tags found
No related merge requests found
......@@ -251,6 +251,10 @@ LDAP_F( int )
ldap_pvt_thread_pool_backload LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_pausecheck LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_pause LDAP_P((
ldap_pvt_thread_pool_t *pool ));
......
......@@ -692,6 +692,45 @@ ldap_int_thread_pool_wrapper (
return(NULL);
}
/* See if a pause was requested; wait for it if so.
* Return 1 if we waited, 0 if not
*/
int
ldap_pvt_thread_pool_pausecheck (
ldap_pvt_thread_pool_t *tpool )
{
struct ldap_int_thread_pool_s *pool;
if (tpool == NULL)
return(-1);
pool = *tpool;
if (pool == NULL)
return(0);
if ( !pool->ltp_pause )
return(0);
ldap_pvt_thread_mutex_lock(&pool->ltp_mutex);
/* If someone else has already requested a pause, we have to wait */
if (pool->ltp_pause) {
pool->ltp_pending_count++;
pool->ltp_active_count--;
/* let the other pool_pause() know when it can proceed */
if (pool->ltp_active_count < 2)
ldap_pvt_thread_cond_signal(&pool->ltp_pcond);
do {
ldap_pvt_thread_cond_wait(&pool->ltp_cond, &pool->ltp_mutex);
} while (pool->ltp_pause);
pool->ltp_pending_count--;
pool->ltp_active_count++;
}
ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
return 1;
}
/* Pause the pool. Return when all other threads are paused. */
int
ldap_pvt_thread_pool_pause (
......
......@@ -1780,7 +1780,13 @@ syncprov_op_mod( Operation *op, SlapReply *rs )
/* wait for this op to get to head of list */
while ( mt->mt_mods != mi ) {
ldap_pvt_thread_mutex_unlock( &mt->mt_mutex );
ldap_pvt_thread_yield();
/* FIXME: if dynamic config can delete overlays or
* databases we'll have to check for cleanup here.
* Currently it's not an issue because there are
* no dynamic config deletes...
*/
if ( !ldap_pvt_thread_pool_pausecheck( &connection_pool ))
ldap_pvt_thread_yield();
ldap_pvt_thread_mutex_lock( &mt->mt_mutex );
/* clean up if the caller is giving up */
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment