Browse Source

don't select overloaded peer

pull/1833/head
orignal 2 years ago
parent
commit
6942c20879
  1. 6
      libi2pd/Transports.cpp
  2. 3
      libi2pd/Transports.h

6
libi2pd/Transports.cpp

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2022, The PurpleI2P Project
* Copyright (c) 2013-2023, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@ -823,7 +823,9 @@ namespace transport @@ -823,7 +823,9 @@ namespace transport
std::unique_lock<std::mutex> l(m_PeersMutex);
auto it = m_Peers.begin ();
std::advance (it, rand () % m_Peers.size ());
if (it == m_Peers.end () || it->second.router) return nullptr; // not connected
if (it == m_Peers.end () || it->second.router || it->second.sessions.empty () ||
it->second.sessions.front ()->GetSendQueueSize () > PEER_ROUTER_INFO_OVERLOAD_QUEUE_SIZE)
return nullptr; // not connected or overloaded
ident = it->first;
}
return i2p::data::netdb.FindRouter (ident);

3
libi2pd/Transports.h

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2022, The PurpleI2P Project
* Copyright (c) 2013-2023, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@ -63,6 +63,7 @@ namespace transport @@ -63,6 +63,7 @@ namespace transport
const int PEER_ROUTER_INFO_UPDATE_INTERVAL = 31*60; // in seconds
const int PEER_ROUTER_INFO_UPDATE_INTERVAL_VARIANCE = 7*60; // in seconds
const size_t PEER_ROUTER_INFO_OVERLOAD_QUEUE_SIZE = 25;
struct Peer
{
int numAttempts;

Loading…
Cancel
Save