git.iko.soy/distributed-process
on master help sign in
smallChunkSize instead of 4kB to avoid overhead
ac068d2Edsko de Vries
network-transport-tcp/src/Network/Transport/TCP/Internal.hs+2−1
@@ -38,6 +38,7 @@ import Control.Applicative ((<$>))
38import Data.ByteString (ByteString)
38import Data.ByteString (ByteString)
39import qualified Data.ByteString as BS (length, concat, null)
39import qualified Data.ByteString as BS (length, concat, null)
40import Data.Int (Int32)
40import Data.Int (Int32)
41+import Data.ByteString.Lazy.Internal (smallChunkSize)
41
42
42-- | Start a server at the specified address.
43-- | Start a server at the specified address.
43--
44--
@@ -115,7 +116,7 @@ recvExact sock len = go [] len
115 go :: [ByteString] -> Int32 -> IO [ByteString]
116 go :: [ByteString] -> Int32 -> IO [ByteString]
116 go acc 0 = return (reverse acc)
117 go acc 0 = return (reverse acc)
117 go acc l = do
118 go acc l = do
118− bs <- NBS.recv sock (fromIntegral l `min` 4096)
119+ bs <- NBS.recv sock (fromIntegral l `min` smallChunkSize)
119 if BS.null bs
120 if BS.null bs
120 then throwIO (userError "recvExact: Socket closed")
121 then throwIO (userError "recvExact: Socket closed")
121 else go (bs : acc) (l - fromIntegral (BS.length bs))
122 else go (bs : acc) (l - fromIntegral (BS.length bs))