#846: transmissioncli attempts to bind to port even when not needed

This commit is contained in:
Charles Kerr 2008-04-06 16:50:41 +00:00
parent d9ff2d6105
commit f42995c872
2 changed files with 7 additions and 1 deletions

View File

@ -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 */

View File

@ -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;