This commit is contained in:
Joey Hess 2012-11-05 16:00:55 -04:00
parent 85c52c4029
commit da65c5c1d1

View file

@ -50,24 +50,24 @@ xmppClientThread urlrenderer = NamedThread "XMPPClient" $ do
v <- liftAnnex getXMPPCreds v <- liftAnnex getXMPPCreds
case v of case v of
Nothing -> noop Nothing -> noop
Just c -> liftIO $ loop c =<< getCurrentTime Just c -> liftIO $ retry (runclient c) =<< getCurrentTime
where where
debug' = void . liftIO . iodebug debug' = void . liftIO . iodebug
{- When the client exits, it's restarted; {- When the client exits, it's restarted;
- if it keeps failing, back off to wait 5 minutes before - if it keeps failing, back off to wait 5 minutes before
- trying it again. -} - trying it again. -}
loop c starttime = do retry a starttime = do
e <- runclient c e <- a
now <- getCurrentTime now <- getCurrentTime
if diffUTCTime now starttime > 300 if diffUTCTime now starttime > 300
then do then do
void $ iodebug ["connection lost; reconnecting", show e] void $ iodebug ["connection lost; reconnecting", show e]
loop c now retry a now
else do else do
void $ iodebug ["connection failed; will retry", show e] void $ iodebug ["connection failed; will retry", show e]
threadDelaySeconds (Seconds 300) threadDelaySeconds (Seconds 300)
loop c =<< getCurrentTime retry a =<< getCurrentTime
runclient c = void $ connectXMPP c $ \jid -> do runclient c = void $ connectXMPP c $ \jid -> do
selfjid <- bindJID jid selfjid <- bindJID jid