1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-22 07:42:37 +00:00

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:
Cœur 2024-06-02 06:41:44 +08:00 committed by GitHub
parent 78027a8e5b
commit acee39e15c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -446,7 +446,7 @@ void tr_torrent::stop_if_seed_limit_reached()
session->onRatioLimitHit(this);
}
/* 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"));

View file

@ -827,7 +827,7 @@ struct tr_torrent
if (auto const latest = std::max(date_started_, date_active_); latest != 0)
{
TR_ASSERT(now >= latest);
return now - latest;
return static_cast<size_t>(std::max(now - latest, time_t{ 0 }));
}
}