diff options
Diffstat (limited to 'dht/src/Network/Tox')
-rw-r--r-- | dht/src/Network/Tox/AggregateSession.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/dht/src/Network/Tox/AggregateSession.hs b/dht/src/Network/Tox/AggregateSession.hs index d1f42e91..feb634f0 100644 --- a/dht/src/Network/Tox/AggregateSession.hs +++ b/dht/src/Network/Tox/AggregateSession.hs | |||
@@ -31,6 +31,7 @@ import Data.Function | |||
31 | import qualified Data.IntMap.Strict as IntMap | 31 | import qualified Data.IntMap.Strict as IntMap |
32 | ;import Data.IntMap.Strict (IntMap) | 32 | ;import Data.IntMap.Strict (IntMap) |
33 | import Data.List | 33 | import Data.List |
34 | import Data.Maybe | ||
34 | import Data.Time.Clock.POSIX | 35 | import Data.Time.Clock.POSIX |
35 | import System.IO.Error | 36 | import System.IO.Error |
36 | 37 | ||
@@ -108,6 +109,7 @@ newAggregateSession notify = do | |||
108 | data AddResult = FirstSession -- ^ Initial connection with this contact. | 109 | data AddResult = FirstSession -- ^ Initial connection with this contact. |
109 | | AddedSession -- ^ Added another connection to active session. | 110 | | AddedSession -- ^ Added another connection to active session. |
110 | | RejectedSession -- ^ Failed to add session (wrong contact / closed session). | 111 | | RejectedSession -- ^ Failed to add session (wrong contact / closed session). |
112 | deriving (Eq,Show) | ||
111 | 113 | ||
112 | -- | The 'keepAlive' thread juggles three scheduled tasks. | 114 | -- | The 'keepAlive' thread juggles three scheduled tasks. |
113 | data KeepAliveEvents = DoTimeout -- ^ A session timed-out, close it. | 115 | data KeepAliveEvents = DoTimeout -- ^ A session timed-out, close it. |
@@ -244,7 +246,9 @@ addSession c s = do | |||
244 | return (result,Just con,singleSession <$> s0) | 246 | return (result,Just con,singleSession <$> s0) |
245 | 247 | ||
246 | mapM_ sClose rejected | 248 | mapM_ sClose rejected |
247 | forM_ (mcon :: Maybe SingleCon) $ \con -> | 249 | when (isNothing mcon) $ dput XMan "addSession: Rejected session!" |
250 | forM_ (mcon :: Maybe SingleCon) $ \con -> do | ||
251 | dput XMan $ "addSession: forkSession! " ++ show result | ||
248 | forkSession c s $ \progress -> do | 252 | forkSession c s $ \progress -> do |
249 | status0 <- aggregateStatus c | 253 | status0 <- aggregateStatus c |
250 | writeTVar (singleStatus con) progress | 254 | writeTVar (singleStatus con) progress |
@@ -314,6 +318,8 @@ closeAll :: AggregateSession -> IO () | |||
314 | closeAll c = join $ atomically $ do | 318 | closeAll c = join $ atomically $ do |
315 | imap <- readTVar (contactSession c) | 319 | imap <- readTVar (contactSession c) |
316 | closeTMChan (contactChannel c) | 320 | closeTMChan (contactChannel c) |
321 | forM_ (listToMaybe $ IntMap.elems imap) $ \(SingleCon s _) -> do | ||
322 | notifyState c c s Dormant | ||
317 | return $ forM_ (IntMap.toList imap) $ \(sid,SingleCon s _) -> do | 323 | return $ forM_ (IntMap.toList imap) $ \(sid,SingleCon s _) -> do |
318 | sClose s | 324 | sClose s |
319 | delSession c sid | 325 | delSession c sid |