diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index 569f112b8..73eea85a2 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -85,7 +85,7 @@ tr_handle_t * tr_init() **********************************************************************/ void tr_setBindPort( tr_handle_t * h, int port ) { - int sock; + int sock = -1; tr_torrent_t * tor; if( h->bindPort == port ) @@ -252,6 +252,11 @@ tr_torrent_t * tr_torrentInit( tr_handle_t * h, const char * path, (h->torrentCount)++; tr_lockUnlock( &h->acceptLock ); + if( 0 > h->bindPort ) + { + tr_setBindPort( h, TR_DEFAULT_PORT ); + } + return tor; } @@ -289,11 +294,6 @@ void tr_torrentStart( tr_torrent_t * tor ) tor->status = TR_STATUS_CHECK; tor->tracker = tr_trackerInit( tor ); - if( 0 > h->bindPort ) - { - tr_setBindPort( h, TR_DEFAULT_PORT ); - } - tor->date = tr_date(); tor->die = 0; tr_threadCreate( &tor->thread, downloadLoop, tor );