[ 
https://issues.apache.org/jira/browse/DAEMON-286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mladen Turk resolved DAEMON-286.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 1.0.14

Your observation was correct.
I have added an extra sync event which waits inside worker thread for signal 
from apxJavaStart ensuring it saws the dwWorkerStatus set to 1.
                
> Race condition during stopping service
> --------------------------------------
>
>                 Key: DAEMON-286
>                 URL: https://issues.apache.org/jira/browse/DAEMON-286
>             Project: Commons Daemon
>          Issue Type: Bug
>          Components: Procrun
>    Affects Versions: 1.0.13
>         Environment: Windows 7 64 bit
>            Reporter: Mike Miller
>            Priority: Minor
>             Fix For: 1.0.14
>
>
> While debugging an issue where ProcRun NT Service hangs in the stopping 
> state, I noticed a race condition that causes 2 possible code paths during 
> stopping.   
>  
> serviceStop() calls afxJavaStart(...).  I have observed apxJavaStart() 
> returns both TRUE & FALSE for a successful call to my stop method.  I think 
> this is caused by a potential race condition in apxJavaStart() & 
> __apxJavaWorkerThread.  The afxJavaStart() waits for lpJava->hWorkerSync 
> event to be set and then checks the lpJava->dwWorkerStatus.  The race 
> condition is that __apxJavaWorkerThread sets the dwWorkerStatus to 1 and sets 
> the event but there is no guarantee that afxJavaStart() will see the 1.  If 
> the __apxJavaWorkerThread completes the stop call before afxJavaStart has a 
> chance to check the dwWorkerStatus, the __apxJavaWorkerThread may have 
> changed the dwWorkerStatus back to 0.   So depending on timing, it appears 
> apxJavaStart() could return either TRUE or FALSE even if the stop method 
> behaved the same.
>  
> This race condition results in the stopService() method not always calling 
> afxjavaWait(hWorker, INFINITE,...). 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to