[PATCH] D37398: [Support, Windows] Retry rename() when MoveFileExW returns ERROR_SHARING_VIOLATION

Oleg Ranevskyy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 13:55:51 PDT 2017


iid_iunknown created this revision.

Currently `rename()` retries `MoveFileExW` if it returns `ERROR_ACCESS_DENIED`.
`MoveFileExW` may also fail with `ERROR_SHARING_VIOLATION` when the file is opened by some other app.

This patch makes `rename()` aware of `ERROR_SHARING_VIOLATION` when moving the file, so that it does
not stop its attempts to move the file if this error is encountered.


Repository:
  rL LLVM

https://reviews.llvm.org/D37398

Files:
  lib/Support/Windows/Path.inc


Index: lib/Support/Windows/Path.inc
===================================================================
--- lib/Support/Windows/Path.inc
+++ lib/Support/Windows/Path.inc
@@ -414,7 +414,9 @@
 
     DWORD MoveError = ::GetLastError();
     ec = mapWindowsError(MoveError);
-    if (MoveError != ERROR_ACCESS_DENIED) break;
+    if (MoveError != ERROR_ACCESS_DENIED &&
+        MoveError != ERROR_SHARING_VIOLATION)
+      break;
   }
 
   return ec;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37398.113591.patch
Type: text/x-patch
Size: 458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170901/8d2fdfc5/attachment-0001.bin>


More information about the llvm-commits mailing list