@@ -1,5 +1,6 @@
1−{-# LANGUAGE RecordWildCards, OverloadedStrings #-}
1+{-# LANGUAGE OverloadedStrings #-}
22{-# LANGUAGE BangPatterns, CPP #-}
3+{-# LANGUAGE RecordWildCards, NamedFieldPuns #-}
34
45module Network.Wai.Handler.Warp.HTTP2.Sender (frameSender) where
56
@@ -37,7 +38,10 @@ import System.Posix.Types
3738----------------------------------------------------------------
3839
3940unlessClosed :: Context -> Connection -> Stream -> IO () -> IO ()
40−unlessClosed ctx Connection{..} strm@Stream{..} body = E.handle resetStream $ do
41+unlessClosed ctx
42+ Connection{connSendAll}
43+ strm@Stream{streamState,streamNumber}
44+ body = E.handle resetStream $ do
4145 state <- readIORef streamState
4246 unless (isClosed state) body
4347 where
@@ -64,7 +68,9 @@ checkWindowSize connWindow strmWindow outQ out pri body = do
6468 body (min cw sw)
6569
6670frameSender :: Context -> Connection -> InternalInfo -> S.Settings -> IO ()
67−frameSender ctx@Context{..} conn@Connection{..} ii settings = do
71+frameSender ctx@Context{outputQ,connectionWindow,wait}
72+ conn@Connection{connWriteBuffer,connBufferSize,connSendAll}
73+ ii settings = do
6874 connSendAll initialFrame
6975 loop `E.finally` putMVar wait ()
7076 where
@@ -172,14 +178,16 @@ ResponseRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) Response
172178-}
173179
174180fillResponseBodyGetNext :: Connection -> InternalInfo -> Int -> WindowSize -> Response -> IO Next
175−fillResponseBodyGetNext Connection{..} _ off lim (ResponseBuilder _ _ bb) = do
181+fillResponseBodyGetNext Connection{connWriteBuffer,connBufferSize}
182+ _ off lim (ResponseBuilder _ _ bb) = do
176183 let datBuf = connWriteBuffer `plusPtr` off
177184 room = min (connBufferSize - off) lim
178185 (len, signal) <- B.runBuilder bb datBuf room
179186 return $ nextForBuilder connWriteBuffer connBufferSize len signal
180187
181188#ifdef WINDOWS
182−fillResponseBodyGetNext Connection{..} _ off lim (ResponseFile _ _ path mpart) = do
189+fillResponseBodyGetNext Connection{connWriteBuffer,connBufferSize}
190+ _ off lim (ResponseFile _ _ path mpart) = do
183191 let datBuf = connWriteBuffer `plusPtr` off
184192 room = min (connBufferSize - off) lim
185193 (start, bytes) <- fileStartEnd path mpart
@@ -190,7 +198,8 @@ fillResponseBodyGetNext Connection{..} _ off lim (ResponseFile _ _ path mpart) =
190198 let bytes' = bytes - fromIntegral len
191199 return $ nextForFile len connWriteBuffer connBufferSize h bytes' (return ())
192200#else
193−fillResponseBodyGetNext Connection{..} ii off lim (ResponseFile _ _ path mpart) = do
201+fillResponseBodyGetNext Connection{connWriteBuffer,connBufferSize}
202+ ii off lim (ResponseFile _ _ path mpart) = do
194203 let Just fdcache = fdCacher ii
195204 (fd, refresh) <- getFd fdcache path
196205 let datBuf = connWriteBuffer `plusPtr` off
@@ -214,7 +223,8 @@ fileStartEnd _ (Just part) =
214223----------------------------------------------------------------
215224
216225fillStreamBodyGetNext :: Connection -> Int -> WindowSize -> TBQueue Sequence -> TVar Sync -> IO Next
217−fillStreamBodyGetNext Connection{..} off lim sq tvar = do
226+fillStreamBodyGetNext Connection{connWriteBuffer,connBufferSize}
227+ off lim sq tvar = do
218228 let datBuf = connWriteBuffer `plusPtr` off
219229 room = min (connBufferSize - off) lim
220230 (leftover, cont, len) <- runStreamBuilder datBuf room sq