Make System.IO.openTempFile thread-safe on Windows
authorTamar Christina <tamar@zhox.com>
Tue, 2 Jan 2018 21:02:49 +0000 (16:02 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 2 Jan 2018 22:33:04 +0000 (17:33 -0500)
commit46287af0911f7cb446c62850630f85af567ac512
tree6447e46470669753746a2da83391347781e77eae
parent27b7b4db9af99aeb88dce7ef0e85131199bbf2ff
Make System.IO.openTempFile thread-safe on Windows

This calls out to the Win32 API `GetTempFileName` to generate
a temporary file. Using `uUnique = 0` guarantees that the file
we get back is unique and the file is "reserved" by creating it.

Test Plan:
./validate

I can't think of any sensible tests that shouldn't run for a while
to verify. So the example in #10731 was ran for a while and no
collisions in new code

Reviewers: hvr, bgamari, erikd

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #10731

Differential Revision: https://phabricator.haskell.org/D4278
libraries/base/System/IO.hs
libraries/base/cbits/Win32Utils.c
libraries/base/changelog.md