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/udp/Socket.h"
#include "Log.h"
#include "Thread.h"
#include "Utils.h"
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 (m_queueFlushing) {
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];

@ -298,26 +298,29 @@ void FNENetwork::clock(uint32_t ms)
uint32_t id = peer.first;
FNEPeerConnection* connection = peer.second;
if (connection != nullptr) {
if (connection->connected()) {
uint64_t dt = connection->lastPing() + ((m_host->m_pingTime * 1000) * m_host->m_maxMissedPings);
if (dt < now) {
LogInfoEx(LOG_NET, "PEER %u (%s) timed out, dt = %u, now = %u", id, connection->identity().c_str(),
dt, now);
// set connection states for this stale connection
connection->connected(false);
connection->connectionState(NET_STAT_INVALID);
// if the connection was an external peer or a peer link -- be noisy about a possible
// netsplit
if (connection->isExternalPeer() || connection->isPeerLink()) {
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(),
dt, now);
}
peersToRemove.push_back(id);
uint64_t dt = 0U;
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) {
LogInfoEx(LOG_NET, "PEER %u (%s) timed out, dt = %u, now = %u", id, connection->identity().c_str(),
dt, now);
// set connection states for this stale connection
connection->connected(false);
connection->connectionState(NET_STAT_INVALID);
// if the connection was an external peer or a peer link -- be noisy about a possible
// netsplit
if (connection->isExternalPeer() || connection->isPeerLink()) {
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(),
dt, now);
}
peersToRemove.push_back(id);
}
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.