summaryrefslogtreecommitdiff
path: root/dht
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2020-01-11 21:28:13 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-11 21:28:13 -0500
commita7cc1e718b87240ef83e2c4abfd4f2efdd6a7e87 (patch)
tree39a617986734d04d33d8de30c88c95713ca34e81 /dht
parentc3af9eb007c96c7fe816cc428f1e37881241b48c (diff)
Simplified AggregateSession status reporting.
Diffstat (limited to 'dht')
-rw-r--r--dht/src/Network/Tox/AggregateSession.hs24
1 files changed, 10 insertions, 14 deletions
diff --git a/dht/src/Network/Tox/AggregateSession.hs b/dht/src/Network/Tox/AggregateSession.hs
index faf512d0..9a784291 100644
--- a/dht/src/Network/Tox/AggregateSession.hs
+++ b/dht/src/Network/Tox/AggregateSession.hs
@@ -243,23 +243,19 @@ addSession c s = do
243 return (result,Just con,s0) 243 return (result,Just con,s0)
244 244
245 mapM_ (sClose . singleSession) replaced 245 mapM_ (sClose . singleSession) replaced
246 forM_ mcon $ \con -> 246 forM_ (mcon :: Maybe SingleCon) $ \con ->
247 forkSession c s $ \progress -> do 247 forkSession c s $ \progress -> do
248 status0 <- aggregateStatus c
248 writeTVar (singleStatus con) progress 249 writeTVar (singleStatus con) progress
249 emap <- readTVar (contactEstablished c) 250 emap' <- do
250 emap' <- case progress of 251 emap <- readTVar (contactEstablished c)
251 Established -> do 252 return $ case progress of
252 when (IntMap.null emap) $ notifyState c c s Established 253 Established -> IntMap.insert (sSessionID s) () emap
253 return $ IntMap.insert (sSessionID s) () emap 254 _ -> IntMap.delete (sSessionID s) emap
254 _ -> do
255 let emap' = IntMap.delete (sSessionID s) emap
256 when (IntMap.null emap' && not (IntMap.null emap)) $ do
257 imap <- readTVar (contactSession c)
258 notifyState c c s
259 $ if IntMap.null imap then Dormant
260 else InProgress AwaitingSessionPacket
261 return emap'
262 writeTVar (contactEstablished c) emap' 255 writeTVar (contactEstablished c) emap'
256 status <- aggregateStatus c
257 when (status /= status0) $ notifyState c c s status
258
263 return result 259 return result
264 260
265-- | Information returned from 'delSession'. 261-- | Information returned from 'delSession'.