scalable-server 0.2.0 → 0.2.1
raw patch · 2 files changed
+11/−5 lines, 2 files
Files
scalable-server.cabal view
@@ -3,7 +3,7 @@ Synopsis: Library for writing fast/scalable TCP-based services Description: Library for writing fast/scalable TCP-based services -Version: 0.2.0+Version: 0.2.1 License: BSD3 @@ -39,4 +39,5 @@ blaze-builder>=0.3 && <0.4, BoundedChan >=1.0 && < 1.1 + Extensions: ScopedTypeVariables ghc-options: -O2
src/Network/Server/ScalableServer.hs view
@@ -10,7 +10,7 @@ import Network.Socket.Enumerator (enumSocket) import qualified Network.Socket.ByteString as BinSock import Network.BSD-import Control.Exception (finally)+import Control.Exception (finally, try, throwIO, SomeException) import Control.Monad (forever, liftM, replicateM, void) import Control.Monad.Trans (liftIO) import Control.Concurrent (forkIO, threadDelay)@@ -107,7 +107,12 @@ next <- readChan chan case next of Just a -> do- resp <- proc a -- XXX handle exceptions?- toByteStringIO (BinSock.sendAll s) $ resp- processRequests chan proc s+ mresp <- try $ proc a+ case mresp of+ Right resp -> do+ toByteStringIO (BinSock.sendAll s) $ resp+ processRequests chan proc s+ Left (e :: SomeException) -> do+ sClose s+ throwIO e Nothing -> return ()