summaryrefslogtreecommitdiff
path: root/Presence/XMPP.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/XMPP.hs')
-rw-r--r--Presence/XMPP.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Presence/XMPP.hs b/Presence/XMPP.hs
index 4db055ea..55aab3d4 100644
--- a/Presence/XMPP.hs
+++ b/Presence/XMPP.hs
@@ -646,10 +646,12 @@ handlePeer st src snk = do
646 debugL $ "(P) connected " <++> name 646 debugL $ "(P) connected " <++> name
647 session <- newPeerSession session_factory sock 647 session <- newPeerSession session_factory sock
648 648
649 finally ( src $= parseBytes def $$ fromPeer sock session ) 649 didClose <- newTVarIO False
650 finally ( src $= parseBytes def $$ fromPeer sock session didClose )
650 $ do 651 $ do
651 debugL $ "(P) disconnected " <++> name 652 debugL $ "(P) disconnected " <++> name
652 closePeerSession session 653 didc <- readTVarIO didClose
654 when (not didc) $ closePeerSession session
653 655
654 656
655handlePeerPresence session stanza False = do 657handlePeerPresence session stanza False = do
@@ -912,8 +914,8 @@ handlePeerIQGet session tag = do
912 req -> unhandledGet req 914 req -> unhandledGet req
913 915
914fromPeer :: (MonadThrow m,MonadIO m, JabberPeerSession session) => 916fromPeer :: (MonadThrow m,MonadIO m, JabberPeerSession session) =>
915 RestrictedSocket -> session -> Sink XML.Event m () 917 RestrictedSocket -> session -> TVar Bool -> Sink XML.Event m ()
916fromPeer sock session = doNestingXML $ do 918fromPeer sock session didClose = doNestingXML $ do
917 let log = liftIO . debugL . ("(P) " <++>) 919 let log = liftIO . debugL . ("(P) " <++>)
918 withXML $ \begindoc -> do 920 withXML $ \begindoc -> do
919 when (begindoc==EventBeginDocument) $ do 921 when (begindoc==EventBeginDocument) $ do
@@ -922,7 +924,9 @@ fromPeer sock session = doNestingXML $ do
922 withJust (elementAttrs "stream" xml) $ \stream_attrs -> do 924 withJust (elementAttrs "stream" xml) $ \stream_attrs -> do
923 log $ "stream atributes: " <++> bshow stream_attrs 925 log $ "stream atributes: " <++> bshow stream_attrs
924 926
925 let doTimeout = Thunk (closePeerSession session) 927 let doTimeout = Thunk $ do
928 atomically $ writeTVar didClose True
929 closePeerSession session
926 930
927 fix $ \loop -> do 931 fix $ \loop -> do
928 log "waiting for stanza." 932 log "waiting for stanza."