]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #3937 "inactive webseeds are listed as active"
authorJordan Lee <jordan@transmissionbt.com>
Sun, 23 Jan 2011 16:35:23 +0000 (16:35 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sun, 23 Jan 2011 16:35:23 +0000 (16:35 +0000)
This is caused by libtransmission using tr_webseedIsActive() in two ways: (1) webseed.c uses it to know if there are any pending requests, and (2) tr_torrentStat() uses it to set tr_stat.webseedsSendingToUs. Having a queued task isn't enough to be "active" in use (2) -- it needs to know if the webseed is actually sending data. These two uses should be moved into separate functions.

libtransmission/webseed.c

index 886742250ca8f234b9ed1a6ff3839869a91f1972..76d30be7dfc7b4e0fe83b05db103fef686ba8840 100644 (file)
@@ -124,12 +124,19 @@ on_content_changed( struct evbuffer                * buf UNUSED,
 
 static void task_request_next_chunk( struct tr_webseed_task * task );
 
+static tr_bool
+webseed_has_tasks( const tr_webseed * w )
+{
+    return w->tasks != NULL;
+}
+
+
 static void
 on_idle( tr_webseed * w )
 {
     tr_torrent * tor = tr_torrentFindFromId( w->session, w->torrent_id );
 
-    if( w->is_stopping && !tr_webseedIsActive( w ) )
+    if( w->is_stopping && !webseed_has_tasks( w ) )
     {
         webseed_free( w );
     }
@@ -258,17 +265,18 @@ task_request_next_chunk( struct tr_webseed_task * t )
 }
 
 tr_bool
-tr_webseedIsActive( const tr_webseed * w )
+tr_webseedGetSpeed_Bps( const tr_webseed * w, uint64_t now, int * setme_Bps )
 {
-    return w->tasks != NULL;
+    const tr_bool is_active = webseed_has_tasks( w );
+    *setme_Bps = is_active ? tr_rcRate_Bps( &w->download_rate, now ) : 0;
+    return is_active;
 }
 
 tr_bool
-tr_webseedGetSpeed_Bps( const tr_webseed * w, uint64_t now, int * setme_Bps )
+tr_webseedIsActive( const tr_webseed * w )
 {
-    const tr_bool is_active = tr_webseedIsActive( w );
-    *setme_Bps = is_active ? tr_rcRate_Bps( &w->download_rate, now ) : 0;
-    return is_active;
+    int Bps = 0;
+    return tr_webseedGetSpeed_Bps( w, tr_time_msec(), &Bps ) && ( Bps > 0 );
 }
 
 /***
@@ -317,7 +325,7 @@ tr_webseedFree( tr_webseed * w )
 {
     if( w )
     {
-        if( tr_webseedIsActive( w ) )
+        if( webseed_has_tasks( w ) )
             w->is_stopping = TRUE;
         else
             webseed_free( w );