on master help sign in
Timeout manager kills threads, does not close sockets
commit199f8f5e98a3f5a79a7f253400cc06d520ec5b02 authorMichael Snoyman <michael@snoyman.com> dateFri 11 Feb 2011, 10:01 (16 years ago) parent59d9cc5
3 files changed+9−3
Network/Wai/Handler/Warp.hs+1−1 Timeout.hs+7−1 warp.cabal+1−1
Network/Wai/Handler/Warp.hs+1−1
@@ -150,7 +150,7 @@ serveConnections' set app socket = do
150150 forever $ do
151151 (conn, sa) <- accept socket
152152 _ <- forkIO $ do
153− th <- T.register tm $ sClose conn
153+ th <- T.registerKillThread tm
154154 serveConnection th onE port app conn sa
155155 T.cancel th
156156 return ()
Timeout.hs+7−1
@@ -3,6 +3,7 @@ module Timeout
33 , Handle
44 , initialize
55 , register
6+ , registerKillThread
67 , tickle
78 , pause
89 , resume
@@ -10,7 +11,7 @@ module Timeout
1011 ) where
1112
1213import qualified Data.IORef as I
13−import Control.Concurrent (forkIO, threadDelay)
14+import Control.Concurrent (forkIO, threadDelay, myThreadId, killThread)
1415import Control.Monad (forever)
1516import qualified Control.Exception as E
1617
@@ -52,6 +53,11 @@ register (Manager ref) onTimeout = do
5253 I.atomicModifyIORef ref (\x -> (h : x, ()))
5354 return h
5455
56+registerKillThread :: Manager -> IO Handle
57+registerKillThread m = do
58+ tid <- myThreadId
59+ register m $ killThread tid
60+
5561tickle, pause, resume, cancel :: Handle -> IO ()
5662tickle (Handle _ iactive) = I.writeIORef iactive Active
5763pause (Handle _ iactive) = I.writeIORef iactive Paused
warp.cabal+1−1
@@ -1,5 +1,5 @@
11Name: warp
2−Version: 0.3.2
2+Version: 0.3.2.1
33Synopsis: A fast, light-weight web server for WAI applications.
44License: BSD3
55License-file: LICENSE