Merge pull request #11066

0bf3e67 epee: replace some fragile code (jpk68)

ACKs: selsta, SNeedlewoods
This commit is contained in:
tobtoht
2026-08-17 09:19:06 +00:00
2 changed files with 6 additions and 3 deletions
@@ -87,7 +87,8 @@ namespace net_utils
static std::mutex hosts_mutex;
std::lock_guard<std::mutex> guard(hosts_mutex);
static std::map<std::string, unsigned int> hosts;
unsigned int &val = hosts[m_host];
auto it = hosts.emplace(m_host, 0).first;
unsigned int &val = it->second;
if (delta > 0)
MTRACE("New connection from host " << m_host << ": " << val);
else if (delta < 0)
@@ -95,7 +96,9 @@ namespace net_utils
CHECK_AND_ASSERT_THROW_MES(delta >= 0 || val >= (unsigned)-delta, "Count would go negative");
CHECK_AND_ASSERT_THROW_MES(delta <= 0 || val <= std::numeric_limits<unsigned int>::max() - (unsigned)delta, "Count would wrap");
val += delta;
return val;
const unsigned int ret = val;
if (ret == 0) hosts.erase(it);
return ret;
}
template<typename T>
+1 -1
View File
@@ -345,7 +345,7 @@ size_t network_throttle::get_recommended_size_of_planned_transport() const {
double network_throttle::get_current_speed() const {
unsigned int bytes_transferred = 0;
if (m_history.size() == 0 || m_slot_size == 0)
if (m_history.size() <= 1 || m_slot_size == 0)
return 0;
auto it = m_history.begin();