Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notification: Fix memory leak of pending substreams #296

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/protocol/notification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,30 @@ impl NotificationProtocol {
},
);
}
(OutboundState::OutboundInitiated { substream }, _) => {
tracing::debug!(
target: LOG_TARGET,
?peer,
protocol = %self.protocol,
"connection closed outbound substream initiated ",
);
// We need to remove this state to avoid a memory leak.
self.pending_outbound.remove(&substream);

self.event_handle
.report_notification_stream_open_failure(
peer,
NotificationError::Rejected,
)
.await;
}
// user either initiated an outbound substream or an outbound substream was
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs need to be updated.

// opened/being opened as a result of an accepted inbound substream but was not
// yet fully open
//
// to have consistent state tracking in the user protocol, substream rejection
// must be reported to the user
(
OutboundState::OutboundInitiated { .. }
| OutboundState::Negotiating
| OutboundState::Open { .. },
_,
) => {
(OutboundState::Negotiating | OutboundState::Open { .. }, _) => {
tracing::debug!(
target: LOG_TARGET,
?peer,
Expand Down