Skip to content

persist BEP-21 upload_only on peer_list entry#8519

Open
reardonia wants to merge 2 commits into
arvidn:RC_2_1from
reardonia:upload_only
Open

persist BEP-21 upload_only on peer_list entry#8519
reardonia wants to merge 2 commits into
arvidn:RC_2_1from
reardonia:upload_only

Conversation

@reardonia

@reardonia reardonia commented Jun 28, 2026

Copy link
Copy Markdown

Fixes #7700.

There is a long standing problem in LT where it immediately drops connections from peers which advertise "upload_only" in the LTEP handshake, and thus even when LT is a seed it keeps recontacting the same peers which are also seeds. Transmission and other clients get this right and hold on to the upload_only indication and stop connecting peer-seeds when unnecessary.

This PR dramatically reduces connection chatter from LT clients. Currently, as described in #7700, LT will attempt to aggressively reconnect to peer-seeds up to once per minute. When trackers do not seed-filter the peer list sent back on announce, this is an enormous number of outbound connections.

The core problem is that upload_only is sent during LTEP exchange, before the have_all message is sent during torrent messages that would indicate a seed. So that connection is dropped by LT before it ever sees the have_all message.

See also qbittorrent/qBittorrent#22432

@arvidn

arvidn commented Jun 29, 2026

Copy link
Copy Markdown
Owner

this seems reasonable. The main risk, that I see, is that upload-only is much more likely to change than seed. If the client decides that it wants to download some new files, it will change.

In an ideal world it would not be persisted for quite as long, but this definitely seems like an improvement.

The comments are a bit verbose; I don't think they need to reference github tickets. You'll find the tickets/PRs via git blame anyway.

Would you mind adding a new unit test for peer_list, it can probably be modeled after set_seed, in test/test_peer_list.cpp.

@reardonia

Copy link
Copy Markdown
Author

this seems reasonable. The main risk, that I see, is that upload-only is much more likely to change than seed. If the client decides that it wants to download some new files, it will change.

Yes, and the peer upload_only state will track 0->1 and 1->0. Tried to make that explicit in comments.

In an ideal world it would not be persisted for quite as long, but this definitely seems like an improvement.

The comments are a bit verbose; I don't think they need to reference github tickets. You'll find the tickets/PRs via git blame anyway.

Would you mind adding a new unit test for peer_list, it can probably be modeled after set_seed, in test/test_peer_list.cpp.

Will add test.

Previously only the live m_upload_only was updated; the persistent
torrent_peer had no record. After disconnect, the next tracker
announce re-promoted the address every ~60s. Add an upload_only:1
bit (distinct from seed and maybe_upload_only), widen
is_connect_candidate to filter on it, and sync both bits both ways.
Mirrors the existing set_seed test, with an extra section verifying
that flipping upload_only back to false restores connect candidacy
(exercises the symmetric +1/-1 candidate-count update).
@reardonia

Copy link
Copy Markdown
Author

@arvidn should I also submit PR against RC_2_0 or are you done updating 2.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants