Browse Source

change pullStanza to not block the stream

add debugging information for outgoing stanzas over TLS
cleanup in Xmpp.Concurrent.Threads
master
Philipp Balzarek 13 years ago
parent
commit
1f3a18f2ef
  1. 5
      source/Network/Xmpp/Concurrent/Threads.hs
  2. 2
      source/Network/Xmpp/Stream.hs
  3. 4
      source/Network/Xmpp/Tls.hs

5
source/Network/Xmpp/Concurrent/Threads.hs

@ -78,10 +78,7 @@ startThreadsWith :: (Stanza -> IO ())
TMVar Stream, TMVar Stream,
ThreadId)) ThreadId))
startThreadsWith stanzaHandler eh con = do startThreadsWith stanzaHandler eh con = do
rd <- withStream' (gets $ streamSend . streamHandle >>= \d -> return $ Right d) con read' <- withStream' (gets $ streamSend . streamHandle) con
case rd of
Left e -> return $ Left e
Right read' -> do
writeLock <- newTMVarIO read' writeLock <- newTMVarIO read'
conS <- newTMVarIO con conS <- newTMVarIO con
-- lw <- forkIO $ writeWorker outC writeLock -- lw <- forkIO $ writeWorker outC writeLock

2
source/Network/Xmpp/Stream.hs

@ -429,7 +429,7 @@ pullUnpickle p = do
-- | Pulls a stanza (or stream error) from the stream. -- | Pulls a stanza (or stream error) from the stream.
pullStanza :: Stream -> IO (Either XmppFailure Stanza) pullStanza :: Stream -> IO (Either XmppFailure Stanza)
pullStanza = withStream $ do pullStanza = withStream' $ do
res <- pullUnpickle xpStreamStanza res <- pullUnpickle xpStreamStanza
case res of case res of
Left e -> return $ Left e Left e -> return $ Left e

4
source/Network/Xmpp/Tls.hs

@ -134,7 +134,9 @@ tlsinit params backend = do
readWithBuffer <- liftIO $ mkReadBuffer (recvData con) readWithBuffer <- liftIO $ mkReadBuffer (recvData con)
return ( src return ( src
, snk , snk
, \s -> sendData con $ BL.fromChunks [s] , \s -> do
liftIO $ debugM "Pontarius.Xmpp.TLS" ("out :" ++ BSC8.unpack s)
sendData con $ BL.fromChunks [s]
, liftIO . readWithBuffer , liftIO . readWithBuffer
, con , con
) )

Loading…
Cancel
Save