diff options
author | Nicholas Hutchinson <nshutchinson@gmail.com> | 2020-12-28 14:22:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-28 15:22:40 +0100 |
commit | eead7e9d63992684ce7290b09c05410485323096 (patch) | |
tree | ddf44ca283f8732a17261f08169f042462603492 /LICENSE.adoc | |
parent | da54bff4e2231a9b4619cb3299edda769fa3b2ba (diff) | |
download | ccache-eead7e9d63992684ce7290b09c05410485323096.tar.gz |
Improve TemporaryFile implementation for Windows (#736)
On Windows, multiple ccache process could race each other to create,
rename and delete temporary files, because they would attempt to
generate the same sequence of temporary file names
(`tmp.cpp_stdout.iG2Kb7`, `tmp.cpp_stdout.P1kAlM`,
`tmp.cpp_stdout.FzP5tM`, ...).
This is because ccache used mingw-w64's [implementation of mkstemp][1],
which uses `rand()` to generate temporary file names, and ccache was
never seeding the thread-local PRNG used by `rand()`.
Replace ccache's use of `mkstemp()` on Windows with an implementation
based on OpenBSD. This allows us to sidestep mingw-w64's problematic
implementation, and allows us to build using MSVC again. (MSVC's C
standard library does not provide `mkstemp()`.)
Example errors:
- Some ccache process is in the process of deleting a temporary file:
ccache: error: Failed to create temporary file for C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.FzP5tM: Access is denied.
- Some ccache process has destination file open, so it can't be overwritten:
ccache: error: failed to rename C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.iG2Kb7 to C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.iG2Kb7.ii: Access is denied.
- Source file has been deleted by some other ccache process:
ccache: error: failed to rename C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.P1kAlM to C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.P1kAlM.ii: The system cannot find the file specified.
[1]: https://github.com/mirror/mingw-w64/blob/v8.0.0/mingw-w64-crt/misc/mkstemp.c
Diffstat (limited to 'LICENSE.adoc')
-rw-r--r-- | LICENSE.adoc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/LICENSE.adoc b/LICENSE.adoc index 3c15c572..a9e5b9da 100644 --- a/LICENSE.adoc +++ b/LICENSE.adoc @@ -638,6 +638,30 @@ The full license text can be found in LGPL-3.0.txt and at https://www.gnu.org/licenses/lgpl-3.0.html. +src/third_party/win32/mktemp.* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This implementation of `mkstemp()` for Win32 was adapted from +<https://github.com/openbsd/src/blob/99b791d14c0f1858d87a0c33b55880fb9b00be66/lib/libc/stdio/mktemp.c> +and has the folowing license text: + +------------------------------------------------------------------------------- +Copyright (c) 1996-1998, 2008 Theo de Raadt +Copyright (c) 1997, 2008-2009 Todd C. Miller + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +------------------------------------------------------------------------------- + src/third_party/xxh* ~~~~~~~~~~~~~~~~~~~~ |