fix: do not crash when pruning idle peer atoms (#3182)

This commit is contained in:
Charles Kerr 2022-06-02 10:00:12 -05:00 committed by GitHub
parent 654bc409d7
commit c2cd09d8d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -2548,6 +2548,7 @@ static void bandwidthPulse(evutil_socket_t /*fd*/, short /*what*/, void* vmgr)
**** ****
***/ ***/
#if 0
static auto getMaxAtomCount(tr_torrent const* tor) static auto getMaxAtomCount(tr_torrent const* tor)
{ {
static auto constexpr Limit = uint16_t{ 50 }; static auto constexpr Limit = uint16_t{ 50 };
@ -2618,12 +2619,14 @@ struct CompareAtomsByActivity
private: private:
tr_swarm const& swarm_; tr_swarm const& swarm_;
}; };
#endif
static void atomPulse(evutil_socket_t /*fd*/, short /*what*/, void* vmgr) static void atomPulse(evutil_socket_t /*fd*/, short /*what*/, void* vmgr)
{ {
auto* mgr = static_cast<tr_peerMgr*>(vmgr); auto* mgr = static_cast<tr_peerMgr*>(vmgr);
auto const lock = mgr->unique_lock(); auto const lock = mgr->unique_lock();
#if 0
for (auto* const tor : mgr->session->torrents()) for (auto* const tor : mgr->session->torrents())
{ {
// do we have too many atoms? // do we have too many atoms?
@ -2646,6 +2649,7 @@ static void atomPulse(evutil_socket_t /*fd*/, short /*what*/, void* vmgr)
tor->swarm, tor->swarm,
fmt::format("max atom count is {}... pruned from {} to {}", max_atom_count, atom_count, std::size(atoms))); fmt::format("max atom count is {}... pruned from {} to {}", max_atom_count, atom_count, std::size(atoms)));
} }
#endif
tr_timerAddMsec(*mgr->atomTimer, AtomPeriodMsec); tr_timerAddMsec(*mgr->atomTimer, AtomPeriodMsec);
} }