summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2017-03-15 14:30:48 -0400
committerBen Gamari <ben@smart-cactus.org>2017-03-15 15:23:34 -0400
commit7e273ea28fe3630a8fede75ed28f471b7be21b5f (patch)
tree6e1304f59c46ca5b43293f5717eb720b76040d02 /libraries
parentcec90709c9c8c2c2955f11b9ad29f4c99bd075db (diff)
downloadhaskell-7e273ea28fe3630a8fede75ed28f471b7be21b5f.tar.gz
Decrease locked region size on Windows to fix ERROR_LOCK_INVALID_RANGE
Reviewers: austin, hvr, bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3345
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/GHC/IO/Handle/Lock.hsc8
1 files changed, 4 insertions, 4 deletions
diff --git a/libraries/base/GHC/IO/Handle/Lock.hsc b/libraries/base/GHC/IO/Handle/Lock.hsc
index d03e261185..5608c1810c 100644
--- a/libraries/base/GHC/IO/Handle/Lock.hsc
+++ b/libraries/base/GHC/IO/Handle/Lock.hsc
@@ -128,10 +128,10 @@ lockImpl h ctx mode block = do
-- We want to lock the whole file without looking up its size to be
-- consistent with what flock does. According to documentation of LockFileEx
-- "locking a region that goes beyond the current end-of-file position is
- -- not an error", however e.g. Windows 10 doesn't accept maximum possible
- -- value (a pair of MAXDWORDs) for mysterious reasons. Work around that by
- -- leaving the highest bit set to 0.
- fix $ \retry -> c_LockFileEx wh flags 0 0xffffffff 0x7fffffff ovrlpd >>= \case
+ -- not an error", however some versions of Windows seem to have issues with
+ -- large regions and set ERROR_INVALID_LOCK_RANGE in such case for
+ -- mysterious reasons. Work around that by setting only low 32 bits.
+ fix $ \retry -> c_LockFileEx wh flags 0 0xffffffff 0x0 ovrlpd >>= \case
True -> return True
False -> getLastError >>= \err -> if
| not block && err == #{const ERROR_LOCK_VIOLATION} -> return False