On Fri, Aug 29, 2014 at 4:48 PM, Yann Ylavic <[email protected]> wrote:
> On Fri, Aug 29, 2014 at 4:28 PM, Ruediger Pluem <[email protected]> wrote:
>> Is this correct? apr_atomic_add32 expects an uint as 2nd argument. I just 
>> experienced a situation where all workers are
>> idle, but queue_info->idlers < zero_pt.
>
> The final code for this (with follow up http://svn.apache.org/r1545408) is :
>
> apr_status_t ap_queue_info_try_get_idler(fd_queue_info_t * queue_info)
> {
>     apr_int32_t new_idlers;
>     new_idlers = apr_atomic_add32(&(queue_info->idlers), -1) - zero_pt;
>     if (--new_idlers <= 0) {
>         apr_atomic_inc32(&(queue_info->idlers));    /* back out dec */
>         return APR_EAGAIN;
>     }
>     return APR_SUCCESS;
> }

Note there is still a race when some (other) thread calls
ap_queue_info_try_get_idler() between this one's apr_atomic_add32()
and apr_atomic_inc32(), so queue_info->idlers < zero_pt is indeed
possible.

Reply via email to