Windows: AFSProcessCreate drop DirOpenRefCount on exit
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 25 Jan 2013 00:25:37 +0000 (19:25 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 2 Feb 2013 17:05:07 +0000 (09:05 -0800)
AFSProcessCreate() must not maintain its DirOpenReferenceCount
when bFileCreated is true because the AFSCcb maintains its own
count and the one obtained by AFSProcessCreate() will only be
leaked.

Change-Id: I6591eb1c10d3dffe7449894b29c9999f5db91d64
Reviewed-on: http://gerrit.openafs.org/8961
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp

index 68f770f..1ec51b7 100644 (file)
@@ -2051,6 +2051,26 @@ try_exit:
             AFSReleaseResource( &(*Fcb)->NPFcb->Resource);
         }
 
+        if ( bFileCreated)
+        {
+
+            //
+            // Decrement the reference added during initialization of the DE
+            // AFSInitCcb allocates its own reference count.
+            //
+
+            lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+                          AFS_TRACE_LEVEL_VERBOSE,
+                          "AFSProcessCreate Decrement count on %wZ DE %p Cnt %d\n",
+                          &pDirEntry->NameInformation.FileName,
+                          pDirEntry,
+                          lCount);
+
+            ASSERT( lCount >= 0);
+        }
+
         if( !NT_SUCCESS( ntStatus))
         {
 
@@ -2078,21 +2098,6 @@ try_exit:
                                  FALSE);
 
                 //
-                // Decrement the reference added during initialization of the DE
-                //
-
-                lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
-
-                AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
-                              AFS_TRACE_LEVEL_VERBOSE,
-                              "AFSProcessCreate Decrement count on %wZ DE %p Cnt %d\n",
-                              &pDirEntry->NameInformation.FileName,
-                              pDirEntry,
-                              lCount);
-
-                ASSERT( lCount >= 0);
-
-                //
                 // Pull the directory entry from the parent
                 //