1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

libtransmission:

Lazily bind the listening port to avoid spurious
 'Could not bind port 9090' error on startup.
This commit is contained in:
Josh Elsasser 2006-02-24 14:10:15 +00:00
parent ceefe97ce2
commit a2066e56bf

View file

@ -68,20 +68,9 @@ tr_handle_t * tr_init()
h->fdlimit = tr_fdInit();
h->choking = tr_chokingInit( h );
h->bindPort = TR_DEFAULT_PORT;
h->bindPort = -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;
tr_lockInit( &h->acceptLock );
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->tracker = tr_trackerInit( h, tor );
if( 0 > h->bindPort )
{
tr_setBindPort( h, TR_DEFAULT_PORT );
}
tor->date = tr_date();
tor->die = 0;
tr_threadCreate( &tor->thread, downloadLoop, tor );