Skip to content

Always send cancels even if peer has no interest #829

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

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The following emojis are used to highlight certain changes:

### Fixed

- Fix memory leak due to not cleaning up wantlists [#829](https://github.com/ipfs/boxo/pull/829)

### Security


Expand Down
2 changes: 1 addition & 1 deletion bitswap/client/internal/messagequeue/messagequeue.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
sendTimeout = 30 * time.Second

defaultPerPeerDelay = time.Millisecond / 8
maxSendMessageDelay = time.Second
maxSendMessageDelay = 2 * time.Second
minSendMessageDelay = 20 * time.Millisecond
)

Expand Down
8 changes: 5 additions & 3 deletions bitswap/client/internal/sessionmanager/sessionmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ func (sm *SessionManager) GetNextSessionID() uint64 {
// their contents. If the caller needs to preserve a copy of the lists it
// should make a copy before calling ReceiveFrom.
func (sm *SessionManager) ReceiveFrom(ctx context.Context, p peer.ID, blks []cid.Cid, haves []cid.Cid, dontHaves []cid.Cid) {
// Send CANCEL to all peers with want-have / want-block. This needs to be
// done before filtering out CIDs that peers are no longer interested in,
// to ensure they are removed from PeerManager and PeerQueue want lists.
sm.peerManager.SendCancels(ctx, blks)

// Keep only the keys that at least one session wants
keys := sm.sessionInterestManager.FilterInterests(blks, haves, dontHaves)
blks = keys[0]
Expand All @@ -179,9 +184,6 @@ func (sm *SessionManager) ReceiveFrom(ctx context.Context, p peer.ID, blks []cid
sess.ReceiveFrom(p, blks, haves, dontHaves)
}
}

// Send CANCEL to all peers with want-have / want-block
sm.peerManager.SendCancels(ctx, blks)
}

// CancelSessionWants is called when a session cancels wants because a call to
Expand Down