summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Network/Tox.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index 26488657..93d42eca 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -68,6 +68,8 @@ import qualified Data.HashMap.Strict as HashMap
68import qualified Data.Map.Strict as Map 68import qualified Data.Map.Strict as Map
69import DPut 69import DPut
70import Network.Tox.Avahi 70import Network.Tox.Avahi
71import Text.Printf
72import Data.List
71 73
72newCrypto :: IO TransportCrypto 74newCrypto :: IO TransportCrypto
73newCrypto = do 75newCrypto = do
@@ -361,7 +363,20 @@ mkDefaultDestroyHook roster = \session -> do
361 accounts <- readTVar (accounts roster) -- :: STM (HashMap NodeId (Account extra) 363 accounts <- readTVar (accounts roster) -- :: STM (HashMap NodeId (Account extra)
362 let mbAccount = HashMap.lookup (key2id $ ncMyPublicKey session) accounts -- :: STM (Maybe (Account extra) 364 let mbAccount = HashMap.lookup (key2id $ ncMyPublicKey session) accounts -- :: STM (Maybe (Account extra)
363 case mbAccount of 365 case mbAccount of
364 Just account -> Right <$> setTerminated now (ncTheirPublicKey session) account 366 Just account -> do
367 mp <- readTVar (netCryptoSessionsByKey (ncAllSessions session))
368 case Map.lookup (ncTheirPublicKey session) mp of
369 Just sessionsWithThisPublicKey
370 | relevantSessions <- filter ((/=ncSessionId session) . ncSessionId) sessionsWithThisPublicKey
371 , not (null relevantSessions)
372 -> do
373 let showsession x = printf "%x" (ncSessionId x)
374 return . Left $ "Not calling setTerminated on " ++ show (key2id (ncTheirPublicKey session))
375 ++" despite session(" ++ showsession session
376 ++ ") failure. (Still have sessions: ["
377 ++ Data.List.intercalate "," (map showsession relevantSessions)
378 ++ "]"
379 _ -> Right <$> setTerminated now (ncTheirPublicKey session) account
365 Nothing -> return . Left $ "(defaultDestroyHook) their is no account! pubkey=" ++ show (key2id (ncTheirPublicKey session)) 380 Nothing -> return . Left $ "(defaultDestroyHook) their is no account! pubkey=" ++ show (key2id (ncTheirPublicKey session))
366 case r of 381 case r of
367 Left msg -> dput XMan msg 382 Left msg -> dput XMan msg