From 24bd7ae11af5dc989e569fee8422018a92c4f23e Mon Sep 17 00:00:00 2001 From: Eric Berge Date: Tue, 13 May 2014 09:10:38 -0500 Subject: 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. --- Source/cmSystemTools.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index ff05975..c7acfd0 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; } -- cgit v0.12