From d9006712f6ffc975d97097caf2d2b4264405b32c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 21 May 2015 15:58:26 -0700 Subject: Completely factor out "desperation" from the core. I thought of a significantly simpler way to move all of this logic entirely into the containing service, liberating the core from any concern over the nature of its pipe to the outside world. --- node/Node.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'node/Node.cpp') diff --git a/node/Node.cpp b/node/Node.cpp index 8eb9ae90..6b3f1f2c 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -80,8 +80,7 @@ Node::Node( _startTimeAfterInactivity(0), _lastPingCheck(0), _lastHousekeepingRun(0), - _lastBeacon(0), - _coreDesperation(0) + _lastBeacon(0) { _newestVersionSeen[0] = ZEROTIER_ONE_VERSION_MAJOR; _newestVersionSeen[1] = ZEROTIER_ONE_VERSION_MINOR; @@ -155,13 +154,12 @@ Node::~Node() ZT1_ResultCode Node::processWirePacket( uint64_t now, const struct sockaddr_storage *remoteAddress, - unsigned int linkDesperation, const void *packetData, unsigned int packetLength, volatile uint64_t *nextBackgroundTaskDeadline) { _now = now; - RR->sw->onRemotePacket(*(reinterpret_cast(remoteAddress)),linkDesperation,packetData,packetLength); + RR->sw->onRemotePacket(*(reinterpret_cast(remoteAddress)),packetData,packetLength); return ZT1_RESULT_OK; } @@ -219,8 +217,7 @@ ZT1_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *next if ((now - _lastPingCheck) >= ZT_PING_CHECK_INVERVAL) { _lastPingCheck = now; - // This is used as a floor for the desperation and online status - // calculations if we just started up or have been asleep. + // This is used to compute whether we appear to be "online" or not if ((now - _startTimeAfterInactivity) > (ZT_PING_CHECK_INVERVAL * 3)) _startTimeAfterInactivity = now; @@ -229,7 +226,6 @@ ZT1_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *next RR->topology->eachPeer<_PingPeersThatNeedPing &>(pfunc); const uint64_t lastActivityAgo = now - std::max(_startTimeAfterInactivity,pfunc.lastReceiveFromUpstream); - _coreDesperation = (unsigned int)(lastActivityAgo / (ZT_PING_CHECK_INVERVAL * ZT_CORE_DESPERATION_INCREMENT)); bool oldOnline = _online; _online = (lastActivityAgo < ZT_PEER_ACTIVITY_TIMEOUT); if (oldOnline != _online) @@ -257,7 +253,7 @@ ZT1_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *next *(reinterpret_cast(p)) = RR->prng->next32(); RR->identity.address().copyTo(beacon + 8,5); RR->antiRec->logOutgoingZT(beacon,13); - putPacket(ZT_DEFAULTS.v4Broadcast,beacon,13,0); + putPacket(ZT_DEFAULTS.v4Broadcast,beacon,13); } } @@ -528,13 +524,12 @@ enum ZT1_ResultCode ZT1_Node_processWirePacket( ZT1_Node *node, uint64_t now, const struct sockaddr_storage *remoteAddress, - unsigned int linkDesperation, const void *packetData, unsigned int packetLength, volatile uint64_t *nextBackgroundTaskDeadline) { try { - return reinterpret_cast(node)->processWirePacket(now,remoteAddress,linkDesperation,packetData,packetLength,nextBackgroundTaskDeadline); + return reinterpret_cast(node)->processWirePacket(now,remoteAddress,packetData,packetLength,nextBackgroundTaskDeadline); } catch (std::bad_alloc &exc) { return ZT1_RESULT_FATAL_ERROR_OUT_OF_MEMORY; } catch ( ... ) { -- cgit v1.2.3