[commit: ghc] master: Decrease locked region size on Windows to fix ERROR_LOCK_INVALID_RANGE (7e273ea)
git at git.haskell.org
git at git.haskell.org
Wed Mar 15 19:25:54 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/7e273ea28fe3630a8fede75ed28f471b7be21b5f/ghc
>---------------------------------------------------------------
commit 7e273ea28fe3630a8fede75ed28f471b7be21b5f
Author: Andrzej Rybczak <electricityispower at gmail.com>
Date: Wed Mar 15 14:30:48 2017 -0400
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
>---------------------------------------------------------------
7e273ea28fe3630a8fede75ed28f471b7be21b5f
libraries/base/GHC/IO/Handle/Lock.hsc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libraries/base/GHC/IO/Handle/Lock.hsc b/libraries/base/GHC/IO/Handle/Lock.hsc
index d03e261..5608c18 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
More information about the ghc-commits
mailing list