Bug #362
ArgumentOutOfRangeException in MonoTorrent.Client.ConnectionManager.TryConnect()
Status: | Closed | Start: | 03/08/2010 | |
Priority: | Normal | Due date: | ||
Assigned to: | - | % Done: | 0% |
|
Category: | - | Spent time: | - | |
Target version: | - | |||
Votes: | 0 |
Description
Repro steps:
- Add several torrents to a
ClientEngine
. - Start one.
- Wait for it to finish.
- Stop it.
- Remove it from the
ClientEngine
. - Start another one. (crash)
It's a little timing sensitive, but not too hard to reproduce. The issue is that TryConnectIndex
ends up out past the number of TorrentManagers
in the ClientEngine
, causing the second loop in ConnectionManager.TryConnect()
to blow up. Suggested replacement for both loops:
// Check each torrent manager in turn to see if they have any peers we want to connect to int count = engine.Torrents.Count; if( count > 0 ) //gonna do some modulo madness { //wrap the index in case torrents have been //removed between the last connect and now (yes, it happens) int startIndex = TryConnectIndex % count; int i = startIndex; do { if( TryConnect( engine.Torrents[i] ) ) { TryConnectIndex = i + 1; break; } i = (i + 1) % count; //wrap around the list } while( i != startIndex ); //ending when we reach the first one we tried to connect to }
That should spin through the array exactly once, starting at TryConnectIndex
, and maintain the old behavior of updating TryConnectIndex
to point to the element after the first that successfully made a connection.
History
Updated by Phill Djonov 5380 days ago
This seems to have been fixed as part of a different change.
(is anyone even watching this site?)