diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-01-29 17:24:55 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-01-29 17:24:55 -0800 |
commit | d75f2f7051c3d0b92cc801e32565b643a0bac4c0 (patch) | |
tree | f835e3e5cc213f2cab56f8581f2b069ec0109f69 /node | |
parent | aa1be9fcad28573db9ffcb341a5f571141da2968 (diff) | |
download | infinitytier-d75f2f7051c3d0b92cc801e32565b643a0bac4c0.tar.gz infinitytier-d75f2f7051c3d0b92cc801e32565b643a0bac4c0.zip |
SIGHUP now causes resync with peers.
Diffstat (limited to 'node')
-rw-r--r-- | node/Node.cpp | 15 | ||||
-rw-r--r-- | node/Node.hpp | 6 |
2 files changed, 20 insertions, 1 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 9fc8ee1f..106c508d 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -224,6 +224,7 @@ struct _NodeImpl volatile Node::ReasonForTermination reasonForTermination; volatile bool started; volatile bool running; + volatile bool resynchronize; inline Node::ReasonForTermination terminate() { @@ -359,6 +360,7 @@ Node::Node(const char *hp,unsigned int port,unsigned int controlPort) impl->reasonForTermination = Node::NODE_RUNNING; impl->started = false; impl->running = false; + impl->resynchronize = false; } Node::~Node() @@ -528,7 +530,11 @@ Node::ReasonForTermination Node::run() } uint64_t now = Utils::now(); - bool resynchronize = false; + bool resynchronize = impl->resynchronize; + if (resynchronize) { + LOG("manual resynchronize ordered, resyncing with network"); + } + impl->resynchronize = false; // If it looks like the computer slept and woke, resynchronize. if (lastDelayDelta >= ZT_SLEEP_WAKE_DETECTION_THRESHOLD) { @@ -657,6 +663,13 @@ void Node::terminate(ReasonForTermination reason,const char *reasonText) ((_NodeImpl *)_impl)->renv.mainLoopWaitCondition.signal(); } +void Node::resync() + throw() +{ + ((_NodeImpl *)_impl)->resynchronize = true; + ((_NodeImpl *)_impl)->renv.mainLoopWaitCondition.signal(); +} + class _VersionStringMaker { public: diff --git a/node/Node.hpp b/node/Node.hpp index 974a51b6..0eb96cae 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -181,6 +181,12 @@ public: throw(); /** + * Forget p2p links and resynchronize with peers + */ + void resync() + throw(); + + /** * Get the ZeroTier version in major.minor.revision string format * * @return Version in string form |