Skip to content

Commit

Permalink
pruning: include current connection in the choice map
Browse files Browse the repository at this point in the history
When pruning connections we have to add current connection, as it is
filtered out by the guard.
  • Loading branch information
coot committed Nov 30, 2021
1 parent c008fc7 commit c2b0d1e
Showing 1 changed file with 23 additions and 4 deletions.
Expand Up @@ -1869,7 +1869,7 @@ withConnectionManager ConnectionManagerArguments {
-- have 'ConnectionType' and are running (have a thread).
-- This excludes connections in 'ReservedOutboundState',
-- 'TerminatingState' and 'TerminatedState'.
(choiceMap :: Map peerAddr (ConnectionType, Async m ()))
(choiceMap' :: Map peerAddr (ConnectionType, Async m ()))
<- flip Map.traverseMaybeWithKey state $ \_peerAddr MutableConnState { connVar = connVar' } ->
(\cs -> do
-- this expression returns @Maybe (connType, connThread)@;
Expand All @@ -1878,6 +1878,11 @@ withConnectionManager ConnectionManagerArguments {
(,) <$> getConnType cs
<*> getConnThread cs)
<$> readTVar connVar'
let choiceMap =
case getConnType connState' of
Nothing -> assert False choiceMap'
Just a -> Map.insert peerAddr (a, connThread)
choiceMap'

pruneSet <-
cmPrunePolicy
Expand Down Expand Up @@ -1955,7 +1960,7 @@ withConnectionManager ConnectionManagerArguments {
-- have 'ConnectionType' and are running (have a thread).
-- This excludes connections in 'ReservedOutboundState',
-- 'TerminatingState' and 'TerminatedState'.
(choiceMap :: Map peerAddr (ConnectionType, Async m ()))
(choiceMap' :: Map peerAddr (ConnectionType, Async m ()))
<- flip Map.traverseMaybeWithKey state $ \_peerAddr MutableConnState { connVar = connVar' } ->
(\cs -> do
-- this expression returns @Maybe (connType, connThread)@;
Expand All @@ -1964,6 +1969,11 @@ withConnectionManager ConnectionManagerArguments {
(,) <$> getConnType cs
<*> getConnThread cs)
<$> readTVar connVar'
let choiceMap =
case getConnType connState' of
Nothing -> assert False choiceMap'
Just a -> Map.insert peerAddr (a, connThread)
choiceMap'

pruneSet <-
cmPrunePolicy
Expand Down Expand Up @@ -2151,7 +2161,7 @@ withConnectionManager ConnectionManagerArguments {
-- have 'ConnectionType' and are running (have a thread).
-- This excludes connections in 'ReservedOutboundState',
-- 'TerminatingState' and 'TerminatedState'.
(choiceMap :: Map peerAddr (ConnectionType, Async m ()))
(choiceMap' :: Map peerAddr (ConnectionType, Async m ()))
<- flip Map.traverseMaybeWithKey state $ \_peerAddr MutableConnState { connVar = connVar' } ->
(\cs -> do
-- this expression returns @Maybe (connType, connThread)@;
Expand All @@ -2160,6 +2170,11 @@ withConnectionManager ConnectionManagerArguments {
(,) <$> getConnType cs
<*> getConnThread cs)
<$> readTVar connVar'
let choiceMap =
case getConnType connState' of
Nothing -> assert False choiceMap'
Just a -> Map.insert peerAddr (a, connThread)
choiceMap'

pruneSet <-
cmPrunePolicy
Expand Down Expand Up @@ -2208,7 +2223,7 @@ withConnectionManager ConnectionManagerArguments {
-- have 'ConnectionType' and are running (have a thread).
-- This excludes connections in 'ReservedOutboundState',
-- 'TerminatingState' and 'TerminatedState'.
(choiceMap :: Map peerAddr (ConnectionType, Async m ()))
(choiceMap' :: Map peerAddr (ConnectionType, Async m ()))
<- flip Map.traverseMaybeWithKey state $ \_peerAddr MutableConnState { connVar = connVar' } ->
(\cs -> do
-- this expression returns @Maybe (connType, connThread)@;
Expand All @@ -2217,6 +2232,10 @@ withConnectionManager ConnectionManagerArguments {
(,) <$> getConnType cs
<*> getConnThread cs)
<$> readTVar connVar'
let choiceMap =
case getConnType connState' of
Nothing -> assert False choiceMap'
Just a -> Map.insert peerAddr (a, connThread) choiceMap'

pruneSet <-
cmPrunePolicy
Expand Down

0 comments on commit c2b0d1e

Please sign in to comment.