Skip to content

Commit

Permalink
Use vectored io in Network.Mux.Bearer.Socket
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Jan 31, 2020
1 parent 16146d7 commit 2ecc959
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions network-mux/src/Network/Mux/Bearer/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import qualified Network.Socket as Socket
#if !defined(mingw32_HOST_OS)
import qualified Network.Socket.ByteString.Lazy as Socket (recv, sendAll)
#else
import Data.Foldable (traverse_)
import qualified System.Win32.Async as Win32.Async
import qualified System.Win32.Async.Socket.ByteString.Lazy as Win32.Async
#endif

import qualified Network.Mux as Mx
Expand All @@ -36,9 +35,10 @@ import qualified Network.Mux.Time as Mx
-- |
-- Create @'MuxBearer'@ from a socket.
--
-- On Windows 'System.Win32.Async` operations are used to read and write. This
-- means that the socket must be associated with the I/O completion port with
-- 'System.Win32.Async.associateWithIOCompletionPort'.
-- On Windows 'System.Win32.Async` operations are used to read and write from
-- a socket. This means that the socket must be associated with the I/O
-- completion port with
-- 'System.Win32.Async.IOManager.associateWithIOCompletionPort'.
--
-- Note: 'IOException's thrown by 'sendAll' and 'recv' are wrapped in
-- 'MuxError'.
Expand Down Expand Up @@ -74,7 +74,7 @@ socketAsMuxBearer tracer sd =
recvLen' waitingOnNxtHeader l bufs = do
traceWith tracer $ Mx.MuxTraceRecvStart $ fromIntegral l
#if defined(mingw32_HOST_OS)
buf <- BL.fromStrict <$> Win32.Async.recv sd (fromIntegral l)
buf <- Win32.Async.recv sd (fromIntegral l)
#else
buf <- Socket.recv sd l
#endif
Expand Down Expand Up @@ -102,8 +102,7 @@ socketAsMuxBearer tracer sd =
buf = Mx.encodeMuxSDU sdu'
traceWith tracer $ Mx.MuxTraceSendStart sdu'
#if defined(mingw32_HOST_OS)
-- TODO: issue #1430: vectored I/O on Windows
traverse_ (Win32.Async.sendAll sd) (BL.toChunks buf)
Win32.Async.sendAll sd buf
#else
Socket.sendAll sd buf
#endif
Expand Down

0 comments on commit 2ecc959

Please sign in to comment.