Skip to content

Commit

Permalink
Stop mux incase termination of miniprotocols timeout
Browse files Browse the repository at this point in the history
When demoting a peer to cold there is a 300s timeout for the
miniprotocols to terminate. In case of timeout the connection will be
left hanging, it will only be unregistered. The next time the
peer is promoted to warm there may still be lingering miniprotocols in
an unknown state.

By calling stopMux we ensure that the connection will be
reset.
  • Loading branch information
karknu committed Jan 17, 2022
1 parent f2425ff commit 70690e8
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -877,7 +877,8 @@ withPeerStateActions PeerStateActionsArguments {
PeerConnectionHandle {
pchConnectionId,
pchPeerState,
pchAppHandles
pchAppHandles,
pchMux
} = do
atomically $ do
currentState <- getCurrentState <$> readTVar pchPeerState
Expand All @@ -903,6 +904,7 @@ withPeerStateActions PeerStateActionsArguments {
case res of
Nothing -> do
-- timeout fired
Mux.stopMux pchMux
_ <- unregisterOutboundConnection spsConnectionManager (remoteAddress pchConnectionId)
atomically (writeTVar pchPeerState (PeerStatus PeerCold))
traceWith spsTracer (PeerStatusChangeFailure
Expand Down

0 comments on commit 70690e8

Please sign in to comment.