From a2066e56bf7bfc69c97b4eac0138e20a7d9279fb Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Fri, 24 Feb 2006 14:10:15 +0000 Subject: [PATCH] libtransmission: Lazily bind the listening port to avoid spurious 'Could not bind port 9090' error on startup. --- libtransmission/transmission.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index 6f22c8b41..51dc15698 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -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 );