@@ -36,14 +36,14 @@ import Network.Wai.Internal (Response(..), ResponseReceived(..), ResponseReceive
3636-- | The wai definition is 'type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived'.
3737-- This type implements the second argument (Response -> IO ResponseReceived)
3838-- with extra arguments.
39−type Responder = ThreadContinue -> T.Handle -> Stream -> Priority -> Request ->
39+type Responder = ThreadContinue -> T.Handle -> Stream -> Request ->
4040 Response -> IO ResponseReceived
4141
4242-- | This function is passed to workers.
4343-- They also pass 'Response's from 'Application's to this function.
4444-- This function enqueues commands for the HTTP/2 sender.
4545response :: Context -> Manager -> Responder
46−response Context{outputQ} mgr tconf th strm pri req rsp = do
46+response Context{outputQ} mgr tconf th strm req rsp = do
4747 case rsp of
4848 ResponseStream _ _ strmbdy -> do
4949 -- We must not exit this WAI application.
@@ -59,6 +59,7 @@ response Context{outputQ} mgr tconf th strm pri req rsp = do
5959 -- So, let's serialize 'Builder' with a designated queue.
6060 sq <- newTBQueueIO 10 -- fixme: hard coding: 10
6161 tvar <- newTVarIO SyncNone
62+ pri <- readIORef $ streamPriority strm
6263 enqueue outputQ (OResponse strm rsp (Persist sq tvar)) pri
6364 let push b = do
6465 atomically $ writeTBQueue sq (SBuilder b)
@@ -67,13 +68,14 @@ response Context{outputQ} mgr tconf th strm pri req rsp = do
6768 -- Since we must not enqueue an empty queue to the priority
6869 -- queue, we spawn a thread to ensure that the designated
6970 -- queue is not empty.
70− void $ forkIO $ waiter tvar sq (enqueue outputQ) strm pri
71+ void $ forkIO $ waiter tvar sq (enqueue outputQ) strm
7172 strmbdy push flush
7273 atomically $ writeTBQueue sq SFinish
7374 _ -> do
7475 setThreadContinue tconf True
7576 let hasBody = requestMethod req /= H.methodHead
7677 && R.hasBody (responseStatus rsp)
78+ pri <- readIORef $ streamPriority strm
7779 enqueue outputQ (OResponse strm rsp (Oneshot hasBody)) pri
7880 return ResponseReceived
7981
@@ -93,11 +95,11 @@ worker ctx@Context{inputQ,outputQ} set tm app responder = do
9395 setThreadContinue tcont True
9496 ex <- E.try $ do
9597 T.pause th
96− Input strm req pri <- atomically $ readTQueue inputQ
98+ Input strm req <- atomically $ readTQueue inputQ
9799 setStreamInfo sinfo strm req
98100 T.resume th
99101 T.tickle th
100− app req $ responder tcont th strm pri req
102+ app req $ responder tcont th strm req
101103 cont1 <- case ex of
102104 Right ResponseReceived -> return True
103105 Left e@(SomeException _)
@@ -127,9 +129,9 @@ worker ctx@Context{inputQ,outputQ} set tm app responder = do
127129 clearStreamInfo sinfo
128130
129131waiter :: TVar Sync -> TBQueue Sequence
130− -> (Output -> Priority -> IO ()) -> Stream -> Priority
132+ -> (Output -> Priority -> IO ()) -> Stream
131133 -> IO ()
132−waiter tvar sq enq strm pri = do
134+waiter tvar sq enq strm = do
133135 mx <- atomically $ do
134136 mout <- readTVar tvar
135137 case mout of
@@ -144,8 +146,9 @@ waiter tvar sq enq strm pri = do
144146 atomically $ do
145147 isEmpty <- isEmptyTBQueue sq
146148 when isEmpty retry
149+ pri <- readIORef $ streamPriority strm
147150 enq (ONext strm next) pri
148− waiter tvar sq enq strm pri
151+ waiter tvar sq enq strm
149152
150153----------------------------------------------------------------
151154