From f42995c872a7bd68de6da4921b1165bdf41cb756 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 6 Apr 2008 16:50:41 +0000 Subject: [PATCH] #846: transmissioncli attempts to bind to port even when not needed --- cli/transmissioncli.c | 5 +++++ libtransmission/shared.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/transmissioncli.c b/cli/transmissioncli.c index f5597673c..4dc68511d 100644 --- a/cli/transmissioncli.c +++ b/cli/transmissioncli.c @@ -139,6 +139,11 @@ main( int argc, char ** argv ) return EXIT_FAILURE; } + /* don't bind the port if we're just running the CLI + * to get metainfo or to create a torrent */ + if( showInfo || ( sourceFile != NULL ) ) + bindPort = -1; + /* Initialize libtransmission */ h = tr_initFull( tr_getDefaultConfigDir(), "cli", /* tag */ diff --git a/libtransmission/shared.c b/libtransmission/shared.c index a02239b01..6b13984ae 100644 --- a/libtransmission/shared.c +++ b/libtransmission/shared.c @@ -110,11 +110,12 @@ incomingPeersPulse( tr_shared * s ) s->bindSocket = -1; } - if( s->bindPort != s->publicPort ) + if( ( s->publicPort > 0 ) && ( s->bindPort != s->publicPort ) ) { int socket; errno = 0; socket = tr_netBindTCP( s->publicPort ); +fprintf( stderr, "opening socket on %d to listen\n", s->publicPort ); if( socket >= 0 ) { tr_ninf( getKey(), _( "Opened port %d to listen for incoming peer connections" ), s->publicPort ); s->bindPort = s->publicPort;