apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49709] New: apr_thread_pool_push may fail to wake up a thread in the thread pool
Date Thu, 05 Aug 2010 12:24:41 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49709

           Summary: apr_thread_pool_push may fail to wake up a thread in
                    the thread pool
           Product: APR
           Version: HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: APR-util
        AssignedTo: bugs@apr.apache.org
        ReportedBy: Joe.Mudd@sas.com


Created an attachment (id=25844)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25844)
apr_thread_pool.c patch

I have observed the following race condition between add_task() and
thread_pool_func().

If thread_pool_func() owns the me->lock and determines that there is no more
work in the task list, the thread will insert itself on the idle list then it
will enter wait.  Before entering wait, thread_pool_func() releases me->lock
then attempts to acquire conditional related me->cond_lock.

If add_task() is blocked on me->lock while thread_pool_func() is placing itself
on the idle list, add_task() may acquire me->lock as soon as thread_pool_func()
releases it.  When add_task() is able to beat the single thread pool thread in
thread_pool_func() in its acquisition of the conditional related me->cond_lock,
we end up with work in the thread pool and no awake threads to process the
work.  Depending on the application, this may cause an infinite wait for the
work to complete.

The attached patch changes all condition activity to make use of the main data
structure lock (me->lock) instead of the conditional lock (me->cond_lock). 
That way the addition of work and waking a thread becomes an atomic operation. 
As well as the placement of a thread in the idle list and waiting for more
work.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message