]> granicus.if.org Git - transmission/commitdiff
(libT) #1398: don't accept incoming peer connections when all torrents are paused
authorCharles Kerr <charles@transmissionbt.com>
Tue, 2 Dec 2008 22:25:51 +0000 (22:25 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Tue, 2 Dec 2008 22:25:51 +0000 (22:25 +0000)
libtransmission/port-forwarding.c

index 4cdf118f1a793651b0d61f0a6787159c3a1c0162..7c6dac8eac5caf93028bf593adc6c03563a76e3c 100644 (file)
@@ -103,6 +103,9 @@ natPulse( tr_shared * s )
 static void
 incomingPeersPulse( tr_shared * s )
 {
+    int allPaused;
+    tr_torrent * tor;
+
     if( s->bindSocket >= 0 && ( s->bindPort != s->publicPort ) )
     {
         tr_ninf( getKey( ), _( "Closing port %d" ), s->bindPort );
@@ -136,7 +139,18 @@ incomingPeersPulse( tr_shared * s )
         }
     }
 
-    for( ; ; ) /* check for new incoming peer connections */
+    /* see if any torrents aren't paused */ 
+    allPaused = 1; 
+    tor = NULL; 
+    while(( tor = tr_torrentNext( s->session, tor ))) { 
+        if( TR_STATUS_IS_ACTIVE( tr_torrentGetActivity( tor ))) { 
+            allPaused = 0; 
+            break; 
+        } 
+    } 
+
+    /* if we have any running torrents, check for new incoming peer connections */ 
+    while( !allPaused )  
     {
         int         socket;
         tr_port     port;