From: Jeffrey Altman Date: Fri, 19 Oct 2012 12:37:25 +0000 (-0400) Subject: Windows: avoid race set/clear ExtentsRequestComplete X-Git-Tag: upstream/1.8.0_pre1^2~1896 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=dfcb68cdc82260f614b2efed2529dc7c559d1933;p=packages%2Fo%2Fopenafs.git Windows: avoid race set/clear ExtentsRequestComplete The FCB ExtentsRequestComplete KEVENT setting, clearing and testing was racy. Clear the event before issuing the request to the service and if the request fails, set it in case two threads issued requests for the same FCB in parallel and one fails and the other succeeds. We must ensure that a clear does not mask the event being set prior to the request thread returning. Change-Id: I6d496214a2621aeca2b9f6d2f50095ffd19b6c59 Reviewed-on: http://gerrit.openafs.org/8255 Reviewed-by: Rod Widdowson Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp b/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp index 06bd73c79..c8c207bac 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp @@ -813,6 +813,8 @@ AFSRequestExtentsAsync( IN AFSFcb *Fcb, request.Length)) { + KeClearEvent( &pNPFcb->Specific.File.ExtentsRequestComplete ); + AFSDbgLogMsg( AFS_SUBSYSTEM_EXTENT_PROCESSING, AFS_TRACE_LEVEL_VERBOSE, "AFSRequestExtentsAsync Request extents for fid %08lX-%08lX-%08lX-%08lX Offset %08lX Len %08lX Thread %08lX\n", @@ -862,17 +864,14 @@ AFSRequestExtentsAsync( IN AFSFcb *Fcb, } } - if( NT_SUCCESS( ntStatus)) + if( !NT_SUCCESS( ntStatus)) { - KeClearEvent( &pNPFcb->Specific.File.ExtentsRequestComplete ); + KeSetEvent( &pNPFcb->Specific.File.ExtentsRequestComplete, + 0, + FALSE); } } - else - { - - KeClearEvent( &pNPFcb->Specific.File.ExtentsRequestComplete ); - } try_exit: