mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-24 15:16:40 +00:00
Back off from thrashing shutdownIfUnreadableCheck, fix bug in control service.
This commit is contained in:
parent
2762db8408
commit
6b76cac6cf
@ -71,6 +71,7 @@ void NodeControlService::threadMain()
|
|||||||
} else if ((_node->initialized())&&(_node->address())) {
|
} else if ((_node->initialized())&&(_node->address())) {
|
||||||
Utils::snprintf(tmp,sizeof(tmp),"%s%.10llx",ZT_IPC_ENDPOINT_BASE,(unsigned long long)_node->address());
|
Utils::snprintf(tmp,sizeof(tmp),"%s%.10llx",ZT_IPC_ENDPOINT_BASE,(unsigned long long)_node->address());
|
||||||
_listener = new IpcListener(tmp,&_CBcommandHandler,this);
|
_listener = new IpcListener(tmp,&_CBcommandHandler,this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Thread::sleep(100); // wait for Node to start
|
Thread::sleep(100); // wait for Node to start
|
||||||
}
|
}
|
||||||
|
@ -471,6 +471,7 @@ Node::ReasonForTermination Node::run()
|
|||||||
uint64_t lastSupernodePingCheck = 0;
|
uint64_t lastSupernodePingCheck = 0;
|
||||||
uint64_t lastBeacon = 0;
|
uint64_t lastBeacon = 0;
|
||||||
uint64_t lastRootTopologyFetch = 0;
|
uint64_t lastRootTopologyFetch = 0;
|
||||||
|
uint64_t lastShutdownIfUnreadableCheck = 0;
|
||||||
long lastDelayDelta = 0;
|
long lastDelayDelta = 0;
|
||||||
|
|
||||||
uint64_t networkConfigurationFingerprint = 0;
|
uint64_t networkConfigurationFingerprint = 0;
|
||||||
@ -480,22 +481,25 @@ Node::ReasonForTermination Node::run()
|
|||||||
_r->initialized = true;
|
_r->initialized = true;
|
||||||
|
|
||||||
while (impl->reasonForTermination == NODE_RUNNING) {
|
while (impl->reasonForTermination == NODE_RUNNING) {
|
||||||
|
uint64_t now = Utils::now();
|
||||||
|
bool resynchronize = false;
|
||||||
|
|
||||||
/* This is how the service automatically shuts down when the OSX .app is
|
/* This is how the service automatically shuts down when the OSX .app is
|
||||||
* thrown in the trash. It's not used on any other platform for now but
|
* thrown in the trash. It's not used on any other platform for now but
|
||||||
* could do similar things. It's disabled on Windows since it doesn't really
|
* could do similar things. It's disabled on Windows since it doesn't really
|
||||||
* work there. */
|
* work there. */
|
||||||
#ifdef __UNIX_LIKE__
|
#ifdef __UNIX_LIKE__
|
||||||
|
if ((now - lastShutdownIfUnreadableCheck) > 10000) {
|
||||||
|
lastShutdownIfUnreadableCheck = now;
|
||||||
if (Utils::fileExists(shutdownIfUnreadablePath.c_str(),false)) {
|
if (Utils::fileExists(shutdownIfUnreadablePath.c_str(),false)) {
|
||||||
FILE *tmpf = fopen(shutdownIfUnreadablePath.c_str(),"r");
|
int tmpfd = ::open(shutdownIfUnreadablePath.c_str(),O_RDONLY,0);
|
||||||
if (!tmpf)
|
if (tmpfd < 0)
|
||||||
return impl->terminateBecause(Node::NODE_NORMAL_TERMINATION,"shutdownIfUnreadable exists but is not readable");
|
return impl->terminateBecause(Node::NODE_NORMAL_TERMINATION,"shutdownIfUnreadable exists but is not readable");
|
||||||
fclose(tmpf);
|
else ::close(tmpfd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint64_t now = Utils::now();
|
|
||||||
bool resynchronize = false;
|
|
||||||
|
|
||||||
// If it looks like the computer slept and woke, resynchronize.
|
// If it looks like the computer slept and woke, resynchronize.
|
||||||
if (lastDelayDelta >= ZT_SLEEP_WAKE_DETECTION_THRESHOLD) {
|
if (lastDelayDelta >= ZT_SLEEP_WAKE_DETECTION_THRESHOLD) {
|
||||||
resynchronize = true;
|
resynchronize = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user