The worker thread can race with a AFSCleanup() operation and
tear down the Fcb before the AFSCleanup() drops the Fcb->NPFcb->Resource.
Avoid this race by requiring the worker thread to obtain the resource
once before deleting the resource.
Change-Id: Iafad8260c5dfc4187a62c04b14d55ac0bf0e4aeb
Reviewed-on: http://gerrit.openafs.org/6462
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
if( pCurrentObject->Fcb != NULL)
{
+ //
+ // Acquire and drop the Fcb resource to synchronize
+ // with a potentially active AFSCleanup() which sets
+ // the OpenReferenceCount to zero while holding the
+ // resource.
+ //
+
+ AFSAcquireExcl( &pCurrentObject->Fcb->NPFcb->Resource,
+ TRUE);
+
+ AFSReleaseResource( &pCurrentObject->Fcb->NPFcb->Resource);
+
AFSCleanupFcb( pCurrentObject->Fcb,
TRUE);