[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add we_are_fully_hibernating() to distinguish hibernation states
commit 50328533e3595b9cc2d3fc72f81f56572c9e732d
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed May 9 12:11:14 2018 -0400
Add we_are_fully_hibernating() to distinguish hibernation states
We want to tell "shut down" from "shutting down".
---
src/or/hibernate.c | 15 ++++++++++++++-
src/or/hibernate.h | 1 +
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 98f32adb1..f73b0420d 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
diff --git a/src/or/hibernate.h b/src/or/hibernate.h
index 85fb42864..84558bb2f 100644
--- a/src/or/hibernate.h
+++ b/src/or/hibernate.h
@@ -25,6 +25,7 @@ void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
int accounting_record_bandwidth_usage(time_t now, or_state_t *state);
void hibernate_begin_shutdown(void);
MOCK_DECL(int, we_are_hibernating, (void));
+MOCK_DECL(int, we_are_fully_hibernating,(void));
void consider_hibernation(time_t now);
int getinfo_helper_accounting(control_connection_t *conn,
const char *question, char **answer,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits