diff options
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/Server.hs | 15 |
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 | ||
737 | bshow e = S.pack . show $ e | 737 | bshow e = S.pack . show $ e |
738 | warn str = S.hPutStrLn stderr str >> hFlush stderr | 738 | warn str = S.hPutStrLn stderr str >> hFlush stderr |
739 | debugNoise str = warn str -- return () | ||
739 | 740 | ||
740 | 741 | ||
741 | data PingEvent = PingIdle | PingTimeOut | 742 | data PingEvent = PingIdle | PingTimeOut |
@@ -841,13 +842,15 @@ interruptableDelay :: IO InterruptableDelay | |||
841 | interruptableDelay = do | 842 | interruptableDelay = do |
842 | fmap InterruptableDelay | 843 | fmap InterruptableDelay |
843 | $ atomically newEmptyTMVar | 844 | $ atomically newEmptyTMVar |
845 | |||
844 | startDelay :: InterruptableDelay -> Microseconds -> IO () | 846 | startDelay :: InterruptableDelay -> Microseconds -> IO () |
845 | startDelay d interval = do | 847 | startDelay 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 | ||
852 | interruptDelay :: InterruptableDelay -> IO () | 855 | interruptDelay :: InterruptableDelay -> IO () |
853 | interruptDelay d = do | 856 | interruptDelay 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 | ||