[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#4943) tpool.c pause vs. finish



Full_Name: Hallvard B Furuseth
Version: HEAD, RE23
OS: 
URL: 
Submission from: (NULL) (129.240.202.105)
Submitted by: hallvard


As far as I can tell from tpool.c, ldap_pvt_thread_pool_destroy()
will act prematurely if another thread pauses:
    ldap_pvt_thread_pool_destroy (...) {
        ...
        if ( pool->ltp_open_count ) {
            ldap_pvt_thread_cond_broadcast(&pool->ltp_cond);
            ldap_pvt_thread_cond_wait(&pool->ltp_cond, &pool->ltp_mutex);
        }
... since ldap_pvt_thread_pool_resume() broadcasts on the same mutex.
Also ldap_pvt_thread_pool_resume() will reset ltp_state to RUNNING
instead of FINISHING/STOPPING.

If that can happen, the fix would be:
(a) use while() instead of if(),
(b) keep an ltp_unpaused_state along with ltp_pause which is _pause
    does not change and _resume copies to ltp_state, or just remove
    LDAP_INT_THREAD_POOL_PAUSING in favor of an ltp_pausing flag.
    (And possibly some code which currently checks ltp_state ought
    to check ltp_unpaused_state instead, I'm not sure.)
(c) if _destroy() can be called while LDAP_INT_THREAD_POOL_PAUSING,
    I think the other if()s around ltp_cond need to be while() too.