When sending an answer over a domain socket, the recipient won't process that answer anyway before it is complete. So we can as well assemble one ByteString first and send it over the wire all at once, thus saving a few system calls.
Signed-off-by: Klaus Aehlig <[email protected]> --- src/Ganeti/UDSServer.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Ganeti/UDSServer.hs b/src/Ganeti/UDSServer.hs index 8e27c5a..868c4e9 100644 --- a/src/Ganeti/UDSServer.hs +++ b/src/Ganeti/UDSServer.hs @@ -77,9 +77,7 @@ import Control.Monad.Trans.Control import Control.Exception (catch) import Control.Monad import qualified Data.ByteString as B -import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.UTF8 as UTF8 -import qualified Data.ByteString.Lazy.UTF8 as UTF8L import Data.IORef import Data.List import Data.Word (Word8) @@ -288,9 +286,9 @@ clientToFd client | rh == wh = join (,) <$> handleToFd rh -- | Sends a message over a transport. sendMsg :: Client -> String -> IO () sendMsg s buf = withTimeout (sendTmo $ clientConfig s) "sending a message" $ do - let encoded = UTF8L.fromString buf + let encoded = UTF8.fromString buf handle = wsocket s - BL.hPut handle encoded + B.hPut handle encoded B.hPut handle bEOM hFlush handle -- 2.6.0.rc2.230.g3dd15c0
