[PATCH] D38570: Support: Rewrite Windows implementation of sys::fs::rename to be more POSIXy.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 12:36:45 PDT 2017


Peter Collingbourne <peter at pcc.me.uk> writes:

> On Thu, Oct 5, 2017 at 11:21 AM, Rafael Avila de Espindola <
> rafael.espindola at gmail.com> wrote:
>
>> Peter Collingbourne via Phabricator via llvm-commits
>> <llvm-commits at lists.llvm.org> writes:
>>
>>
>> > +  while (1) {
>> > +    auto EC = rename_internal(FromHandle, To, true);
>> > +    if (!EC || EC != errc::permission_denied)
>> > +      return EC;
>> ...
>> > +    // The destination file probably exists and is currently open in
>> another
>> > +    // process. Rename it to move it out of the way of the source file.
>> Use
>> > +    // FILE_FLAG_DELETE_ON_CLOSE to arrange for the destination file to
>> be
>> > +    // deleted when the other process closes it.
>>
>> This only happens if the file is open without FILE_SHARE_DELETE mode, no?
>>
>
> I observed that it could also happen if the destination file is memory
> mapped (i.e. another process has a MemoryBuffer open on the file). In that
> case we cannot delete it directly, we have to rename it.

Please add a comment saying why just using FILE_SHARE_DELETE everywhere
is not enough.

Cheers,
Rafael


More information about the llvm-commits mailing list