@@ -1,5 +1,6 @@
1−{-# LANGUAGE RecordWildCards, OverloadedStrings #-}
1+{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE BangPatterns, CPP #-}
2{-# LANGUAGE BangPatterns, CPP #-}
3+{-# LANGUAGE RecordWildCards, NamedFieldPuns #-}
4module Network.Wai.Handler.Warp.HTTP2.Sender (frameSender) where
5module Network.Wai.Handler.Warp.HTTP2.Sender (frameSender) where
@@ -37,7 +38,10 @@ import System.Posix.Types
37----------------------------------------------------------------
38----------------------------------------------------------------
39unlessClosed :: Context -> Connection -> Stream -> IO () -> IO ()
40unlessClosed :: Context -> Connection -> Stream -> IO () -> IO ()
42+ Connection{connSendAll}
43+ strm@Stream{streamState,streamNumber}
40−unlessClosed ctx Connection{..} strm@Stream{..} body = E.handle resetStream $ do
44+ body = E.handle resetStream $ do
41 state <- readIORef streamState
45 state <- readIORef streamState
42 unless (isClosed state) body
46 unless (isClosed state) body
@@ -64,7 +68,9 @@ checkWindowSize connWindow strmWindow outQ out pri body = do
64 body (min cw sw)
68 body (min cw sw)
66frameSender :: Context -> Connection -> InternalInfo -> S.Settings -> IO ()
70frameSender :: 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}
68 connSendAll initialFrame
74 connSendAll initialFrame
69 loop `E.finally` putMVar wait ()
75 loop `E.finally` putMVar wait ()
@@ -172,14 +178,16 @@ ResponseRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) Response
174fillResponseBodyGetNext :: Connection -> InternalInfo -> Int -> WindowSize -> Response -> IO Next
180fillResponseBodyGetNext :: Connection -> InternalInfo -> Int -> WindowSize -> Response -> IO Next
181+fillResponseBodyGetNext Connection{connWriteBuffer,connBufferSize}
175−fillResponseBodyGetNext Connection{..} _ off lim (ResponseBuilder _ _ bb) = do
182+ _ off lim (ResponseBuilder _ _ bb) = do
176 let datBuf = connWriteBuffer `plusPtr` off
183 let datBuf = connWriteBuffer `plusPtr` off
177 room = min (connBufferSize - off) lim
184 room = min (connBufferSize - off) lim
178 (len, signal) <- B.runBuilder bb datBuf room
185 (len, signal) <- B.runBuilder bb datBuf room
179 return $ nextForBuilder connWriteBuffer connBufferSize len signal
186 return $ nextForBuilder connWriteBuffer connBufferSize len signal
181#ifdef WINDOWS
188#ifdef WINDOWS
189+fillResponseBodyGetNext Connection{connWriteBuffer,connBufferSize}
182−fillResponseBodyGetNext Connection{..} _ off lim (ResponseFile _ _ path mpart) = do
190+ _ off lim (ResponseFile _ _ path mpart) = do
183 let datBuf = connWriteBuffer `plusPtr` off
191 let datBuf = connWriteBuffer `plusPtr` off
184 room = min (connBufferSize - off) lim
192 room = min (connBufferSize - off) lim
185 (start, bytes) <- fileStartEnd path mpart
193 (start, bytes) <- fileStartEnd path mpart
@@ -190,7 +198,8 @@ fillResponseBodyGetNext Connection{..} _ off lim (ResponseFile _ _ path mpart) =
190 let bytes' = bytes - fromIntegral len
198 let bytes' = bytes - fromIntegral len
191 return $ nextForFile len connWriteBuffer connBufferSize h bytes' (return ())
199 return $ nextForFile len connWriteBuffer connBufferSize h bytes' (return ())
201+fillResponseBodyGetNext Connection{connWriteBuffer,connBufferSize}
193−fillResponseBodyGetNext Connection{..} ii off lim (ResponseFile _ _ path mpart) = do
202+ ii off lim (ResponseFile _ _ path mpart) = do
194 let Just fdcache = fdCacher ii
203 let Just fdcache = fdCacher ii
195 (fd, refresh) <- getFd fdcache path
204 (fd, refresh) <- getFd fdcache path
196 let datBuf = connWriteBuffer `plusPtr` off
205 let datBuf = connWriteBuffer `plusPtr` off
@@ -214,7 +223,8 @@ fileStartEnd _ (Just part) =
214----------------------------------------------------------------
223----------------------------------------------------------------
216fillStreamBodyGetNext :: Connection -> Int -> WindowSize -> TBQueue Sequence -> TVar Sync -> IO Next
225fillStreamBodyGetNext :: 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
218 let datBuf = connWriteBuffer `plusPtr` off
228 let datBuf = connWriteBuffer `plusPtr` off
219 room = min (connBufferSize - off) lim
229 room = min (connBufferSize - off) lim
220 (leftover, cont, len) <- runStreamBuilder datBuf room sq
230 (leftover, cont, len) <- runStreamBuilder datBuf room sq