diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index def184fd2..429df3adc 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -171,7 +171,7 @@ tr_peerIoFree( tr_peerIo * c ) c->canRead = NULL; c->didWrite = NULL; c->gotError = NULL; - tr_bufferevent_free( c->handle, c->bufev ); + bufferevent_free( c->bufev ); tr_netClose( c->socket ); tr_rcClose( c->rateToClient ); diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 836dfba17..949820b51 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -1086,16 +1086,15 @@ tr_peerMgrGetPeers( tr_peerMgr * manager, tr_pex ** setme_pex ) { const Torrent * t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash ); - int i, peerCount; const int isLocked = torrentIsLocked( t ); - const tr_peer ** peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount ); - tr_pex * pex = tr_new( tr_pex, peerCount ); - tr_pex * walk = pex; + int i, peerCount; + const tr_peer ** peers; + tr_pex * pex; + tr_pex * walk; if( !isLocked ) torrentLock( (Torrent*)t ); - t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash ); peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount ); pex = walk = tr_new( tr_pex, peerCount ); @@ -1532,6 +1531,8 @@ getWeakConnections( Torrent * t, int * setmeSize ) const double throughput = (2*tr_peerIoGetRateToPeer( peer->io )) + tr_peerIoGetRateToClient( peer->io ); + assert( atom != NULL ); + /* if we're both seeds, give a little bit of time for * a mutual pex -- peer-msgs initiates a pex exchange * on startup -- and then disconnect */ diff --git a/libtransmission/trevent.c b/libtransmission/trevent.c index b6a53f9c0..e34e2aecf 100644 --- a/libtransmission/trevent.c +++ b/libtransmission/trevent.c @@ -66,7 +66,6 @@ enum mode TR_EV_EVHTTP_MAKE_REQUEST, TR_EV_BUFFEREVENT_SET, TR_EV_BUFFEREVENT_WRITE, - TR_EV_BUFFEREVENT_FREE, TR_EV_TIMER_ADD, TR_EV_TIMER_DEL, TR_EV_EXEC @@ -150,10 +149,6 @@ pumpList( int i UNUSED, short s UNUSED, void * veh ) tr_free( cmd->buf ); break; - case TR_EV_BUFFEREVENT_FREE: - bufferevent_free( cmd->bufev ); - break; - case TR_EV_EXEC: (cmd->func)( cmd->user_data ); break; @@ -417,39 +412,3 @@ tr_runInEventThread( struct tr_handle * handle, pushList( handle->events, cmd ); } } - - -/** -*** -**/ - -static int -bufCompareFunc( const void * va, const void * vb ) -{ - const struct tr_event_command * a = va; - const struct bufferevent * b = vb; - return a->bufev == b ? 0 : 1; -} - -void -tr_bufferevent_free( struct tr_handle * handle, - struct bufferevent * bufev ) -{ - void * v; - tr_event_handle * eh = handle->events; - - /* purge pending commands from the list */ - tr_lockLock( eh->lock ); - while(( v = tr_list_remove( &eh->commands, bufev, bufCompareFunc ) )) - tr_free( v ); - tr_lockUnlock( eh->lock ); - - if( tr_amInThread( handle->events->thread ) ) - bufferevent_free( bufev ); - else { - struct tr_event_command * cmd = tr_new0( struct tr_event_command, 1 ); - cmd->mode = TR_EV_BUFFEREVENT_FREE; - cmd->bufev = bufev; - pushList( handle->events, cmd ); - } -} diff --git a/libtransmission/trevent.h b/libtransmission/trevent.h index 51bf520d5..6beb4520e 100644 --- a/libtransmission/trevent.h +++ b/libtransmission/trevent.h @@ -41,9 +41,6 @@ void tr_bufferevent_write( struct tr_handle * tr_handle, const void * buf, size_t buflen ); -void tr_bufferevent_free( struct tr_handle * handle, - struct bufferevent * bufev ); - void tr_setBufferEventMode( struct tr_handle * tr_handle, struct bufferevent * bufferEvent,