Skip to content

Commit 7683f90

Browse files
committed
notification: Fix memory leak of pending substreams
Signed-off-by: Alexandru Vasile <[email protected]>
1 parent 28d42c6 commit 7683f90

File tree

1 file changed

+18
-6
lines changed
  • src/protocol/notification

1 file changed

+18
-6
lines changed

src/protocol/notification/mod.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,30 @@ impl NotificationProtocol {
435435
},
436436
);
437437
}
438+
(OutboundState::OutboundInitiated { substream }, _) => {
439+
tracing::debug!(
440+
target: LOG_TARGET,
441+
?peer,
442+
protocol = %self.protocol,
443+
"connection closed outbound substream initiated ",
444+
);
445+
// We need to remove this state to avoid a memory leak.
446+
self.pending_outbound.remove(&substream);
447+
448+
self.event_handle
449+
.report_notification_stream_open_failure(
450+
peer,
451+
NotificationError::Rejected,
452+
)
453+
.await;
454+
}
438455
// user either initiated an outbound substream or an outbound substream was
439456
// opened/being opened as a result of an accepted inbound substream but was not
440457
// yet fully open
441458
//
442459
// to have consistent state tracking in the user protocol, substream rejection
443460
// must be reported to the user
444-
(
445-
OutboundState::OutboundInitiated { .. }
446-
| OutboundState::Negotiating
447-
| OutboundState::Open { .. },
448-
_,
449-
) => {
461+
(OutboundState::Negotiating | OutboundState::Open { .. }, _) => {
450462
tracing::debug!(
451463
target: LOG_TARGET,
452464
?peer,

0 commit comments

Comments
 (0)