summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Berge <ericmberge@gmail.com>2014-05-13 09:10:38 -0500
committerBrad King <brad.king@kitware.com>2014-05-13 15:23:36 -0400
commit24bd7ae11af5dc989e569fee8422018a92c4f23e (patch)
tree5e1524149bd107e422e4c23238e565cb950a776f
parent9996b9846d5131e98d01c754eb50893d83314c3c (diff)
downloadcmake-24bd7ae11af5dc989e569fee8422018a92c4f23e.tar.gz
cmSystemTools::RenameFile: Retry on Windows ERROR_SHARING_VIOLATION
Add ERROR_SHARING_VIOLATION to the set of errors (previously including only ERROR_ACCESS_DENIED) that cause a rename (MoveFile) on Windows to retry. The condition was observed when two renames to the same target file name were happening simultaneously.
-rw-r--r--Source/cmSystemTools.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index ff05975636..c7acfd09bc 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -917,8 +917,10 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
cmsys::Encoding::ToWide(newname).c_str(),
MOVEFILE_REPLACE_EXISTING) && --retry.Count)
{
- // Try again only if failure was due to access permissions.
- if(GetLastError() != ERROR_ACCESS_DENIED)
+ DWORD last_error = GetLastError();
+ // Try again only if failure was due to access/sharing permissions.
+ if(last_error != ERROR_ACCESS_DENIED &&
+ last_error != ERROR_SHARING_VIOLATION)
{
return false;
}