summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-11-21 16:34:27 -0500
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-11-21 16:34:27 -0500
commitb699bdefbd008a5dbfab4308e9b969b2aaa88ce1 (patch)
treeffcdbca9f667f72fd195d3087d7886db39505ad2 /node/Node.cpp
parent74af234305a3758589112212b4c270756fa73243 (diff)
downloadinfinitytier-b699bdefbd008a5dbfab4308e9b969b2aaa88ce1.tar.gz
infinitytier-b699bdefbd008a5dbfab4308e9b969b2aaa88ce1.zip
Add shutdownIfUnreadable file feature: shut down if shutdownIfUnreadable in home folder is in fact existent but unreadable (e.g. broken link). This enables nifty shutdown on .app trashing feature for OSX.
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index c88741a6..f2668e4e 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -467,6 +467,7 @@ Node::ReasonForTermination Node::run()
// Core I/O loop
try {
+ std::string shutdownIfUnreadablePath(_r->homePath + ZT_PATH_SEPARATOR_S + "shutdownIfUnreadable");
uint64_t lastNetworkAutoconfCheck = Utils::now() - 5000; // check autoconf again after 5s for startup
uint64_t lastPingCheck = 0;
uint64_t lastClean = Utils::now(); // don't need to do this immediately
@@ -476,6 +477,13 @@ Node::ReasonForTermination Node::run()
long lastDelayDelta = 0;
while (impl->reasonForTermination == NODE_RUNNING) {
+ if (Utils::fileExists(shutdownIfUnreadablePath.c_str(),false)) {
+ FILE *tmpf = fopen(shutdownIfUnreadablePath.c_str(),"r");
+ if (!tmpf)
+ return impl->terminateBecause(Node::NODE_NORMAL_TERMINATION,"shutdownIfUnreadable was not readable");
+ fclose(tmpf);
+ }
+
uint64_t now = Utils::now();
bool resynchronize = false;