[PATCH] D111875: [Support] [Windows] Manually clean up temp files on network shares

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 15 04:00:19 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: rdwampler, amccarth, rnk, jhenderson, aganea.
Herald added subscribers: dexonsmith, hiraditya.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

Since D81803 <https://reviews.llvm.org/D81803> / 79657e2339b58bc01fe1b85a448bb073d57d90bb <https://reviews.llvm.org/rG79657e2339b58bc01fe1b85a448bb073d57d90bb>, temp files
created on network shares don't set "Disposition.DeleteFile = true".
This flag normally takes care of removing the temp file both if the
process exits abnormally, and when the file is closed cleanly.

Even if we can't seem to use the flag on network shares, we can
at least make sure to remove the temp files when they are closed
cleanly.

This patch adjusts setDeleteDisposition to take a bool &Delete
reference, to let the caller know whether it actually set the
flag or not (on network shares, it returns a success error code
but doesn't do what it was asked to).

When setDeleteDisposition is called from openNativeFile, we can't
easily pass this information back to the caller without adding
extra plumbing through all the layers of functions up to the
caller in TempFile::create.

Instead have TempFile::create() do a duplicate call to
setDeleteDisposition, to see whether it actually sets the
desired flag. If not, set a Windows specific flag in TempFile,
and manually remove the file in discard().

This fixes https://github.com/mstorsjo/llvm-mingw/issues/233.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111875

Files:
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Windows/Path.inc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111875.379964.patch
Type: text/x-patch
Size: 4963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211015/c6f39d5a/attachment.bin>


More information about the llvm-commits mailing list