revert e6188b2, use a loop instead the lock blocking wasn't consistent; fix issue where the FNE wouldn't check the heartbeat state of a peer that wasn't in a complete running state causing the peer to get into weird states; modify peer timeout handler, external peers (i.e. ISSI or upstream) and peer link peers get double the alotted maximum missed before being dropped;

pull/85/head
Bryan Biedenkapp 10 months ago
parent e6188b21aa
commit 8ebae02615

@ -11,6 +11,7 @@
#include "network/RawFrameQueue.h" #include "network/RawFrameQueue.h"
#include "network/udp/Socket.h" #include "network/udp/Socket.h"
#include "Log.h" #include "Log.h"
#include "Thread.h"
#include "Utils.h" #include "Utils.h"
using namespace network; using namespace network;
@ -118,7 +119,8 @@ void RawFrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, sock
// if the queue is flushing -- don't attempt to enqueue any messages // if the queue is flushing -- don't attempt to enqueue any messages
if (m_queueFlushing) { if (m_queueFlushing) {
LogWarning(LOG_NET, "RawFrameQueue::enqueueMessage() -- queue is flushing, waiting to enqueue message"); LogWarning(LOG_NET, "RawFrameQueue::enqueueMessage() -- queue is flushing, waiting to enqueue message");
std::lock_guard<std::mutex> lock(m_queueMutex); while (m_queueFlushing)
Thread::sleep(2U);
} }
uint8_t* buffer = new uint8_t[length]; uint8_t* buffer = new uint8_t[length];

@ -298,8 +298,12 @@ void FNENetwork::clock(uint32_t ms)
uint32_t id = peer.first; uint32_t id = peer.first;
FNEPeerConnection* connection = peer.second; FNEPeerConnection* connection = peer.second;
if (connection != nullptr) { if (connection != nullptr) {
if (connection->connected()) { uint64_t dt = 0U;
uint64_t dt = connection->lastPing() + ((m_host->m_pingTime * 1000) * m_host->m_maxMissedPings); if (connection->isExternalPeer() || connection->isPeerLink())
dt = connection->lastPing() + ((m_host->m_pingTime * 1000) * (m_host->m_maxMissedPings * 2U));
else
dt = connection->lastPing() + ((m_host->m_pingTime * 1000) * m_host->m_maxMissedPings);
if (dt < now) { if (dt < now) {
LogInfoEx(LOG_NET, "PEER %u (%s) timed out, dt = %u, now = %u", id, connection->identity().c_str(), LogInfoEx(LOG_NET, "PEER %u (%s) timed out, dt = %u, now = %u", id, connection->identity().c_str(),
dt, now); dt, now);
@ -320,7 +324,6 @@ void FNENetwork::clock(uint32_t ms)
} }
} }
} }
}
// remove any peers // remove any peers
for (uint32_t peerId : peersToRemove) { for (uint32_t peerId : peersToRemove) {

Loading…
Cancel
Save

Powered by TurnKey Linux.