Windows: Avoid deadlock on ProcessTree Lock
authorJeffrey Altman <jaltman@your-file-system.com>
Sat, 26 May 2012 01:47:23 +0000 (21:47 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 1 Jun 2012 06:29:01 +0000 (23:29 -0700)
Change-Id: I2c1be0df615c513eefc27be167d7acda113c06e2
Reviewed-on: http://gerrit.openafs.org/7505
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/fs/AFSProcessSupport.cpp

index 1f77caf..af87c80 100644 (file)
@@ -290,25 +290,41 @@ AFSValidateProcessEntry( IN HANDLE ProcessId)
             pProcessCB == NULL)
         {
 
-            AFSProcessCreate( 0,
-                              ProcessId,
-                              0,
-                              0);
-        }
+            AFSReleaseResource( pDeviceExt->Specific.Control.ProcessTree.TreeLock);
 
-        if( !NT_SUCCESS( ntStatus) ||
-            pProcessCB == NULL)
-        {
+            AFSAcquireExcl( pDeviceExt->Specific.Control.ProcessTree.TreeLock,
+                            TRUE);
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_AUTHGROUP_PROCESSING,
-                          AFS_TRACE_LEVEL_ERROR,
-                          "%s Failed to locate process entry for ProcessID %I64X\n",
-                          __FUNCTION__,
-                          ullProcessID);
+            ntStatus = AFSLocateHashEntry( pDeviceExt->Specific.Control.ProcessTree.TreeHead,
+                                           ullProcessID,
+                                           (AFSBTreeEntry **)&pProcessCB);
 
-            AFSReleaseResource( pDeviceExt->Specific.Control.ProcessTree.TreeLock);
+            if( !NT_SUCCESS( ntStatus) ||
+                pProcessCB == NULL)
+            {
+
+                AFSProcessCreate( 0,
+                                  ProcessId,
+                                  0,
+                                  0);
+            }
+
+            if( !NT_SUCCESS( ntStatus) ||
+                pProcessCB == NULL)
+            {
+
+                AFSDbgLogMsg( AFS_SUBSYSTEM_AUTHGROUP_PROCESSING,
+                              AFS_TRACE_LEVEL_ERROR,
+                              "%s Failed to locate process entry for ProcessID %I64X\n",
+                              __FUNCTION__,
+                              ullProcessID);
+
+                AFSReleaseResource( pDeviceExt->Specific.Control.ProcessTree.TreeLock);
+
+                try_return( ntStatus = STATUS_UNSUCCESSFUL);
+            }
 
-            try_return( ntStatus = STATUS_UNSUCCESSFUL);
+            AFSConvertToShared( pDeviceExt->Specific.Control.ProcessTree.TreeLock);
         }
 
         //