Windows: Do not delete in CleanupFile if error
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 11 Apr 2012 04:29:03 +0000 (00:29 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 11 Apr 2012 13:48:15 +0000 (06:48 -0700)
If an error was detected when processing RDR_CleanupFileEntry()
do not perform the file deletion.  Just return the error as
attempting the deletion could result in an exception.

Change-Id: I57b17a15d1bdda4d0890dbe59f9e2432d465250f
Reviewed-on: http://gerrit.openafs.org/7186
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/user/RDRFunction.c

index cc5a4c7..670e8ce 100644 (file)
@@ -1985,7 +1985,7 @@ RDR_CleanupFileEntry( IN cm_user_t *userp,
     if (bScpLocked)
         lock_ReleaseWrite(&scp->rw);
 
-    if (dscp && bDeleteFile) {
+    if (code == 0 && dscp && bDeleteFile) {
         WCHAR FileName[260];
 
         StringCchCopyNW(FileName, 260, FileNameCounted, FileNameLength / sizeof(WCHAR));
@@ -1996,16 +1996,16 @@ RDR_CleanupFileEntry( IN cm_user_t *userp,
             code = cm_Unlink(dscp, NULL, FileName, userp, &req);
     }
 
-    if ( ResultBufferLength >=  sizeof( AFSFileCleanupResultCB))
-    {
-        (*ResultCB)->ResultBufferLength = sizeof( AFSFileCleanupResultCB);
-        pResultCB = (AFSFileCleanupResultCB *)&(*ResultCB)->ResultData;
-        pResultCB->ParentDataVersion.QuadPart = dscp ? dscp->dataVersion : 0;
-    } else {
-        (*ResultCB)->ResultBufferLength = 0;
-    }
+    if (code == 0)
+        if ( ResultBufferLength >=  sizeof( AFSFileCleanupResultCB))
+        {
+            (*ResultCB)->ResultBufferLength = sizeof( AFSFileCleanupResultCB);
+            pResultCB = (AFSFileCleanupResultCB *)&(*ResultCB)->ResultData;
+            pResultCB->ParentDataVersion.QuadPart = dscp ? dscp->dataVersion : 0;
+        } else {
+            (*ResultCB)->ResultBufferLength = 0;
+        }
 
-    if (code == 0) {
         (*ResultCB)->ResultStatus = 0;
         osi_Log0(afsd_logp, "RDR_CleanupFileEntry SUCCESS");
     } else {
@@ -2014,6 +2014,7 @@ RDR_CleanupFileEntry( IN cm_user_t *userp,
         osi_Log2(afsd_logp, "RDR_CleanupFileEntry FAILURE code=0x%x status=0x%x",
                   code, status);
     }
+
     if (scp)
         cm_ReleaseSCache(scp);
     if (dscp)