warp 1.3.9 → 1.3.9.1
raw patch · 2 files changed
+16/−5 lines, 2 files
Files
- Network/Wai/Handler/Warp/FdCache.hs +15/−4
- warp.cabal +1/−1
Network/Wai/Handler/Warp/FdCache.hs view
@@ -8,10 +8,12 @@ import Control.Applicative ((<$>), (<*>)) import Control.Concurrent+import Control.Exception (mask_) import Control.Monad import Data.Hashable import Data.IORef import Network.Wai.Handler.Warp.MultiMap+import System.Mem.Weak (addFinalizer) import System.Posix.IO import System.Posix.Types @@ -79,15 +81,24 @@ initialize :: Int -> IO MutableFdCache initialize duration = do mfc <- newMutableFdCache- void . forkIO $ loop mfc+ tid <- forkIO $ loop mfc+ addFinalizer mfc $ terminate mfc tid return mfc where loop mfc = do- old <- swapWithNew mfc- new <- pruneWith old prune- update mfc (merge new)+ mask_ $ do+ old <- swapWithNew mfc+ new <- pruneWith old prune+ update mfc (merge new) threadDelay duration loop mfc++terminate :: MutableFdCache -> ThreadId -> IO ()+terminate (MutableFdCache icache) tid = do+ killThread tid+ readIORef icache >>= mapM_ go . toList+ where+ go (_, FdEntry _ fd _) = closeFd fd prune :: t -> Some FdEntry -> IO [(t, Some FdEntry)] prune k v@(One (FdEntry _ fd mst)) = status mst >>= prune'
warp.cabal view
@@ -1,5 +1,5 @@ Name: warp-Version: 1.3.9+Version: 1.3.9.1 Synopsis: A fast, light-weight web server for WAI applications. License: MIT License-file: LICENSE