refactor: harden idle_seconds (#6834)
* Hardening idle_seconds * code review: revert "size_t to time_t" because time_t isn't guaranted to be signed in the C spec
This commit is contained in:
parent
78027a8e5b
commit
acee39e15c
|
@ -446,7 +446,7 @@ void tr_torrent::stop_if_seed_limit_reached()
|
||||||
session->onRatioLimitHit(this);
|
session->onRatioLimitHit(this);
|
||||||
}
|
}
|
||||||
/* if we're seeding and reach our inactivity limit, stop the torrent */
|
/* if we're seeding and reach our inactivity limit, stop the torrent */
|
||||||
else if (auto const secs_left = idle_seconds_left(tr_time()); secs_left && *secs_left == 0U)
|
else if (auto const secs_left = idle_seconds_left(tr_time()); secs_left && *secs_left <= 0U)
|
||||||
{
|
{
|
||||||
tr_logAddInfoTor(this, _("Seeding idle limit reached; pausing torrent"));
|
tr_logAddInfoTor(this, _("Seeding idle limit reached; pausing torrent"));
|
||||||
|
|
||||||
|
|
|
@ -827,7 +827,7 @@ struct tr_torrent
|
||||||
if (auto const latest = std::max(date_started_, date_active_); latest != 0)
|
if (auto const latest = std::max(date_started_, date_active_); latest != 0)
|
||||||
{
|
{
|
||||||
TR_ASSERT(now >= latest);
|
TR_ASSERT(now >= latest);
|
||||||
return now - latest;
|
return static_cast<size_t>(std::max(now - latest, time_t{ 0 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue