on master help sign in
self-controlling Receiver without TBQueue.
commit9a881a10e6af67d8f5e35cf6190d1a98f96e3113 authorKazu Yamamoto <kazu@iij.ad.jp> dateThu 17 Dec 2015, 16:06 (11 years ago) parent8f78022
1 file changed+9−3
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+9−3
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+9−3
@@ -9,6 +9,7 @@ module Network.Wai.Handler.Warp.HTTP2.Receiver (frameReceiver) where
99#if __GLASGOW_HASKELL__ < 709
1010import Control.Applicative
1111#endif
12+import Control.Concurrent
1213import Control.Concurrent.STM
1314import qualified Control.Exception as E
1415import Control.Monad (when, unless, void)
@@ -27,7 +28,7 @@ import Network.Wai.Handler.Warp.Types
2728----------------------------------------------------------------
2829
2930frameReceiver :: Context -> MkReq -> (BufSize -> IO ByteString) -> IO ()
30−frameReceiver ctx mkreq recvN = loop `E.catch` sendGoaway
31+frameReceiver ctx mkreq recvN = loop 0 `E.catch` sendGoaway
3132 where
3233 Context{ http2settings
3334 , streamTable
@@ -48,13 +49,18 @@ frameReceiver ctx mkreq recvN = loop `E.catch` sendGoaway
4849 let !frame = resetFrame err sid
4950 enqueueControl outputQ 0 $ OFrame frame
5051
51− loop = do
52+ loop :: Int -> IO ()
53+ loop !n
54+ | n == 6 = do
55+ yield
56+ loop 0
57+ | otherwise = do
5258 hd <- recvN frameHeaderLength
5359 if BS.null hd then
5460 enqueueControl outputQ 0 OFinish
5561 else do
5662 cont <- processStreamGuardingError $ decodeFrameHeader hd
57− when cont loop
63+ when cont $ loop (n + 1)
5864
5965 processStreamGuardingError (_, FrameHeader{streamId})
6066 | isResponse streamId = E.throwIO $ ConnectionError ProtocolError "stream id should be odd"