summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
Diffstat (limited to 'Presence')
-rw-r--r--Presence/Server.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/Presence/Server.hs b/Presence/Server.hs
index 331829e7..003fcdbb 100644
--- a/Presence/Server.hs
+++ b/Presence/Server.hs
@@ -369,9 +369,9 @@ server = do
369 let elapsed = 1000.0 * (fin_utc `diffUTCTime` utc) 369 let elapsed = 1000.0 * (fin_utc `diffUTCTime` utc)
370 expected = fromIntegral interval 370 expected = fromIntegral interval
371 when (retry && elapsed < expected) $ do 371 when (retry && elapsed < expected) $ do
372 warn $ "Waiting to retry " <> bshow addr 372 debugNoise $ "Waiting to retry " <> bshow addr
373 startDelay timer (round $ 1000 * (expected-elapsed)) 373 startDelay timer (round $ 1000 * (expected-elapsed))
374 warn $ "retry " <> bshow (retry,addr) 374 debugNoise $ "retry " <> bshow (retry,addr)
375 when retry $ retryLoop 375 when retry $ retryLoop
376 376
377 377
@@ -736,6 +736,7 @@ connFlush c =
736 736
737bshow e = S.pack . show $ e 737bshow e = S.pack . show $ e
738warn str = S.hPutStrLn stderr str >> hFlush stderr 738warn str = S.hPutStrLn stderr str >> hFlush stderr
739debugNoise str = warn str -- return ()
739 740
740 741
741data PingEvent = PingIdle | PingTimeOut 742data PingEvent = PingIdle | PingTimeOut
@@ -841,13 +842,15 @@ interruptableDelay :: IO InterruptableDelay
841interruptableDelay = do 842interruptableDelay = do
842 fmap InterruptableDelay 843 fmap InterruptableDelay
843 $ atomically newEmptyTMVar 844 $ atomically newEmptyTMVar
845
844startDelay :: InterruptableDelay -> Microseconds -> IO () 846startDelay :: InterruptableDelay -> Microseconds -> IO ()
845startDelay d interval = do 847startDelay d interval = do
846 thread <- myThreadId 848 thread <- myThreadId
847 atomically $ putTMVar (delayThread d) thread 849 handle (\(ErrorCall _)-> do
848 handle (\(ErrorCall _)-> warn $ "delay interrupted" ) $ do 850 debugNoise $ "delay interrupted" ) $ do
851 atomically $ putTMVar (delayThread d) thread
849 threadDelay interval 852 threadDelay interval
850 void . atomically $ takeTMVar (delayThread d) 853 void . atomically $ takeTMVar (delayThread d)
851 854
852interruptDelay :: InterruptableDelay -> IO () 855interruptDelay :: InterruptableDelay -> IO ()
853interruptDelay d = do 856interruptDelay d = do
@@ -855,7 +858,5 @@ interruptDelay d = do
855 tryTakeTMVar (delayThread d) 858 tryTakeTMVar (delayThread d)
856 flip (maybe $ return ()) mthread $ \thread -> do 859 flip (maybe $ return ()) mthread $ \thread -> do
857 throwTo thread (ErrorCall "Interrupted delay") 860 throwTo thread (ErrorCall "Interrupted delay")
858 atomically $ do
859 putTMVar (delayThread d) thread
860 861
861 862