summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-05-29 09:00:40 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-05-29 09:00:40 +0000
commit72a01c731b2dc8c82f14161731575d00c71905aa (patch)
tree8681263cef02d6936ca17edb3cec5afa8654a471 /src
parent897f9a5e39b8356133323024d84891cc3817ed6a (diff)
handle empty case with ncOutgoingQueue
Diffstat (limited to 'src')
-rw-r--r--src/Data/PacketQueue.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Data/PacketQueue.hs b/src/Data/PacketQueue.hs
index 144c8de0..4770d4a9 100644
--- a/src/Data/PacketQueue.hs
+++ b/src/Data/PacketQueue.hs
@@ -193,7 +193,11 @@ tryAppendQueueOutgoing :: STM extra -> PacketOutQueue extra msg wire fromwire ->
193tryAppendQueueOutgoing getExtra q@(PacketOutQueue { pktoInPQ, pktoOutPQ, pktoPacketNo, pktoToWireIO, pktoToWire }) msg = do 193tryAppendQueueOutgoing getExtra q@(PacketOutQueue { pktoInPQ, pktoOutPQ, pktoPacketNo, pktoToWireIO, pktoToWire }) msg = do
194 be <- readTVar (buffend pktoOutPQ) 194 be <- readTVar (buffend pktoOutPQ)
195 let i = be `mod` (qsize pktoOutPQ) 195 let i = be `mod` (qsize pktoOutPQ)
196 mbPkt <- readArray (pktq pktoOutPQ) i 196 let arrayEmpty ar = do (lowB,highB) <- getBounds ar
197 return (lowB > highB )
198 mbPkt <- do emp <- arrayEmpty (pktq pktoOutPQ)
199 if emp then return Nothing
200 else readArray (pktq pktoOutPQ) i
197 pktno <- readTVar pktoPacketNo 201 pktno <- readTVar pktoPacketNo
198 nextno <- readTVar (seqno pktoInPQ) 202 nextno <- readTVar (seqno pktoInPQ)
199 mbWire <- pktoToWire getExtra nextno be pktno msg 203 mbWire <- pktoToWire getExtra nextno be pktno msg