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

Inbound governor idle timeout #3844

Merged
merged 1 commit into from
Jun 28, 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
2 changes: 1 addition & 1 deletion ouroboros-network-framework/demo/connection-manager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ withBidirectionalConnectionManager snocket socket
serverInboundGovernorTracer = ("inbound-governor",) `contramap` debugTracer,
serverConnectionLimits = AcceptedConnectionsLimit maxBound maxBound 0,
serverConnectionManager = connectionManager,
serverInboundIdleTimeout = protocolIdleTimeout,
serverInboundIdleTimeout = Just protocolIdleTimeout,
serverControlChannel = inbgovControlChannel,
serverObservableStateVar = observableStateVar
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ inboundGovernor :: forall (muxMode :: MuxMode) socket peerAddr versionNumber m a
=> Tracer m (RemoteTransitionTrace peerAddr)
-> Tracer m (InboundGovernorTrace peerAddr)
-> ServerControlChannel muxMode peerAddr ByteString m a b
-> DiffTime -- protocol idle timeout
-> Maybe DiffTime -- protocol idle timeout
-> MuxConnectionManager muxMode socket peerAddr
versionNumber ByteString m a b
-> StrictTVar m InboundGovernorObservableState
Expand Down Expand Up @@ -242,11 +242,13 @@ inboundGovernor trTracer tracer serverControlChannel inboundIdleTimeout
Nothing -> return Nothing

Just csCompletionMap -> do
v <- registerDelay inboundIdleTimeout
mv <- traverse registerDelay inboundIdleTimeout
let -- initial state is 'RemoteIdle', if the remote end will not
-- start any responders this will unregister the inbound side.
csRemoteState :: RemoteState m
csRemoteState = RemoteIdle (LazySTM.readTVar v >>= check)
csRemoteState = RemoteIdle (case mv of
Nothing -> retry
Just v -> LazySTM.readTVar v >>= check)

connState = ConnectionState {
csMux,
Expand Down Expand Up @@ -338,9 +340,11 @@ inboundGovernor trTracer tracer serverControlChannel inboundIdleTimeout
let state' = unregisterConnection connId state
return (Just connId, state')
OperationSuccess {} -> do
v <- registerDelay inboundIdleTimeout
mv <- traverse registerDelay inboundIdleTimeout
let timeoutSTM :: STM m ()
!timeoutSTM = LazySTM.readTVar v >>= check
!timeoutSTM = case mv of
Nothing -> retry
Just v -> LazySTM.readTVar v >>= check

let state' = updateRemoteState connId (RemoteIdle timeoutSTM) state

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data ServerArguments (muxMode :: MuxMode) socket peerAddr versionNumber bytes m
-- | Time for which all protocols need to be idle to trigger
-- 'DemotedToCold' transition.
--
serverInboundIdleTimeout :: DiffTime,
serverInboundIdleTimeout :: Maybe DiffTime,

-- | Server control var is passed as an argument; this allows to use the
-- server to run and manage responders which needs to be started on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ withBidirectionalConnectionManager name timeouts
WithName name `contramap` inboundTracer, -- InboundGovernorTrace
serverConnectionLimits = acceptedConnLimit,
serverConnectionManager = connectionManager,
serverInboundIdleTimeout = tProtocolIdleTimeout timeouts,
serverInboundIdleTimeout = Just (tProtocolIdleTimeout timeouts),
serverControlChannel = inbgovControlChannel,
serverObservableStateVar = observableStateVar
}
Expand Down
4 changes: 2 additions & 2 deletions ouroboros-network/src/Ouroboros/Network/Diffusion/P2P.hs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ runM Interfaces
serverTracer = dtLocalServerTracer,
serverTrTracer = nullTracer, -- TODO: issue #3320
serverInboundGovernorTracer = dtLocalInboundGovernorTracer,
serverInboundIdleTimeout = local_PROTOCOL_IDLE_TIMEOUT,
serverInboundIdleTimeout = Nothing,
serverConnectionLimits = localConnectionLimits,
serverConnectionManager = localConnectionManager,
serverControlChannel = localControlChannel,
Expand Down Expand Up @@ -1018,7 +1018,7 @@ runM Interfaces
serverInboundGovernorTracer = dtInboundGovernorTracer,
serverConnectionLimits = daAcceptedConnectionsLimit,
serverConnectionManager = connectionManager,
serverInboundIdleTimeout = daProtocolIdleTimeout,
serverInboundIdleTimeout = Just daProtocolIdleTimeout,
serverControlChannel = controlChannel,
serverObservableStateVar = observableStateVar
})
Expand Down