packages feed

warp 3.4.4 → 3.4.5

raw patch · 7 files changed

+32/−9 lines, 7 files

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # ChangeLog for warp +## 3.4.5++* Rethrowing asynchronous exceptions and preventing callsing+  `connClose` twice.+  [#1013](https://github.com/yesodweb/wai/pull/1013)+ ## 3.4.4  * Removing `unliftio`.
Network/Wai/Handler/Warp/HTTP1.hs view
@@ -122,6 +122,7 @@         | Just NoKeepAliveRequest <- fromException e = return ()         -- No valid request         | Just (BadFirstLine _) <- fromException e = return ()+        | isAsyncException e = throwIO e         | otherwise = do             _ <-                 sendErrorResponse@@ -204,6 +205,7 @@         Right ResponseReceived -> return ()         Left (e :: SomeException)             | Just (ExceptionInsideResponseBody e') <- fromException e -> throwIO e'+            | isAsyncException e -> throwIO e             | otherwise -> do                 keepAlive <- sendErrorResponse settings ii conn th istatus req e                 settingsOnException settings (Just req) e
Network/Wai/Handler/Warp/HTTP2.hs view
@@ -110,6 +110,7 @@           | Just E.ThreadKilled  <- E.fromException e -> return ()           -- killed by the local timeout manager           | Just T.TimeoutThread <- E.fromException e -> return ()+          | isAsyncException e -> E.throwIO e           | otherwise -> do             S.settingsOnException settings (Just req) e             let ersp = S.settingsOnExceptionResponse settings e@@ -152,7 +153,7 @@     return bs   where     handler :: E.SomeException -> IO ByteString-    handler _ = return ""+    handler = throughAsync (return "")  -- connClose must not be called here since Run:fork calls it goaway :: Connection -> H2.ErrorCodeId -> ByteString -> IO ()
Network/Wai/Handler/Warp/Imports.hs view
@@ -10,9 +10,12 @@     module Data.Word,     module Data.Maybe,     module Numeric,+    throughAsync,+    isAsyncException, ) where  import Control.Applicative+import Control.Exception import Control.Monad import Data.Bits import Data.ByteString.Internal (ByteString (..))@@ -23,3 +26,14 @@ import Data.Ord import Data.Word import Numeric++isAsyncException :: Exception e => e -> Bool+isAsyncException e =+    case fromException (toException e) of+        Just (SomeAsyncException _) -> True+        Nothing -> False++throughAsync :: IO a -> SomeException -> IO a+throughAsync action (SomeException e)+    | isAsyncException e = throwIO e+    | otherwise = action
Network/Wai/Handler/Warp/Run.hs view
@@ -81,7 +81,7 @@                             else settingsGracefulCloseTimeout1 set                 if tm == 0                     then close s-                    else gracefulClose s tm `E.catch` \(E.SomeException _) -> return ()+                    else gracefulClose s tm `E.catch` throughAsync (return ()) #else             , connClose = close s #endif@@ -179,7 +179,7 @@         (s, sa) <- accept' socket         setSocketCloseOnExec s         -- NoDelay causes an error for AF_UNIX.-        setSocketOption s NoDelay 1 `E.catch` \(E.SomeException _) -> return ()+        setSocketOption s NoDelay 1 `E.catch` throughAsync (return ())         conn <- socketConnection set s         return (conn, sa) @@ -369,7 +369,7 @@                 -- above ensures the connection is closed.                 when goingon $ serveConnection conn ii th addr transport set app       where-        register = T.registerKillThread (timeoutManager ii) (connClose conn)+        register = T.registerKillThread (timeoutManager ii) (return ())         cancel = T.cancel      onOpen adr = increase counter >> settingsOnOpen set adr
Network/Wai/Handler/Warp/Settings.hs view
@@ -9,7 +9,7 @@  module Network.Wai.Handler.Warp.Settings where -import Control.Exception (SomeException, fromException)+import Control.Exception (SomeException(..), fromException, throw) import qualified Data.ByteString.Builder as Builder import qualified Data.ByteString.Char8 as C8 import Data.Streaming.Network (HostPreference)@@ -17,7 +17,7 @@ import qualified Data.Text.IO as TIO import Data.Version (showVersion) import GHC.IO (IO (IO), unsafeUnmask)-import GHC.IO.Exception (AsyncException (ThreadKilled), IOErrorType (..))+import GHC.IO.Exception (IOErrorType (..)) import GHC.Prim (fork#) import qualified Network.HTTP.Types as H import Network.Socket (SockAddr, Socket, accept)@@ -228,12 +228,11 @@ -- Since 2.1.3 defaultShouldDisplayException :: SomeException -> Bool defaultShouldDisplayException se-    | Just ThreadKilled <- fromException se = False     | Just (_ :: InvalidRequest) <- fromException se = False     | Just (ioeGetErrorType -> et) <- fromException se     , et == ResourceVanished || et == InvalidArgument =         False-    | Just TimeoutThread <- fromException se = False+    | isAsyncException se = False     | otherwise = True  -- | Printing an exception to standard error@@ -255,6 +254,7 @@ -- Since 3.2.27 defaultOnExceptionResponse :: SomeException -> Response defaultOnExceptionResponse e+    | isAsyncException e = throw e     | Just PayloadTooLarge <- fromException e =         responseLBS             H.status413
warp.cabal view
@@ -1,6 +1,6 @@ cabal-version:      >=1.10 name:               warp-version:            3.4.4+version:            3.4.5 license:            MIT license-file:       LICENSE maintainer:         michael@snoyman.com