]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #3208 "Local Peer Discovery idea: prioritize LPD requests for downloads...
authorJordan Lee <jordan@transmissionbt.com>
Fri, 4 Mar 2011 17:33:29 +0000 (17:33 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Fri, 4 Mar 2011 17:33:29 +0000 (17:33 +0000)
libtransmission/announcer.c
libtransmission/tr-lpd.c

index abc0b024a23bc35d8bd468d58a831d407d55998a..430aa2dc5583c3a04c85aedd5593a916595f5f79 100644 (file)
@@ -63,7 +63,7 @@ enum
     UPKEEP_INTERVAL_SECS = 1,
 
     /* this is an upper limit for the frequency of LDS announces */
-    LPD_HOUSEKEEPING_INTERVAL_SECS = 30
+    LPD_HOUSEKEEPING_INTERVAL_SECS = 5
 
 };
 
index f18524b688757c912a1e2fff48707c7db8f936cc..bffcbe5ae112affa954dd69a08a8e8694c1fb98f 100644 (file)
@@ -552,17 +552,32 @@ int tr_lpdAnnounceMore( const time_t now, const int interval )
     {
         if( tr_isTorrent( tor ) )
         {
-            if( !tr_torrentAllowsLPD( tor ) || (
-                    ( tr_torrentGetActivity( tor ) != TR_STATUS_DOWNLOAD ) &&
-                    ( tr_torrentGetActivity( tor ) != TR_STATUS_SEED ) ) )
+            int announcePrio = 0;
+
+            if( !tr_torrentAllowsLPD( tor ) )
                 continue;
 
-            if( tor->lpdAnnounceAt <= now )
+            /* issue #3208: prioritize downloads before seeds */
+            switch( tr_torrentGetActivity( tor ) )
+            {
+            case TR_STATUS_DOWNLOAD:
+                announcePrio = 1;
+                break;
+            case TR_STATUS_SEED:
+                announcePrio = 2;
+                break;
+            default: /* fall through */
+                break;
+            }
+
+            if( announcePrio > 0 && tor->lpdAnnounceAt <= now )
             {
                 if( tr_lpdSendAnnounce( tor ) )
                     announcesSent++;
 
-                tor->lpdAnnounceAt = now + lpd_announceInterval;
+                tor->lpdAnnounceAt = now +
+                    lpd_announceInterval * announcePrio;
+
                 break; /* that's enough; for this interval */
             }
         }