httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Nazarenko" <>
Subject Re: [PATCH] Avoid busy wait in winnt MPM when all workers are busy
Date Fri, 07 Feb 2003 22:42:17 GMT
>Finally spending some time reviewing this patch. It has a problem.
>Igor Nazarenko wrote:
>>+            /* We failed to grab a context off the queue, consider 
>>allocating a
>>+             * new one out of the child pool. There may be up to 
>>+             * contexts in the system at once.
>>+             * Note: this function assumes that only one thread may call 
>>+             * so the access to num_completion_contexts variable does not
>>+             * have to be protected.
>>+             */
>The server can have multiple accept threads (one for each Listen 
>directive), thus mpm_get_completion_context can have multiple threads in it 
>at once. num_completion_contexts needs protecting. I basically like your 
>patch, but I want to spend some time thinking through potential timing 
>windows before committing it.

Then in the old code there's also a race around the allocation of the last 
context, which may result in one extra completion context. It would go as 

thread 1 checks if it can allocate another context, sees counter == max-1
thread 2 checks the same condition, sees counter == max-1
thread 1 increments the counter
thread 2 increments the counter

This will cause the server to "lose" one client connection.

The easiest way to fix it without introducing extra synchronization overhead 
on the main codepath is to pre-allocate all contexts during the child 
initialization. Should I implement that and re-submit the patch?


MSN 8 with e-mail virus protection service: 2 months FREE*

View raw message