@@ -41,17 +41,17 @@ frameReceiver ctx mkreq recvN = loop `E.catch` sendGoaway
4141 | Just (ConnectionError err msg) <- E.fromException e = do
4242 csid <- readIORef currentStreamId
4343 let frame = goawayFrame csid err msg
44− enqueue outputQ (OGoaway frame) highestPriority
44+ enqueue outputQ 0 controlPriority $ OGoaway frame
4545 | otherwise = return ()
4646
4747 sendReset err sid = do
4848 let frame = resetFrame err sid
49− enqueue outputQ (OFrame frame) highestPriority
49+ enqueue outputQ 0 controlPriority $ OFrame frame
5050
5151 loop = do
5252 hd <- recvN frameHeaderLength
5353 if BS.null hd then
54− enqueue outputQ OFinish highestPriority
54+ enqueue outputQ 0 controlPriority OFinish
5555 else do
5656 cont <- processStreamGuardingError $ decodeFrameHeader hd
5757 when cont loop
@@ -186,7 +186,7 @@ control FrameSettings header@FrameHeader{flags} bs Context{http2settings, output
186186 unless (testAck flags) $ do
187187 modifyIORef http2settings $ \old -> updateSettings old alist
188188 let frame = settingsFrame setAck []
189− enqueue outputQ (OSettings frame alist) highestPriority
189+ enqueue outputQ 0 controlPriority $ OSettings frame alist
190190 return True
191191
192192control FramePing FrameHeader{flags} bs Context{outputQ} =
@@ -194,11 +194,11 @@ control FramePing FrameHeader{flags} bs Context{outputQ} =
194194 E.throwIO $ ConnectionError ProtocolError "the ack flag of this ping frame must not be set"
195195 else do
196196 let frame = pingFrame bs
197− enqueue outputQ (OFrame frame) defaultPriority
197+ enqueue outputQ 0 controlPriority $ OFrame frame
198198 return True
199199
200200control FrameGoAway _ _ Context{outputQ} = do
201− enqueue outputQ OFinish highestPriority
201+ enqueue outputQ 0 controlPriority OFinish
202202 return False
203203
204204control FrameWindowUpdate header bs Context{connectionWindow} = do
@@ -271,7 +271,7 @@ stream FrameData
271271 let frame1 = windowUpdateFrame 0 payloadLength
272272 frame2 = windowUpdateFrame streamNumber payloadLength
273273 frame = frame1 `BS.append` frame2
274− enqueue outputQ (OFrame frame) highestPriority
274+ enqueue outputQ 0 controlPriority $ OFrame frame
275275 atomically $ writeTQueue q body
276276 if endOfStream then do
277277 mcl <- readIORef streamContentLength
@@ -310,24 +310,25 @@ stream FrameWindowUpdate header@FrameHeader{streamId} bs _ s Stream{streamWindow
310310 atomically $ writeTVar streamWindow w
311311 return s
312312
313−stream FrameRSTStream header bs _ _ strm = do
313+stream FrameRSTStream header bs ctx _ strm = do
314314 RSTStreamFrame e <- guardIt $ decoderstStreamFrame header bs
315315 let cc = Reset e
316− closed strm cc
316+ closed strm cc ctx
317317 return $ Closed cc -- will be written to streamState again
318318
319319stream FramePriority header bs Context{outputQ} s Stream{streamNumber,streamPriority} = do
320− PriorityFrame p <- guardIt $ decodePriorityFrame header bs
321− checkPriority p streamNumber
320+ PriorityFrame newp <- guardIt $ decodePriorityFrame header bs
321+ checkPriority newp streamNumber
322322 -- checkme: this should be tested
323− -- fixme: This works well when the priority gets lower because
324− -- the old higher priority value comes out from the queue quickly
325− -- and the new lower priority is used when enqueuing again.
326− -- But when the priority get higher, it takes time to use the new
327− -- priority.
328− writeIORef streamPriority p
329− -- checkme: this should be tested
330− when (isIdle s) $ prepare outputQ streamNumber p
323+ oldp <- readIORef streamPriority
324+ writeIORef streamPriority newp
325+ if isIdle s then
326+ prepare outputQ streamNumber newp
327+ else do
328+ mx <- delete outputQ streamNumber oldp
329+ case mx of
330+ Nothing -> return ()
331+ Just x -> enqueue outputQ streamNumber newp x
331332 return s
332333
333334-- this ordering is important