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,26 +298,29 @@ 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())
if (dt < now) { dt = connection->lastPing() + ((m_host->m_pingTime * 1000) * (m_host->m_maxMissedPings * 2U));
LogInfoEx(LOG_NET, "PEER %u (%s) timed out, dt = %u, now = %u", id, connection->identity().c_str(), else
dt, now); dt = connection->lastPing() + ((m_host->m_pingTime * 1000) * m_host->m_maxMissedPings);
// set connection states for this stale connection if (dt < now) {
connection->connected(false); LogInfoEx(LOG_NET, "PEER %u (%s) timed out, dt = %u, now = %u", id, connection->identity().c_str(),
connection->connectionState(NET_STAT_INVALID); dt, now);
// if the connection was an external peer or a peer link -- be noisy about a possible // set connection states for this stale connection
// netsplit connection->connected(false);
if (connection->isExternalPeer() || connection->isPeerLink()) { connection->connectionState(NET_STAT_INVALID);
for (uint8_t i = 0U; i < 3U; i++)
LogWarning(LOG_NET, "PEER %u (%s) downstream netsplit, dt = %u, now = %u", id, connection->identity().c_str(), // if the connection was an external peer or a peer link -- be noisy about a possible
dt, now); // netsplit
} if (connection->isExternalPeer() || connection->isPeerLink()) {
for (uint8_t i = 0U; i < 3U; i++)
peersToRemove.push_back(id); LogWarning(LOG_NET, "PEER %u (%s) downstream netsplit, dt = %u, now = %u", id, connection->identity().c_str(),
dt, now);
} }
peersToRemove.push_back(id);
} }
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.