From 70690e8a16ac8d0226343dda210aa98cdfec2bcf Mon Sep 17 00:00:00 2001 From: Karl Knutsson Date: Fri, 14 Jan 2022 11:37:38 +0100 Subject: [PATCH] Stop mux incase termination of miniprotocols timeout 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. --- .../src/Ouroboros/Network/PeerSelection/PeerStateActions.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerStateActions.hs b/ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerStateActions.hs index af1ee95a091..e0f932f109a 100644 --- a/ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerStateActions.hs +++ b/ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerStateActions.hs @@ -877,7 +877,8 @@ withPeerStateActions PeerStateActionsArguments { PeerConnectionHandle { pchConnectionId, pchPeerState, - pchAppHandles + pchAppHandles, + pchMux } = do atomically $ do currentState <- getCurrentState <$> readTVar pchPeerState @@ -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