]> granicus.if.org Git - transmission/commitdiff
#846: transmissioncli attempts to bind to port even when not needed
authorCharles Kerr <charles@transmissionbt.com>
Sun, 6 Apr 2008 16:50:41 +0000 (16:50 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sun, 6 Apr 2008 16:50:41 +0000 (16:50 +0000)
cli/transmissioncli.c
libtransmission/shared.c

index f5597673c4f5b1ba51da810e69a7361336bdf35c..4dc68511d0f02659d1123c4d0a10a20ea8e53062 100644 (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 */
index a02239b01ce2a299ba6345ee7a1441c319387a74..6b13984aee38b69dda517f34f6bdfb874e87fea7 100644 (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;