Browse Source

add type delcaration to runHandlers and don't pass write sem to startThreadsWith

master
Philipp Balzarek 12 years ago
parent
commit
3f8848825f
  1. 7
      source/Network/Xmpp/Concurrent.hs
  2. 2
      source/Network/Xmpp/Concurrent/Threads.hs

7
source/Network/Xmpp/Concurrent.hs

@ -50,6 +50,7 @@ import System.Random (randomRIO)
import Control.Monad.State.Strict import Control.Monad.State.Strict
runHandlers :: [Stanza -> [Annotation] -> IO [Annotated Stanza]] -> Stanza -> IO ()
runHandlers [] sta = do runHandlers [] sta = do
errorM "Pontarius.Xmpp" $ errorM "Pontarius.Xmpp" $
"No stanza handlers set, discarding stanza" ++ show sta "No stanza handlers set, discarding stanza" ++ show sta
@ -94,7 +95,7 @@ handleIQ iqHands out sta as = do
Right res -> IQResultS $ IQResult iqid Nothing Right res -> IQResultS $ IQResult iqid Nothing
from lang res from lang res
Ex.bracketOnError (atomically $ takeTMVar sentRef) Ex.bracketOnError (atomically $ takeTMVar sentRef)
(atomically . putTMVar sentRef) (atomically . tryPutTMVar sentRef)
$ \wasSent -> do $ \wasSent -> do
case wasSent of case wasSent of
True -> do True -> do
@ -154,11 +155,11 @@ newSession stream config realm mbSasl = runErrorT $ do
] ]
, rosterH , rosterH
] ]
(kill, wLock, streamState, reader) <- ErrorT $ startThreadsWith writeSem stanzaHandler eh stream (kill, streamState, reader) <- ErrorT $ startThreadsWith writeSem stanzaHandler eh stream
idGen <- liftIO $ sessionStanzaIDs config idGen <- liftIO $ sessionStanzaIDs config
let sess = Session { stanzaCh = stanzaChan let sess = Session { stanzaCh = stanzaChan
, iqHandlers = iqHands , iqHandlers = iqHands
, writeSemaphore = wLock , writeSemaphore = writeSem
, readerThread = reader , readerThread = reader
, idGenerator = idGen , idGenerator = idGen
, streamRef = streamState , streamRef = streamState

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

@ -94,7 +94,6 @@ startThreadsWith :: TMVar (BS.ByteString -> IO Bool)
-> TMVar EventHandlers -> TMVar EventHandlers
-> Stream -> Stream
-> IO (Either XmppFailure (IO (), -> IO (Either XmppFailure (IO (),
TMVar (BS.ByteString -> IO Bool),
TMVar Stream, TMVar Stream,
ThreadId)) ThreadId))
startThreadsWith writeSem stanzaHandler eh con = do startThreadsWith writeSem stanzaHandler eh con = do
@ -104,7 +103,6 @@ startThreadsWith writeSem stanzaHandler eh con = do
cp <- forkIO $ connPersist writeSem cp <- forkIO $ connPersist writeSem
rdw <- forkIO $ readWorker stanzaHandler (noCon eh) conS rdw <- forkIO $ readWorker stanzaHandler (noCon eh) conS
return $ Right ( killConnection [rdw, cp] return $ Right ( killConnection [rdw, cp]
, writeSem
, conS , conS
, rdw , rdw
) )

Loading…
Cancel
Save