Skip to content

Commit

Permalink
threadWaitRead does not work on windows.
Browse files Browse the repository at this point in the history
A fix was introduced in 243f01b
The conditional was removed by mistake in 769ca47

To fix the regression the conditional will be reintroduced.
  • Loading branch information
diogob committed Jan 25, 2025
1 parent 51f123c commit c5acb41
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Hasql/Notifications.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ module Hasql.Notifications
FatalError (..),
)
where

import Control.Concurrent (threadDelay, threadWaitRead)
#if defined(mingw32_HOST_OS)
import Control.Concurrent ( threadDelay )
#else
import Control.Concurrent (threadWaitRead, threadDelay)
#endif
import Control.Exception (Exception, throw)
import Control.Monad (forever, unless, void, when)
import Data.ByteString.Char8 (ByteString)
Expand Down Expand Up @@ -190,9 +193,13 @@ waitForNotifications sendNotification con =
mfd <- PQ.socket pqCon
case mfd of
Nothing -> void $ threadDelay 1000000
#if defined(mingw32_HOST_OS)
Just _ -> do
void $ threadDelay 1000000
#else
Just fd -> do
void $ threadWaitRead fd

#endif
result <- PQ.consumeInput pqCon
unless result $ do
mError <- PQ.errorMessage pqCon
Expand Down

0 comments on commit c5acb41

Please sign in to comment.