aboutsummaryrefslogtreecommitdiff
path: root/src/or/hibernate.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-05-09 12:11:14 -0400
committerNick Mathewson <nickm@torproject.org>2018-05-09 12:11:14 -0400
commit50328533e3595b9cc2d3fc72f81f56572c9e732d (patch)
treee7b19bf63087103c82d79bca1a4e9d371feec8ce /src/or/hibernate.c
parent0c19ce7bdece5906e035e71d3fb682632c8bb9cb (diff)
downloadtor-50328533e3595b9cc2d3fc72f81f56572c9e732d.tar.gz
tor-50328533e3595b9cc2d3fc72f81f56572c9e732d.zip
Add we_are_fully_hibernating() to distinguish hibernation states
We want to tell "shut down" from "shutting down".
Diffstat (limited to 'src/or/hibernate.c')
-rw-r--r--src/or/hibernate.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 98f32adb1c..f73b0420d3 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -877,13 +877,26 @@ hibernate_begin_shutdown(void)
hibernate_begin(HIBERNATE_STATE_EXITING, time(NULL));
}
-/** Return true iff we are currently hibernating. */
+/**
+ * Return true iff we are currently hibernating -- that is, if we are in
+ * any non-live state.
+ */
MOCK_IMPL(int,
we_are_hibernating,(void))
{
return hibernate_state != HIBERNATE_STATE_LIVE;
}
+/**
+ * Return true iff we are currently _fully_ hibernating -- that is, if we are
+ * in a state where we expect to handle no network activity at all.
+ */
+MOCK_IMPL(int,
+we_are_fully_hibernating,(void))
+{
+ return hibernate_state == HIBERNATE_STATE_DORMANT;
+}
+
/** If we aren't currently dormant, close all connections and become
* dormant. */
static void