From 77e04de54de671a9bef887350c48debf2ac153f2 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Thu, 21 Nov 2024 16:18:35 +0900 Subject: [PATCH] using withHandleKillThread in Warp --- warp/Network/Wai/Handler/Warp/HTTP2.hs | 4 ---- warp/Network/Wai/Handler/Warp/Run.hs | 5 +---- warp/warp.cabal | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/warp/Network/Wai/Handler/Warp/HTTP2.hs b/warp/Network/Wai/Handler/Warp/HTTP2.hs index 3e473354a..e488279c9 100644 --- a/warp/Network/Wai/Handler/Warp/HTTP2.hs +++ b/warp/Network/Wai/Handler/Warp/HTTP2.hs @@ -106,10 +106,6 @@ http2server label settings ii transport addr app h2req0 aux0 response = do logResponse req st msiz mapM_ (logPushPromise req) pps Left e - -- killed by the local worker manager - | 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 diff --git a/warp/Network/Wai/Handler/Warp/Run.hs b/warp/Network/Wai/Handler/Warp/Run.hs index 98d8a63c9..41850811c 100644 --- a/warp/Network/Wai/Handler/Warp/Run.hs +++ b/warp/Network/Wai/Handler/Warp/Run.hs @@ -355,7 +355,7 @@ fork set mkConn addr app counter ii = settingsFork set $ \unmask -> do -- We need to register a timeout handler for this thread, and -- cancel that handler as soon as we exit. - serve unmask (conn, transport) = E.bracket register cancel $ \th -> do + serve unmask (conn, transport) = T.withHandleKillThread (timeoutManager ii) (return ()) $ \th -> do -- We now have fully registered a connection close handler in -- the case of all exceptions, so it is safe to once again -- allow async exceptions. @@ -368,9 +368,6 @@ fork set mkConn addr app counter ii = settingsFork set $ \unmask -> do -- Actually serve this connection. bracket with closeConn -- above ensures the connection is closed. when goingon $ serveConnection conn ii th addr transport set app - where - register = T.registerKillThread (timeoutManager ii) (return ()) - cancel = T.cancel onOpen adr = increase counter >> settingsOnOpen set adr onClose adr _ = decrease counter >> settingsOnClose set adr diff --git a/warp/warp.cabal b/warp/warp.cabal index ab0ba0642..c0f5d881a 100644 --- a/warp/warp.cabal +++ b/warp/warp.cabal @@ -102,7 +102,7 @@ library stm >=2.3, streaming-commons >=0.1.10, text, - time-manager >=0.1 && <0.2, + time-manager >=0.1.3 && <0.2, vault >=0.3, wai >=3.2.4 && <3.3, word8