@@ -230,6 +230,7 @@ processHeap q heap st sv winfo entry sno stopping = loopHeap sno entry
231 loopHeap seqNo ent =
231 loopHeap seqNo ent =
232 case ent of
232 case ent of
233+ AheadEntryNull -> nextHeap seqNo
233 AheadEntryPure a -> do
234 AheadEntryPure a -> do
234 -- Use 'send' directly so that we do not account this in worker
235 -- Use 'send' directly so that we do not account this in worker
235 -- latency as this will not be the real latency.
236 -- latency as this will not be the real latency.
@@ -338,7 +339,12 @@ processWithoutToken q heap st sv winfo m sno = do
338 -- we have already decremented the yield limit for m
339 -- we have already decremented the yield limit for m
339 let stop = do
340 let stop = do
340 liftIO (incrementYieldLimit sv)
341 liftIO (incrementYieldLimit sv)
341− workLoopAhead q heap st sv winfo
342+ -- If the stream stops without yielding anything, and we do not put
343+ -- anything on heap, but if heap was waiting for this seq number
344+ -- then it will keep waiting forever, because we are never going to
345+ -- put it on heap. So we have to put a null entry on heap even when
347+ toHeap sno AheadEntryNull
343 unStream m st stop (singleToHeap sno) (yieldToHeap sno)
349 unStream m st stop (singleToHeap sno) (yieldToHeap sno)