From 391bdbf9ace271ef41d6c73031d172cdad802f79 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 24 Jan 2013 19:25:37 -0500 Subject: [PATCH] Windows: AFSProcessCreate drop DirOpenRefCount on exit 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 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp b/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp index 68f770f..1ec51b7 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp @@ -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 // -- 1.9.4