Changeset 3163
- Timestamp:
- Sep 25, 2007, 12:04:29 AM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-mgr.c
r3161 r3163 560 560 561 561 static void 562 restartReconnectTimer( Torrent * t ) 563 { 564 tr_timerFree( &t->reconnectTimer ); 565 if( t->isRunning ) 566 t->reconnectTimer = tr_timerNew( t->manager->handle, reconnectPulse, t, RECONNECT_PERIOD_MSEC ); 567 } 568 569 static void 562 570 reconnectNow( Torrent * t ) 563 571 { 564 572 reconnectPulse( t ); 565 tr_timerFree( &t->reconnectTimer ); 566 t->reconnectTimer = tr_timerNew( t->manager->handle, reconnectPulse, t, RECONNECT_PERIOD_MSEC ); 573 restartReconnectTimer( t ); 567 574 } 568 575 … … 591 598 592 599 static void 600 restartChokeTimer( Torrent * t ) 601 { 602 tr_timerFree( &t->rechokeTimer ); 603 if( t->isRunning ) 604 t->rechokeTimer = tr_timerNew( t->manager->handle, rechokePulse, t, RECHOKE_PERIOD_MSEC ); 605 } 606 607 static void 593 608 rechokeNow( Torrent * t ) 594 609 { 595 610 rechokePulse( t ); 596 tr_timerFree( &t->rechokeTimer ); 597 t->rechokeTimer = tr_timerNew( t->manager->handle, rechokePulse, t, RECHOKE_PERIOD_MSEC ); 611 restartChokeTimer( t ); 598 612 } 599 613 … … 877 891 Torrent * t = getExistingTorrent( manager, torrentHash ); 878 892 t->isRunning = 1; 893 restartChokeTimer( t ); 879 894 reconnectNow( t ); 880 895 } … … 886 901 Torrent * t = getExistingTorrent( manager, torrentHash ); 887 902 t->isRunning = 0; 888 reconnectNow( t ); 903 tr_timerFree( &t->rechokeTimer ); 904 tr_timerFree( &t->reconnectTimer ); 905 reconnectPulse( t ); 889 906 } 890 907 … … 903 920 t->peers = tr_ptrArrayNew( ); 904 921 t->requested = tr_bitfieldNew( tor->blockCount ); 905 t->rechokeTimer = tr_timerNew( manager->handle, rechokePulse, t, RECHOKE_PERIOD_MSEC);906 t->reconnectTimer = tr_timerNew( manager->handle, reconnectPulse, t, RECONNECT_PERIOD_MSEC);922 restartChokeTimer( t ); 923 restartReconnectTimer( t ); 907 924 908 925 memcpy( t->hash, tor->info.hash, SHA_DIGEST_LENGTH ); -
trunk/libtransmission/peer-msgs.c
r3162 r3163 45 45 enum 46 46 { 47 BT_CHOKE = 0, 48 BT_UNCHOKE = 1, 49 BT_INTERESTED = 2, 50 BT_NOT_INTERESTED = 3, 51 BT_HAVE = 4, 52 BT_BITFIELD = 5, 53 BT_REQUEST = 6, 54 BT_PIECE = 7, 55 BT_CANCEL = 8, 56 BT_PORT = 9, 57 BT_SUGGEST = 13, 58 BT_HAVE_ALL = 14, 59 BT_HAVE_NONE = 15, 60 BT_REJECT = 16, 61 BT_ALLOWED_FAST = 17, 62 BT_LTEP = 20, 63 64 LTEP_HANDSHAKE = 0, 65 66 OUR_LTEP_PEX = 1 47 BT_CHOKE = 0, 48 BT_UNCHOKE = 1, 49 BT_INTERESTED = 2, 50 BT_NOT_INTERESTED = 3, 51 BT_HAVE = 4, 52 BT_BITFIELD = 5, 53 BT_REQUEST = 6, 54 BT_PIECE = 7, 55 BT_CANCEL = 8, 56 BT_PORT = 9, 57 BT_SUGGEST = 13, 58 BT_HAVE_ALL = 14, 59 BT_HAVE_NONE = 15, 60 BT_REJECT = 16, 61 BT_ALLOWED_FAST = 17, 62 BT_LTEP = 20, 63 64 LTEP_HANDSHAKE = 0, 65 66 OUR_LTEP_PEX = 1, 67 68 /* disregard requests that want more than this many bytes. 69 it's common practice in for BT clients to use a 16K threshold */ 70 MAX_REQUEST_BYTE_COUNT = (16 * 1024) 67 71 }; 68 72 … … 612 616 const tr_torrent * tor = msgs->torrent; 613 617 assert( req != NULL ); 614 assert( req->index < (uint32_t)tor->info.pieceCount ); 615 assert( (int)req->offset < tr_torPieceCountBytes( tor, (int)req->index ) ); 616 assert( tr_pieceOffset( tor, req->index, req->offset, req->length ) <= tor->info.totalSize ); 618 619 if( req->index >= (uint32_t) tor->info.pieceCount ) 620 return FALSE; 621 if ( (int)req->offset >= tr_torPieceCountBytes( tor, (int)req->index ) ) 622 return FALSE; 623 if( req->length > MAX_REQUEST_BYTE_COUNT ) 624 return FALSE; 625 if( tr_pieceOffset( tor, req->index, req->offset, req->length ) > tor->info.totalSize ) 626 return FALSE; 627 617 628 return TRUE; 618 629 }
Note: See TracChangeset
for help on using the changeset viewer.