1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

(trunk libT) peer-mgr.c peerCallbackFunc(): Replace some "should always be true" tests with assert()s. These tests used to be useful, but I don't think they are anymore. The assert()s have been put in their place to test that theory...

This commit is contained in:
Jordan Lee 2011-02-25 01:48:46 +00:00
parent 3136946851
commit cff172bbd5

View file

@ -1607,6 +1607,9 @@ peerCallbackFunc( tr_peer * peer, const tr_peer_event * e, void * vt )
torrentLock( t ); torrentLock( t );
assert( peer != NULL );
assert( peer->atom != NULL );
switch( e->eventType ) switch( e->eventType )
{ {
case TR_PEER_PEER_GOT_DATA: case TR_PEER_PEER_GOT_DATA:
@ -1627,7 +1630,7 @@ peerCallbackFunc( tr_peer * peer, const tr_peer_event * e, void * vt )
tr_statsAddUploaded( tor->session, e->length ); tr_statsAddUploaded( tor->session, e->length );
/* update our atom */ /* update our atom */
if( peer && e->wasPieceData ) if( e->wasPieceData )
peer->atom->piece_data_time = now; peer->atom->piece_data_time = now;
break; break;
@ -1668,18 +1671,15 @@ peerCallbackFunc( tr_peer * peer, const tr_peer_event * e, void * vt )
break; break;
case TR_PEER_CLIENT_GOT_PORT: case TR_PEER_CLIENT_GOT_PORT:
if( peer ) peer->atom->port = e->port;
peer->atom->port = e->port;
break; break;
case TR_PEER_CLIENT_GOT_SUGGEST: case TR_PEER_CLIENT_GOT_SUGGEST:
if( peer ) peerSuggestedPiece( t, peer, e->pieceIndex, FALSE );
peerSuggestedPiece( t, peer, e->pieceIndex, FALSE );
break; break;
case TR_PEER_CLIENT_GOT_ALLOWED_FAST: case TR_PEER_CLIENT_GOT_ALLOWED_FAST:
if( peer ) peerSuggestedPiece( t, peer, e->pieceIndex, TRUE );
peerSuggestedPiece( t, peer, e->pieceIndex, TRUE );
break; break;
case TR_PEER_CLIENT_GOT_DATA: case TR_PEER_CLIENT_GOT_DATA:
@ -1699,7 +1699,7 @@ peerCallbackFunc( tr_peer * peer, const tr_peer_event * e, void * vt )
tr_statsAddDownloaded( tor->session, e->length ); tr_statsAddDownloaded( tor->session, e->length );
/* update our atom */ /* update our atom */
if( peer && peer->atom && e->wasPieceData ) if( e->wasPieceData )
peer->atom->piece_data_time = now; peer->atom->piece_data_time = now;
break; break;
@ -1730,8 +1730,7 @@ peerCallbackFunc( tr_peer * peer, const tr_peer_event * e, void * vt )
tr_ptrArrayDestruct( &peerArr, FALSE ); tr_ptrArrayDestruct( &peerArr, FALSE );
if( peer ) tr_historyAdd( &peer->blocksSentToClient, tr_time( ), 1 );
tr_historyAdd( &peer->blocksSentToClient, tr_time( ), 1 );
if( tr_cpBlockIsComplete( &tor->completion, block ) ) if( tr_cpBlockIsComplete( &tor->completion, block ) )
{ {