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>
Thu, 4 Jan 2018 19:03:24 +0000 (14:03 -0500)
commit2fc621df9200475c471cb62a0c30ce4eae2d1dcd
treef6e4e0631d7c031783cf3eddb66842c24e0217ed
parent1779e3bf4876d8ac46657275e5f0f2ee6877a5c9
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

(cherry picked from commit 46287af0911f7cb446c62850630f85af567ac512)
libraries/base/System/IO.hs
libraries/base/cbits/Win32Utils.c
libraries/base/changelog.md