Changeset 5647 for trunk/libtransmission/tracker.c
- Timestamp:
- Apr 19, 2008, 3:07:59 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/tracker.c
r5626 r5647 222 222 ***/ 223 223 224 static const tr_tracker_event emptyEvent = { 0, NULL, NULL, NULL, 0 };224 static const tr_tracker_event emptyEvent = { 0, NULL, NULL, NULL, 0, 0 }; 225 225 226 226 static void … … 257 257 258 258 static void 259 publishNewPeers( tr_tracker * t, int count, uint8_t * peers)259 publishNewPeers( tr_tracker * t, int allAreSeeds, void * compact, int compactLen ) 260 260 { 261 261 tr_tracker_event event = emptyEvent; 262 262 event.hash = t->hash; 263 263 event.messageType = TR_TRACKER_PEERS; 264 event. peerCount = count;265 event. peerCompact = peers;266 tr_ndbg( t->name, "Torrent got %d new peers", count );267 if( co unt)264 event.allAreSeeds = allAreSeeds; 265 event.compact = compact; 266 event.compactLen = compactLen; 267 if( compactLen ) 268 268 tr_publisherPublish( t->publisher, t, &event ); 269 269 } … … 361 361 /* Convert to compact form */ 362 362 static uint8_t * 363 parseOldPeers( tr_benc * bePeers, int * setmePeerCount )363 parseOldPeers( tr_benc * bePeers, size_t * byteCount ) 364 364 { 365 365 int i; … … 394 394 } 395 395 396 * setmePeerCount = peerCount;396 *byteCount = peerCount * 6; 397 397 return compact; 398 398 } … … 433 433 { 434 434 tr_benc * tmp; 435 int incomplete = -1; 435 436 436 437 if(( tmp = tr_bencDictFind( &benc, "failure reason" ))) { … … 461 462 462 463 if(( tmp = tr_bencDictFind( &benc, "incomplete" ))) 463 t->leecherCount = tmp->val.i;464 t->leecherCount = incomplete = tmp->val.i; 464 465 465 466 if(( tmp = tr_bencDictFind( &benc, "peers" ))) 466 467 { 467 int peerCount = 0; 468 uint8_t * peerCompact = NULL; 469 470 if( tmp->type == TYPE_LIST ) /* original protocol */ 468 const int allAreSeeds = incomplete == 0; 469 470 if( tmp->type == TYPE_STR ) /* "compact" extension */ 471 471 { 472 if( tmp->val.l.count > 0 ) 473 peerCompact = parseOldPeers( tmp, &peerCount ); 472 publishNewPeers( t, allAreSeeds, tmp->val.s.s, tmp->val.s.i ); 474 473 } 475 else if( tmp->type == TYPE_ STR ) /* "compact" extension*/474 else if( tmp->type == TYPE_LIST ) /* original protocol */ 476 475 { 477 if( tmp->val.s.i >= 6 ) 478 { 479 peerCount = tmp->val.s.i / 6; 480 peerCompact = tr_new( uint8_t, tmp->val.s.i ); 481 memcpy( peerCompact, tmp->val.s.s, tmp->val.s.i ); 482 } 476 size_t byteCount = 0; 477 uint8_t * compact = parseOldPeers( tmp, &byteCount ); 478 publishNewPeers( t, allAreSeeds, compact, byteCount ); 479 tr_free( compact ); 483 480 } 484 485 publishNewPeers( t, peerCount, peerCompact );486 tr_free( peerCompact );487 481 } 488 482 }
Note: See TracChangeset
for help on using the changeset viewer.