@@ -4,6 +4,7 @@
4{-# LANGUAGE CPP #-}
4{-# LANGUAGE CPP #-}
5{-# LANGUAGE ScopedTypeVariables #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE BangPatterns #-}
8module Network.Wai.Handler.Warp.HTTP2.Worker (
9module Network.Wai.Handler.Warp.HTTP2.Worker (
@@ -62,15 +63,16 @@ response ii settings Context{outputQ} mgr tconf th strm req rsp
62 ResponseRaw _ _ -> error "HTTP/2 does not support ResponseRaw"
63 ResponseRaw _ _ -> error "HTTP/2 does not support ResponseRaw"
63 | otherwise = responseNoBody s0 hs0
64 | otherwise = responseNoBody s0 hs0
65− isHead = requestMethod req == H.methodHead
66+ !isHead = requestMethod req == H.methodHead
66− s0 = responseStatus rsp
67+ !s0 = responseStatus rsp
67− hs0 = responseHeaders rsp
68+ !hs0 = responseHeaders rsp
68− logger = S.settingsLogger settings req
69+ !logger = S.settingsLogger settings req
70 responseNoBody s hs = responseBuilderBody s hs mempty
71 responseNoBody s hs = responseBuilderBody s hs mempty
72 responseBuilderBody s hs bdy = do
73 responseBuilderBody s hs bdy = do
73− writeIORef (streamLogger strm) (logger s Nothing)
74+ let !logact = logger s Nothing
75+ writeIORef (streamLogger strm) logact
74 setThreadContinue tconf True
76 setThreadContinue tconf True
75 let rsp' = ResponseBuilder s hs bdy
77 let rsp' = ResponseBuilder s hs bdy
76 out = OResponse strm rsp' (Oneshot True)
78 out = OResponse strm rsp' (Oneshot True)
@@ -90,7 +92,8 @@ response ii settings Context{outputQ} mgr tconf th strm req rsp
90 responseFile2XX s hs path mpart
92 responseFile2XX s hs path mpart
91 | isHead = responseNoBody s hs
93 | isHead = responseNoBody s hs
92 | otherwise = do
94 | otherwise = do
93− writeIORef (streamLogger strm) (logger s (filePartByteCount <$> mpart))
95+ let !logact = logger s (filePartByteCount <$> mpart)
96+ writeIORef (streamLogger strm) logact
94 setThreadContinue tconf True
97 setThreadContinue tconf True
95 let rsp' = ResponseFile s hs path mpart
98 let rsp' = ResponseFile s hs path mpart
96 out = OResponse strm rsp' (Oneshot True)
99 out = OResponse strm rsp' (Oneshot True)
@@ -104,7 +107,8 @@ response ii settings Context{outputQ} mgr tconf th strm req rsp
104 body = byteString "File not found"
107 body = byteString "File not found"
106 responseStreaming strmbdy = do
109 responseStreaming strmbdy = do
107− writeIORef (streamLogger strm) (logger s0 Nothing)
110+ let !logact = logger s0 Nothing
111+ writeIORef (streamLogger strm) logact
108 -- We must not exit this WAI application.
112 -- We must not exit this WAI application.
109 -- If the application exits, streaming would be also closed.
113 -- If the application exits, streaming would be also closed.
110 -- So, this work occupies this thread.
114 -- So, this work occupies this thread.