Checkout
kotkov
committed
on 20 Aug
Win32: prevent svn_io_file_rename2() from spinning in the retry loop in a
racy case where the rename function clears the read-only attribute… Show more
Win32: prevent svn_io_file_rename2() from spinning in the retry loop in a

racy case where the rename function clears the read-only attribute from the

destination file, but another thread or process is quick enough to set it

back before the original rename function has a chance to proceed.

Despite sounding like an uncommon case, this may happen when the API is

being used to atomically update the file contents while also altering its

read-only attribute (and where such updates can occur in parallel).

Fix this by including the call that clears the read-only attribute on the

destination into the retry loop instead of calling it only once before

looping.

* subversion/libsvn_subr/io.c

 (win32_file_rename): Handle EACCES/EEXIST and attempt to clear the

  destination read-only attribute if it's there.

 (svn_io_file_rename2): Don't call svn_io_set_file_read_write() in the

  Win32-specific portion of this function, since clearing the read-only

  attribute is now a part of the win32_file_rename() function.

Show less