Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket configuration #3979

Merged
merged 9 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions network-mux/network-mux.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ library
-- The Windows version of network-3.1.2 is missing
-- functions, see
-- https://github.com/haskell/network/issues/484
network >=3.1.2 && <3.2,
network >=3.1.2.2 && <3.2,
process >=1.6 && <1.7,
statistics-linreg
>=0.3 && <0.4,
Expand Down Expand Up @@ -182,7 +182,6 @@ executable cardano-ping
import: demo-deps
hs-source-dirs: tools
main-is: cardano-ping.hs
other-modules: Linger
build-depends: base,
aeson,
network-mux,
Expand Down
32 changes: 0 additions & 32 deletions network-mux/tools/Linger.hsc

This file was deleted.

4 changes: 1 addition & 3 deletions network-mux/tools/cardano-ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Data.Maybe (fromMaybe, isNothing)
import Data.TDigest
import Data.Text (unpack)
import Data.Word
import Network.Socket (AddrInfo)
import Network.Socket (AddrInfo, StructLinger (..))
import qualified Network.Socket as Socket
import System.Console.GetOpt
import System.Environment (getArgs, getProgName)
Expand All @@ -40,8 +40,6 @@ import Network.Mux.Bearer.Socket
import Network.Mux.Timeout
import Network.Mux.Types

import Linger

mainnetMagic :: Word32
mainnetMagic = 764824073

Expand Down
2 changes: 1 addition & 1 deletion ouroboros-consensus-cardano-tools/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ main = defaultMain tests
-- cannot execute binary file: Exec format error
-- ```
--
-- 0
-- 3
7 changes: 7 additions & 0 deletions ouroboros-consensus-mock-test/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ tests =
, Test.ThreadNet.PBFT.tests
, Test.ThreadNet.Praos.tests
]

-- Counter to address the zfs copy bug on Hydra
-- ```
-- cannot execute binary file: Exec format error
-- ```
--
-- 3
1 change: 1 addition & 0 deletions ouroboros-network-framework/demo/connection-manager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ withBidirectionalConnectionManager snocket socket
cmIPv6Address = Nothing,
cmAddressType = \_ -> Just IPv4Address,
cmSnocket = snocket,
cmConfigureSocket = \_ _ -> return (),
cmTimeWaitTimeout = timeWaitTimeout,
cmOutboundIdleTimeout = protocolIdleTimeout,
connectionDataFlow = const Duplex,
Expand Down
4 changes: 4 additions & 0 deletions ouroboros-network-framework/demo/ping-pong.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ clientPingPong pipelined =
withIOManager $ \iomgr ->
connectToNode
(Snocket.localSnocket iomgr)
mempty
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
Expand Down Expand Up @@ -146,6 +147,7 @@ serverPingPong =
_ <- async $ cleanNetworkMutableState networkState
withServerNode
(Snocket.localSnocket iomgr)
mempty
nullNetworkServerTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
Expand Down Expand Up @@ -206,6 +208,7 @@ clientPingPong2 =
withIOManager $ \iomgr -> do
connectToNode
(Snocket.localSnocket iomgr)
mempty
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
Expand Down Expand Up @@ -257,6 +260,7 @@ serverPingPong2 =
_ <- async $ cleanNetworkMutableState networkState
withServerNode
(Snocket.localSnocket iomgr)
mempty
nullNetworkServerTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ library

Simulation.Network.Snocket

other-modules: Ouroboros.Network.Linger
-- other-extensions:
build-depends: base >=4.12 && <4.15
, async >=2.1 && <2.3
Expand All @@ -92,7 +91,7 @@ library
, io-classes >=0.1 && < 0.3
, monoidal-synchronisation
>=0.1 && < 0.2
, network >=3.1.2 && < 3.2
, network >=3.1.2.2 && < 3.2
, network-mux >=0.1 && < 0.2
, ouroboros-network-testing
, strict-stm >=0.1 && < 0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Control.Monad.Fix
import Control.Tracer (Tracer, contramap, traceWith)
import Data.Foldable (foldMap', traverse_)
import Data.Function (on)
import Data.Functor (void, ($>))
import Data.Functor (void)
import Data.Maybe (maybeToList)
import Data.Proxy (Proxy (..))
import Data.Typeable (Typeable)
Expand Down Expand Up @@ -102,6 +102,10 @@ data ConnectionManagerArguments handlerTrace socket peerAddr handle handleError
--
cmSnocket :: Snocket m socket peerAddr,

-- | Socket configuration.
--
cmConfigureSocket :: socket -> Maybe peerAddr -> m (),

-- | @TCP@ will held connections in @TIME_WAIT@ state for up to two MSL
-- (maximum segment time). On Linux this is set to '60' seconds on
-- other system this might be up to four minutes.
Expand Down Expand Up @@ -558,6 +562,7 @@ withConnectionManager ConnectionManagerArguments {
cmIPv6Address,
cmAddressType,
cmSnocket,
cmConfigureSocket,
cmTimeWaitTimeout,
cmOutboundIdleTimeout,
connectionDataFlow,
Expand Down Expand Up @@ -1634,17 +1639,19 @@ withConnectionManager ConnectionManagerArguments {
)
$ \socket -> do
traceWith tracer (TrConnectionNotFound provenance peerAddr)
addr <-
case cmAddressType peerAddr of
Nothing -> pure Nothing
Just IPv4Address ->
traverse_ (bind cmSnocket socket)
cmIPv4Address
$> cmIPv4Address
Just IPv6Address ->
traverse_ (bind cmSnocket socket)
cmIPv6Address
$> cmIPv6Address
let addr = case cmAddressType peerAddr of
Nothing -> Nothing
Just IPv4Address -> cmIPv4Address
Just IPv6Address -> cmIPv6Address
cmConfigureSocket socket addr
case cmAddressType peerAddr of
Nothing -> pure ()
Just IPv4Address ->
traverse_ (bind cmSnocket socket)
cmIPv4Address
Just IPv6Address ->
traverse_ (bind cmSnocket socket)
cmIPv6Address

traceWith tracer (TrConnect addr peerAddr)
connect cmSnocket socket peerAddr
Expand Down
32 changes: 0 additions & 32 deletions ouroboros-network-framework/src/Ouroboros/Network/Linger.hsc

This file was deleted.

Loading