mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
libtransmission:
Lazily bind the listening port to avoid spurious 'Could not bind port 9090' error on startup.
This commit is contained in:
parent
ceefe97ce2
commit
a2066e56bf
1 changed files with 6 additions and 12 deletions
|
@ -68,20 +68,9 @@ tr_handle_t * tr_init()
|
||||||
h->fdlimit = tr_fdInit();
|
h->fdlimit = tr_fdInit();
|
||||||
h->choking = tr_chokingInit( h );
|
h->choking = tr_chokingInit( h );
|
||||||
|
|
||||||
h->bindPort = TR_DEFAULT_PORT;
|
h->bindPort = -1;
|
||||||
h->bindSocket = -1;
|
h->bindSocket = -1;
|
||||||
|
|
||||||
#ifndef BEOS_NETSERVER
|
|
||||||
/* BeOS net_server seems to be unable to set incoming connections to
|
|
||||||
non-blocking. Too bad. */
|
|
||||||
if( !tr_fdSocketWillCreate( h->fdlimit, 0 ) )
|
|
||||||
{
|
|
||||||
/* XXX should handle failure here in a better way */
|
|
||||||
h->bindSocket = tr_netBind( h->bindPort );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
h->acceptDie = 0;
|
h->acceptDie = 0;
|
||||||
tr_lockInit( &h->acceptLock );
|
tr_lockInit( &h->acceptLock );
|
||||||
tr_threadCreate( &h->acceptThread, acceptLoop, h );
|
tr_threadCreate( &h->acceptThread, acceptLoop, h );
|
||||||
|
@ -302,6 +291,11 @@ void tr_torrentStart( tr_handle_t * h, int t )
|
||||||
tor->status = TR_STATUS_CHECK;
|
tor->status = TR_STATUS_CHECK;
|
||||||
tor->tracker = tr_trackerInit( h, tor );
|
tor->tracker = tr_trackerInit( h, tor );
|
||||||
|
|
||||||
|
if( 0 > h->bindPort )
|
||||||
|
{
|
||||||
|
tr_setBindPort( h, TR_DEFAULT_PORT );
|
||||||
|
}
|
||||||
|
|
||||||
tor->date = tr_date();
|
tor->date = tr_date();
|
||||||
tor->die = 0;
|
tor->die = 0;
|
||||||
tr_threadCreate( &tor->thread, downloadLoop, tor );
|
tr_threadCreate( &tor->thread, downloadLoop, tor );
|
||||||
|
|
Loading…
Reference in a new issue