Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismwendt committed Mar 10, 2023
1 parent db8e3a7 commit c619e36
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Network/WebSockets/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ runServerWithOptions opts app = S.withSocketsDo $
bracket
(makeListenSocket (serverHost opts) (serverPort opts))
S.close $ \sock -> do
heartbeat <- newEmptyMVar :: IO (MVar ())
heartbeat <- newEmptyMVar

let -- Update the connection options to perform a heartbeat whenever a
-- pong is received.
Expand All @@ -120,7 +120,7 @@ runServerWithOptions opts app = S.withSocketsDo $
}

-- Kills the thread if pong was not received within the grace period.
reaper grace appAsync = timeout (grace * 10^(6 :: Int)) (takeMVar heartbeat) >>= \case
reaper grace appAsync = timeout (grace * 1_000_000) (takeMVar heartbeat) >>= \case
Nothing -> appAsync `Async.cancelWith` PongTimeout
Just _ -> reaper grace appAsync

Expand Down

0 comments on commit c619e36

Please sign in to comment.