diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-06-09 07:04:15 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-06-09 07:04:15 +0000 |
commit | 3cdcc5851248ec7c7156e8bd03799a3b329a3498 (patch) | |
tree | 2821de1c7b38a2b43cd3cba89b793af795c34a8a /src | |
parent | d9a57957141a02fbdf3c4dcb1a9744c276432cd2 (diff) |
addSessinToMap (dead code for now, used for debugging)
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index e22388a3..2fc12559 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -589,6 +589,7 @@ freshCryptoSession sessions | |||
589 | , ncLastNMsgs = lastNQ | 589 | , ncLastNMsgs = lastNQ |
590 | , ncListeners = listeners | 590 | , ncListeners = listeners |
591 | } | 591 | } |
592 | -- addSessionToMap sessions addr netCryptoSession0 | ||
592 | addSessionToMapIfNotThere sessions addr netCryptoSession0 | 593 | addSessionToMapIfNotThere sessions addr netCryptoSession0 |
593 | maybeLaunchMissles | 594 | maybeLaunchMissles |
594 | <- case mbpktoq of | 595 | <- case mbpktoq of |
@@ -618,6 +619,20 @@ createNetCryptoOutQueue sessions newsession theirSessionKey pktq ncMyPacketNonce | |||
618 | pktoq <- PQ.newOutGoing pktq ncToWire toWireIO 0 (outboundQueueCapacity sessions) 0 | 619 | pktoq <- PQ.newOutGoing pktq ncToWire toWireIO 0 (outboundQueueCapacity sessions) 0 |
619 | return (HaveHandshake pktoq) | 620 | return (HaveHandshake pktoq) |
620 | 621 | ||
622 | -- | add new session to the lookup maps | ||
623 | addSessionToMap :: NetCryptoSessions -> SockAddr -> NetCryptoSession -> STM () | ||
624 | addSessionToMap sessions addrRaw netCryptoSession = do | ||
625 | let addr = either id id $ either4or6 addrRaw | ||
626 | let dmsg msg = trace msg (return ()) | ||
627 | dmsg $ "addSessionToMapIfNotThere sockaddr = " ++ show addr ++ ", sessionid = " ++ show (ncSessionId netCryptoSession) | ||
628 | let remotePublicKey = ncTheirPublicKey netCryptoSession | ||
629 | allsessions = netCryptoSessions sessions | ||
630 | allsessionsByKey= netCryptoSessionsByKey sessions | ||
631 | byAddrResult <- readTVar allsessions >>= return . Map.lookup addr | ||
632 | mp <- readTVar allsessionsByKey | ||
633 | modifyTVar allsessions (Map.insert addr netCryptoSession) | ||
634 | modifyTVar allsessionsByKey (Map.insertWith (++) remotePublicKey [netCryptoSession]) | ||
635 | |||
621 | -- | add this session to the lookup maps, overwrite if its already in them | 636 | -- | add this session to the lookup maps, overwrite if its already in them |
622 | addSessionToMapIfNotThere :: NetCryptoSessions -> SockAddr -> NetCryptoSession -> STM () | 637 | addSessionToMapIfNotThere :: NetCryptoSessions -> SockAddr -> NetCryptoSession -> STM () |
623 | addSessionToMapIfNotThere sessions addrRaw netCryptoSession = do | 638 | addSessionToMapIfNotThere sessions addrRaw netCryptoSession = do |