@@ -18,6 +18,7 @@ import Network (sClose, Socket)
18import Network.Socket (accept, SockAddr)
18import Network.Socket (accept, SockAddr)
19import qualified Network.Socket.ByteString as Sock
19import qualified Network.Socket.ByteString as Sock
20import Network.Wai
20import Network.Wai
21+import Network.Wai.Internal (ResponseReceived (ResponseReceived))
21import qualified Network.Wai.Handler.Warp.Date as D
22import qualified Network.Wai.Handler.Warp.Date as D
22import qualified Network.Wai.Handler.Warp.FdCache as F
23import qualified Network.Wai.Handler.Warp.FdCache as F
23import Network.Wai.Handler.Warp.Buffer
24import Network.Wai.Handler.Warp.Buffer
@@ -255,13 +256,17 @@ serveConnection conn ii addr isSecure' settings app = do
255 -- In the event that some scarce resource was acquired during
256 -- In the event that some scarce resource was acquired during
256 -- creating the request, we need to make sure that we don't get
257 -- creating the request, we need to make sure that we don't get
257 -- an async exception before calling the ResponseSource.
258 -- an async exception before calling the ResponseSource.
259+ keepAliveRef <- newIORef $ error "keepAliveRef not filled"
258− keepAlive <- app req $ \res -> do
260+ _ <- app req $ \res -> do
259 T.resume th
261 T.resume th
260 -- FIXME consider forcing evaluation of the res here to
262 -- FIXME consider forcing evaluation of the res here to
261 -- send more meaningful error messages to the user.
263 -- send more meaningful error messages to the user.
262 -- However, it may affect performance.
264 -- However, it may affect performance.
263 writeIORef istatus False
265 writeIORef istatus False
264− sendResponse conn ii req idxhdr (readSource fromClient) res
266+ keepAlive <- sendResponse conn ii req idxhdr (readSource fromClient) res
267+ writeIORef keepAliveRef keepAlive
268+ return ResponseReceived
269+ keepAlive <- readIORef keepAliveRef
266 -- We just send a Response and it takes a time to
271 -- We just send a Response and it takes a time to
267 -- receive a Request again. If we immediately call recv,
272 -- receive a Request again. If we immediately call recv,