From dfcb68cdc82260f614b2efed2529dc7c559d1933 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 19 Oct 2012 08:37:25 -0400 Subject: [PATCH] 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 --- src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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: -- 2.39.5