| author | Rink Springer <rink@rink.nu> |
| Sun Jul 31 12:12:56 2011 +0200 (9 months ago ago) | |
| changeset 327 | b023a55427b4 |
| parent 326 | 6177d2f6fd57 |
| child 328 | 89367a44e2dc |
Construct the tracker talker before hashing pieces
As constructing the tracker talker may fail (due to missing/corrupt metadata), we must do so before scheduling pieces since an exception will cause our object construction to be aborted - yet the hasher won't know about this and invoke callbacks in an object already gone.
Note that the tracker won't actually be called during initialization (Torrent::heartbeat() talks to it) so this change does not introduce races.
As constructing the tracker talker may fail (due to missing/corrupt metadata), we must do so before scheduling pieces since an exception will cause our object construction to be aborted - yet the hasher won't know about this and invoke callbacks in an object already gone.
Note that the tracker won't actually be called during initialization (Torrent::heartbeat() talks to it) so this change does not introduce races.
| lib/torrent.cc | file | annotate | diff | revisions |
1.1 --- a/lib/torrent.cc Fri Jul 29 19:19:31 2011 +0200 1.2 +++ b/lib/torrent.cc Sun Jul 31 12:12:56 2011 +0200 1.3 @@ -195,6 +195,9 @@ 1.4 */ 1.5 torrentDictionary = new MetaDictionary(*md->getDictionary()); 1.6 1.7 + /* Initializer our talker; this will speak with the trackers */ 1.8 + trackerTalker = new TrackerTalker(this, torrentDictionary); 1.9 + 1.10 /* 1.11 * If there is a 'taStatus' dictionary in the torrent, we must parse it. This is a 1.12 * Tortilla-specific dictionary containing the current torrent status, which we 1.13 @@ -294,9 +297,6 @@ 1.14 * We must have processed as many pieces as there are in the file. 1.15 */ 1.16 assert(piecenum == numPieces); 1.17 - 1.18 - /* Initializer our talker; this will speak with the trackers */ 1.19 - trackerTalker = new TrackerTalker(this, dictionary); 1.20 } 1.21 1.22 Torrent::~Torrent()