Skip to content

Commit

Permalink
pruning: do not prune in Duplex → InboundState transition
Browse files Browse the repository at this point in the history
When we unregister outbound side of a Duplex connection, it does not
changes the number of inbound connections, so there's not need to prune
anything.
  • Loading branch information
coot committed Nov 30, 2021
1 parent 4e587d0 commit 6b3785d
Showing 1 changed file with 10 additions and 34 deletions.
Expand Up @@ -1983,40 +1983,16 @@ withConnectionManager ConnectionManagerArguments {
let connState' = InboundState connId connThread handle Duplex
tr = mkTransition connState connState'

numberOfConns <- countIncomingConnections state
let numberToPrune =
numberOfConns
- fromIntegral
(acceptedConnectionsHardLimit cmConnectionsLimits)

if numberToPrune > 0

then do
(pruneSelf, prune)
<- mkPruneAction peerAddr numberToPrune state connState' connVar connThread
when (not pruneSelf)
$ writeTVar connVar connState'
if pruneSelf
then return ( PruneConnections prune (Left connState)
, Nothing
)
else do
writeTVar connVar connState'
return ( PruneConnections prune (Right tr)
, Nothing
)

else do
-- @
-- DemotedToCold^{Duplex}_{Local} : DuplexState
-- → InboundState Duplex
-- @
-- does not require to perform any additional io action (we
-- already updated 'connVar').
writeTVar connVar connState'
return ( DemoteToColdLocalNoop (Just tr) st
, Nothing
)
-- @
-- DemotedToCold^{Duplex}_{Local} : DuplexState
-- → InboundState Duplex
-- @
-- does not require to perform any additional io action (we
-- already updated 'connVar').
writeTVar connVar connState'
return ( DemoteToColdLocalNoop (Just tr) st
, Nothing
)

TerminatingState _connId _connThread _handleError ->
return (DemoteToColdLocalNoop Nothing st
Expand Down

0 comments on commit 6b3785d

Please sign in to comment.