Skip to content

Commit b496fb4

Browse files
committed
connection manager: propagate disconnection reason to inbound governor
Propagate the reason why the connection manager wasn't able to include a connection to the inbound governor.
1 parent 8de849c commit b496fb4

File tree

1 file changed

+12
-10
lines changed
  • ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager

1 file changed

+12
-10
lines changed

ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/Core.hs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -991,22 +991,22 @@ with args@Arguments {
991991
let connState' = InboundIdleState
992992
connId connThread handle dataFlow
993993
writeTVar connVar connState'
994-
return ( True
994+
return ( Right ()
995995
, Just $ mkTransition connState connState'
996996
, Inbound
997997
)
998998

999999
-- Self connection: the inbound side lost the race to update
10001000
-- the state after negotiating the connection.
1001-
OutboundUniState {} -> return (True, Nothing, Outbound)
1002-
OutboundDupState {} -> return (True, Nothing, Outbound)
1001+
OutboundUniState {} -> return (Right (), Nothing, Outbound)
1002+
OutboundDupState {} -> return (Right (), Nothing, Outbound)
10031003

10041004
OutboundIdleState _ _ _ dataFlow' -> do
10051005
let connState' = InboundIdleState
10061006
connId connThread handle
10071007
dataFlow'
10081008
writeTVar connVar connState'
1009-
return ( True
1009+
return ( Right ()
10101010
, Just $ mkTransition connState connState'
10111011
, Outbound
10121012
)
@@ -1024,9 +1024,11 @@ with args@Arguments {
10241024
DuplexState {} ->
10251025
throwSTM (withCallStack (ImpossibleState (remoteAddress connId)))
10261026

1027-
TerminatingState {} -> return (False, Nothing, Inbound)
1027+
TerminatingState _ _ err ->
1028+
return (Left err, Nothing, Inbound)
10281029

1029-
TerminatedState {} -> return (False, Nothing, Inbound)
1030+
TerminatedState err ->
1031+
return (Left err, Nothing, Inbound)
10301032

10311033
traverse_ (traceWith trTracer . TransitionTrace connStateId) mbTransition
10321034
traceCounters stateVar
@@ -1043,8 +1045,8 @@ with args@Arguments {
10431045
-- idle, it will call 'releaseInboundConnection' which will
10441046
-- perform the aforementioned @Commit@ transition.
10451047

1046-
if connected
1047-
then do
1048+
case connected of
1049+
Right _ -> do
10481050
case inboundGovernorInfoChannel of
10491051
InResponderMode infoChannel ->
10501052
atomically $ InfoChannel.writeMessage
@@ -1055,8 +1057,8 @@ with args@Arguments {
10551057

10561058
-- the connection is in `TerminatingState` or
10571059
-- `TerminatedState`.
1058-
else
1059-
return $ Disconnected connId Nothing
1060+
Left err ->
1061+
return $ Disconnected connId err
10601062

10611063
terminateInboundWithErrorOrQuery
10621064
:: ConnectionId peerAddr

0 commit comments

Comments
 (0)