diff options
author | Joe Crayne <joe@jerkface.net> | 2020-01-26 03:51:45 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-26 03:51:45 -0500 |
commit | 3581bb6d887728441d161765392a0d96ae8ccf19 (patch) | |
tree | c2602656f09383ff1df2a433d0c182b13c3a4283 | |
parent | c0b6b785596df15d3bf48cd5aba171a5d1bccd23 (diff) |
Remove timed-out sessions from aggregate map.
-rw-r--r-- | dht/src/Network/Tox/AggregateSession.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/dht/src/Network/Tox/AggregateSession.hs b/dht/src/Network/Tox/AggregateSession.hs index 44bbf9b9..c657f4d9 100644 --- a/dht/src/Network/Tox/AggregateSession.hs +++ b/dht/src/Network/Tox/AggregateSession.hs | |||
@@ -269,12 +269,12 @@ addSession c s = do | |||
269 | forkSession c s $ \progress -> do | 269 | forkSession c s $ \progress -> do |
270 | status0 <- aggregateStatus c | 270 | status0 <- aggregateStatus c |
271 | writeTVar (singleStatus con) progress | 271 | writeTVar (singleStatus con) progress |
272 | emap' <- do | 272 | let sid = sSessionID s |
273 | emap <- readTVar (contactEstablished c) | 273 | modifyTVar' (contactEstablished c) $ case progress of |
274 | return $ case progress of | 274 | Established -> IntMap.insert sid () |
275 | Established -> IntMap.insert (sSessionID s) () emap | 275 | _ -> IntMap.delete sid |
276 | _ -> IntMap.delete (sSessionID s) emap | 276 | when (progress == Dormant) $ |
277 | writeTVar (contactEstablished c) emap' | 277 | modifyTVar' (contactSession c) (IntMap.delete sid) |
278 | status <- aggregateStatus c | 278 | status <- aggregateStatus c |
279 | when (status /= status0) $ notifyState c c s status | 279 | when (status /= status0) $ notifyState c c s status |
280 | mapM_ (delSession c) closed | 280 | mapM_ (delSession c) closed |