on master help sign in
switch to verbose Windows error handling in file locking

appveyor appears to have some issue with file locking that I have not seen in a regular Windows VM

commit19798be480358c6951b740663a51d8c2fc3b0192 authorAgentM <agentm@themactionfaction.com> dateThu 18 Jan 2018, 13:10 (9 years ago) parent4732765
1 file changed+2−10
src/lib/ProjectM36/FileLock.hs+2−10
src/lib/ProjectM36/FileLock.hs+2−10
@@ -49,22 +49,14 @@ lockFile winHandle lock = do
4949
5050 allocaBytes sizeof_OVERLAPPED $ \op -> do
5151 zeroMemory op $ fromIntegral sizeof_OVERLAPPED
52− res <- c_lockFileEx winHandle (exFlag .|. blockFlag) 0 1 0 op
53− if res then
54− pure ()
55− else
56− error "failed to wait for database lock"
52+ failIfFalse_ "LockFileEx" $ c_lockFileEx winHandle (exFlag .|. blockFlag) 0 1 0 op
5753
5854unlockFile :: HANDLE -> IO ()
5955unlockFile winHandle = do
6056 let sizeof_OVERLAPPED = 32
6157 allocaBytes sizeof_OVERLAPPED $ \op -> do
6258 zeroMemory op $ fromIntegral sizeof_OVERLAPPED
63− res <- c_unlockFileEx winHandle 0 1 0 op
64− if res then
65− pure ()
66− else
67− error ("failed to unlock database lock: " ++ show res)
59+ failIfFalse_ "UnlockFileEx" $ c_unlockFileEx winHandle 0 1 0 op
6860
6961#else
7062--all of this complicated nonsense is fixed if we switch to GHC 8.2 which includes native flock support on handles