From b699bdefbd008a5dbfab4308e9b969b2aaa88ce1 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 21 Nov 2013 16:34:27 -0500 Subject: 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. --- node/Node.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'node/Node.cpp') 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; -- cgit v1.2.3