on master help sign in
Merge fix for event source.
commit78365c210e5a025853bdf2b6c46661d03b71297a authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 8 Jan 2020, 20:29 (7 years ago) parent3a27649ceea765
2 files changed+12−4
warp/Network/Wai/Handler/Warp/HTTP2.hs+3−3 warp/Network/Wai/Handler/Warp/Run.hs+9−1
warp/Network/Wai/Handler/Warp/HTTP2.hs+3−3
@@ -24,14 +24,14 @@ import Network.Wai.Handler.Warp.Types
2424
2525----------------------------------------------------------------
2626
27−http2 :: Connection -> Transport -> InternalInfo -> SockAddr -> S.Settings -> (BufSize -> IO ByteString) -> Application -> IO ()
28−http2 conn transport ii addr settings readN app =
27+http2 :: Connection -> Transport -> InternalInfo -> SockAddr -> S.Settings -> (BufSize -> IO ByteString) -> (ByteString -> IO ()) -> Application -> IO ()
28+http2 conn transport ii addr settings readN send app =
2929 H2.run conf http2server
3030 where
3131 conf = H2.Config {
3232 confWriteBuffer = connWriteBuffer conn
3333 , confBufferSize = connBufferSize conn
34− , confSendAll = connSendAll conn
34+ , confSendAll = send
3535 , confReadN = readN
3636 , confPositionReadMaker = pReadMaker ii
3737 }
warp/Network/Wai/Handler/Warp/Run.hs+9−1
@@ -350,11 +350,19 @@ serveConnection conn ii th origAddr transport settings app = do
350350 istatus <- newIORef False
351351 if settingsHTTP2Enabled settings && h2 then do
352352 rawRecvN <- makeReceiveN bs (connRecv conn) (connRecvBuf conn)
353+ -- This thread becomes the sender in http2 library.
354+ -- In the case of event source, one request comes and one
355+ -- worker gets busy. But it is likely that the receiver does
356+ -- not receive any data at all while the sender is sending
357+ -- output data from the worker. It's not good enough to tickle
358+ -- the time handler in the receiver only. So, we should tickle
359+ -- the time handler in both the receiver and the sender.
353360 let recvN = wrappedRecvN th istatus (settingsSlowlorisSize settings) rawRecvN
361+ sendBS x = connSendAll conn x >> T.tickle th
354362 -- fixme: origAddr
355363 checkTLS
356364 setConnHTTP2 conn True
357− http2 conn transport ii origAddr settings recvN app
365+ http2 conn transport ii origAddr settings recvN sendBS app
358366 else do
359367 src <- mkSource (wrappedRecv conn th istatus (settingsSlowlorisSize settings))
360368 writeIORef istatus True