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 );
}
}
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 );
}
/***
{
if( w )
{
- if( tr_webseedIsActive( w ) )
+ if( webseed_has_tasks( w ) )
w->is_stopping = TRUE;
else
webseed_free( w );