Skip to content

Commit edff5fd

Browse files
Bugfix async demotion
The 'releaseOutboundConnection' is moved following peer status update to PeerCooling to avoid calling it twice in racy conditions. The outbound governor can be in the middle of an async demotion in a call to closePeerConnection while the peerMonitoringLoop in peer state actions can detect that a warm protocol has finished. The latter will also call closePeerConnection. This change ensures that there can be only one (tm) winner.
1 parent 82beb03 commit edff5fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerStateActions.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,9 +1058,9 @@ withPeerStateActions PeerStateActionsArguments {
10581058
-- 'unregisterOutboundConnection' could only fail to demote the peer if
10591059
-- connection manager would simultaneously promote it, but this is not
10601060
-- possible.
1061-
_ <- releaseOutboundConnection spsConnectionManager pchConnectionId
10621061
wasWarm <- atomically (updateUnlessCoolingOrCold pchPeerStatus PeerCooling)
1063-
when wasWarm $
1062+
when wasWarm $ do
1063+
_ <- releaseOutboundConnection spsConnectionManager pchConnectionId
10641064
traceWith spsTracer (PeerStatusChanged (WarmToCooling pchConnectionId))
10651065
return wasWarm
10661066

0 commit comments

Comments
 (0)