From e710ed2434496f7891363def81c1c8756eadd129 Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 9 Feb 2014 23:36:58 -0500 Subject: extra careful ping bump --- Presence/Server.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Presence/Server.hs b/Presence/Server.hs index da0cda17..c7162265 100644 --- a/Presence/Server.hs +++ b/Presence/Server.hs @@ -622,8 +622,13 @@ pingCancel me = do pingBump :: PingMachine -> IO () pingBump me = do b <- atomically $ do - when (pingIdle me /= 0) $ - putTMVar (pingDelay me) (1000*pingIdle me,PingIdle) + when (pingIdle me /= 0) $ do + e <- tryReadTMVar (pingDelay me) + case e of + Just (0,PingTimeOut) -> return () -- canceled/fired + Just _ -> retry + Nothing -> putTMVar (pingDelay me) + (1000*pingIdle me,PingIdle) readTVar (pingStarted me) when b $ throwTo (pingThread me) $ ErrorCall "" -- cgit v1.2.3