Conversation
Between its last chunk arriving and its hash passing, a piece is neither queued, in-flight nor have. update_only_files() re-selecting its file in that window sees "selected and not have" and queues it, and when the hash then passes the piece is have AND queued: the next peer to ask is handed a piece we have, downloads it again over the same bytes, and the completion is counted twice. mark_piece_downloaded() now clears the queue bit alongside setting have, which restores queued ⊆ !have at the one place it could break. The test walks exactly that interleaving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Between its last chunk arriving and its hash passing, a piece is neither queued, in-flight nor have. update_only_files() re-selecting its file in that window sees "selected and not have" and queues it, and when the hash then passes the piece is have AND queued: the next peer to ask is handed a piece we have, downloads it again over the same bytes, and the completion is counted twice.
mark_piece_downloaded() now clears the queue bit alongside setting have, which restores queued ⊆ !have at the one place it could break. The test walks exactly that interleaving.
Generated by my Claude Fable.
Here my agent has solved it in a way that I'm not fully 100% I agree with - but it is a very simple solution - just force set queued to false after it's marked as downloaded should make all newly downloaded pieces never be queued. But maybe there's a better way more in line with project style that I don't see?