summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjim@bo <jim@bo>2018-06-24 00:27:49 -0400
committerjim@bo <jim@bo>2018-06-24 00:27:49 -0400
commitb88601d78aeae15c75aa584afa51d1666595b7d8 (patch)
treef3768704d472cd4b06e82f28e1354edd88685be3 /src
parentcd18190b8f66b5480dfbafebb52f201094bab233 (diff)
fix index-bounds error & improve efficiency
Diffstat (limited to 'src')
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index d8ba19eb..82aa8f12 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -623,13 +623,19 @@ freshCryptoSession sessions
623 lossyEsc <- newTVar $ U.listArray (0,255) [0 .. 255] 623 lossyEsc <- newTVar $ U.listArray (0,255) [0 .. 255]
624 losslessEsc <- newTVar $ U.listArray (0,255) [0 .. 255] 624 losslessEsc <- newTVar $ U.listArray (0,255) [0 .. 255]
625 outHooks <- emptySTMRangeMap 625 outHooks <- emptySTMRangeMap
626 mapM_ ($ outHooks) -- TODO: combine into larger ranges for faster lookup 626 let doNothingHook crypto session msg = return (Left "unsupported")
627 [ insertWhereItGoes (A.listArray (2,2) [sendKillHook]) 627 assignHook 2 = (2,sendKillHook)
628 , insertWhereItGoes (A.listArray (16,16) [sendLossless{-Ping-}]) 628 assignHook 16 = (16,sendLossless{-Ping-})
629 , insertWhereItGoes (A.listArray (24,25) [sendOnlineHook,sendLossless{-Offline-}]) 629 assignHook 24 = (24,sendOnlineHook)
630 , insertWhereItGoes (A.listArray (48,51) [sendNickHook,sendStatusMsgHook,sendStatusHook,sendTypingHook]) 630 assignHook 25 = (25,sendLossless{-Offline-})
631 , insertWhereItGoes (A.listArray (63,64) [sendMessageHook, sendMessageHook]) 631 assignHook 48 = (48,sendNickHook)
632 ] 632 assignHook 49 = (49,sendStatusMsgHook)
633 assignHook 50 = (50,sendStatusHook)
634 assignHook 51 = (51,sendTypingHook)
635 assignHook 63 = (63,sendMessageHook)
636 assignHook 64 = (64,sendMessageHook{-ACTION-})
637 assignHook other = (other,doNothingHook)
638 insertArrayAt outHooks 0 (A.array (0,64) (map assignHook [0..64]))
633 return (idmap,lossyEsc,losslessEsc,outHooks) 639 return (idmap,lossyEsc,losslessEsc,outHooks)
634 ncView0 <- newTVar (sessionView sessions) 640 ncView0 <- newTVar (sessionView sessions)
635 pktq <- PQ.new (inboundQueueCapacity sessions) 0 641 pktq <- PQ.new (inboundQueueCapacity sessions) 0