splice 0.4 → 0.5
raw patch · 4 files changed
+26/−12 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.Socket.Splice: tryWith :: (SomeException -> IO a) -> IO a -> IO a
Files
- splice.cabal +2/−2
- src/Network/Socket/Splice.hs +1/−1
- src/Network/Socket/Splice/Internal.hsc +18/−4
- src/System/IO/Splice/Linux.hsc +5/−5
splice.cabal view
@@ -1,6 +1,6 @@ name: splice-version: 0.4-stability: stable on GNU/Linux, experimental on other operating systems+version: 0.5+stability: stable on all operating systems synopsis: Socket to Socket Data Splicing (supports all operating systems) description: A library that implements most efficient socket to socket data transfer loops for proxy servers on each operating system.
src/Network/Socket/Splice.hs view
@@ -18,7 +18,7 @@ -- License : BSD3 -- Maintainer : fusion@corsis.eu -- Stability : stable--- Portability : GHC-only, works on all operating systems+-- Portability : works on all operating systems module Network.Socket.Splice (
src/Network/Socket/Splice/Internal.hsc view
@@ -5,7 +5,7 @@ -- License : BSD3 -- Maintainer : fusion@corsis.eu -- Stability : stable--- Portability : GHC-only, works on all operating systems+-- Portability : works on all operating systems #ifdef LINUX_SPLICE@@ -27,8 +27,12 @@ [Initiate bi-directional continuous data transfer between two sockets:] - > void . forkIO . try_ $ splice 1024 (sourceSocket, _) (targetSocket, _)- > void . forkIO . try_ $ splice 1024 (targetSocket, _) (sourceSocket, _)+ > void . forkIO . tryWith handler $ splice 1024 (sourceSocket, _) (targetSocket, _)+ > void . forkIO . tryWith handler $ splice 1024 (targetSocket, _) (sourceSocket, _)++ where @handler@ is an IO action that would do the necessary clean up –+ such as ensuring the sockets are closed and any resources that may be+ associated with the sockets are properly disposed of. -} splice@@ -36,6 +40,7 @@ , zeroCopy -- * Combinators for Exception Handling+ , tryWith , try_ -- * Implementation Primitives@@ -192,7 +197,7 @@ hSplice len s t = do sb <- hGetBuffering s; hSetBuffering s NoBuffering- tb <- hGetBuffering s; hSetBuffering t NoBuffering+ tb <- hGetBuffering t; hSetBuffering t NoBuffering a <- mallocBytes len :: IO (Ptr Word8) finally@@ -205,6 +210,15 @@ try_ $ hSetBuffering s sb try_ $ hSetBuffering s tb) ++-- | Similar to 'Control.Exception.Base.try' but used when an obvious exception+-- is expected and can be handled easily. Unlike 'finally' exceptions are+-- not rethrown once handled.+tryWith+ :: (SomeException -> IO a) -- ^ exception handler.+ -> IO a -- ^ action to run which can throw /any/ exception.+ -> IO a -- ^ new action where all exceptions are handled by a single.+tryWith h a = try a >>= \r -> case r of Left x -> h x; Right y -> return y -- | Similar to 'Control.Exception.Base.try' but used when an obvious exception
src/System/IO/Splice/Linux.hsc view
@@ -1,6 +1,6 @@-{- | Exposes the GNU\/Linux system call @splice()@.+{- | Exposes the GNU\/Linux system call @splice()@: <http://kerneltrap.org/node/6505>. - /This module is only available (compiled & exposed) on Linux./+ /This module is only available (compiled & exposed) on GNU/\//Linux./ -} -- -- Module : System.IO.Splice.Linux@@ -37,8 +37,8 @@ type ChunkSize = (#type size_t) -- | Moves data between two file descriptors without copying between kernel--- address space and user address space. It transfers up to 'len' bytes of--- data from the file descriptor 'fd_in' to the file descriptor 'fd_out',+-- address space and user address space. It transfers up to @len@ bytes of+-- data from the file descriptor @fd_in@ to the file descriptor @fd_out@, -- where one of the descriptors must refer to a pipe. -- -- 'c_splice' is /NOT/ a loop and needs to be called repeatedly.@@ -64,7 +64,7 @@ -- | More data will be coming in a subsequent 'c_splice'. This is a helpful hint--- when 'fd_out' refers to a socket.+-- when @fd_out@ refers to a socket. sPLICE_F_MORE :: Word sPLICE_F_MORE = (#const "SPLICE_F_MORE")