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

Fix infinite loop bug #1786

Open
wants to merge 5 commits into
base: master
from
Open

Fix infinite loop bug #1786

wants to merge 5 commits into from

Conversation

@koush
Copy link

koush commented Dec 6, 2019

The wire request may fail due to choking or wire closed. This results in an infinite loop.

Here is where "false" is expected, otherwise it loops infinitely:
https://github.com/koush/webtorrent/blob/master/lib/torrent.js#L1316

The failure is reported in the callback, but not as a return value:
https://github.com/webtorrent/bittorrent-protocol/blob/master/index.js#L316

Alternatively, the peer choking check can be done in the while loop.

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[ X] Bug fix
[ ] New feature
[ ] Other, please explain:

What changes did you make? (Give an overview)
Watch for a failed wire request (number of requests does not change), and return false.

Which issue (if any) does this pull request address?

Is there anything you'd like reviewers to focus on?

The wire request may fail due to choking or wire closed. This results in an infinite loop.
@koush koush changed the title Fix inifnite loop bug Fix infinite loop bug Dec 6, 2019
koush added 4 commits Dec 7, 2019
Do not calculate the rarest piece unless it is needed.
It is an expensive operation.
Add custom verifier so reading the entire torrent file(s) is not necessary on startup.
Queue torrent updates once per second, as it is an expensive operation. Before, this would cause updates to happen nearly every tick.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.