On Fri, Aug 29, 2014 at 4:28 PM, Ruediger Pluem <[email protected]> wrote:
>
>
> [email protected] wrote:
>> Author: jim
>> Date: Mon Nov 25 13:59:06 2013
>> New Revision: 1545286
>>
>> URL: http://svn.apache.org/r1545286
>> Log:
>> Use a normalized offset point for idlers... still need to worry
>> that atomics work as "expected", in this case that a add32 of a -1
>> is the "same" as dec32 (as far as effect on idlers)
>>
>> Modified:
>>     httpd/httpd/trunk/server/mpm/event/event.c
>>     httpd/httpd/trunk/server/mpm/event/fdqueue.c
>>
>
>> Modified: httpd/httpd/trunk/server/mpm/event/fdqueue.c
>> URL: 
>> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/fdqueue.c?rev=1545286&r1=1545285&r2=1545286&view=diff
>> ==============================================================================
>> --- httpd/httpd/trunk/server/mpm/event/fdqueue.c (original)
>> +++ httpd/httpd/trunk/server/mpm/event/fdqueue.c Mon Nov 25 13:59:06 2013
>
>> @@ -131,7 +128,7 @@ apr_status_t ap_queue_info_set_idle(fd_q
>>  apr_status_t ap_queue_info_try_get_idler(fd_queue_info_t * queue_info)
>>  {
>>      int prev_idlers;
>> -    prev_idlers = apr_atomic_dec32((apr_uint32_t *)&(queue_info->idlers));
>> +    prev_idlers = apr_atomic_add32((apr_uint32_t *)&(queue_info->idlers), 
>> -1) - zero_pt;
>
> 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;
}

When all the workers are idle, queue_info->idlers should be equal to
zero_pt though (initial state)...

Regards,
Yann.

Reply via email to