aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/or/circuitpadding.c9
-rw-r--r--src/feature/hibernate/hibernate.h1
-rw-r--r--src/test/test_circuitpadding.c7
3 files changed, 16 insertions, 1 deletions
diff --git a/src/core/or/circuitpadding.c b/src/core/or/circuitpadding.c
index 2895d49e18..599d88f493 100644
--- a/src/core/or/circuitpadding.c
+++ b/src/core/or/circuitpadding.c
@@ -48,6 +48,7 @@
#include "core/or/circuitpadding.h"
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
+#include "core/mainloop/netstatus.h"
#include "core/or/relay.h"
#include "feature/stats/rephist.h"
#include "feature/nodelist/networkstatus.h"
@@ -965,7 +966,7 @@ circpad_send_padding_cell_for_callback(circpad_machine_state_t *mi)
mi->padding_scheduled_at_usec = 0;
circpad_statenum_t state = mi->current_state;
- // Make sure circuit didn't close on us
+ /* Make sure circuit didn't close on us */
if (mi->on_circ->marked_for_close) {
log_fn(LOG_INFO,LD_CIRC,
"Padding callback on a circuit marked for close. Ignoring.");
@@ -1157,6 +1158,12 @@ circpad_machine_schedule_padding,(circpad_machine_state_t *mi))
struct timeval timeout;
tor_assert(mi);
+ /* Don't schedule padding if we are currently in dormant mode. */
+ if (!is_participating_on_network()) {
+ log_info(LD_CIRC, "Not scheduling padding because we are dormant.");
+ return CIRCPAD_STATE_UNCHANGED;
+ }
+
// Don't pad in end (but also don't cancel any previously
// scheduled padding either).
if (mi->current_state == CIRCPAD_STATE_END) {
diff --git a/src/feature/hibernate/hibernate.h b/src/feature/hibernate/hibernate.h
index 3309ef0ce3..2e245f6ab1 100644
--- a/src/feature/hibernate/hibernate.h
+++ b/src/feature/hibernate/hibernate.h
@@ -32,6 +32,7 @@ int getinfo_helper_accounting(control_connection_t *conn,
const char **errmsg);
uint64_t get_accounting_max_total(void);
void accounting_free_all(void);
+bool accounting_tor_is_dormant(void);
#ifdef HIBERNATE_PRIVATE
/** Possible values of hibernate_state */
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index 1976e54bb9..ba58cd0d97 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -17,6 +17,7 @@
#include "core/or/circuitlist.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitpadding.h"
+#include "core/mainloop/netstatus.h"
#include "core/crypto/relay_crypto.h"
#include "core/or/protover.h"
#include "feature/nodelist/nodelist.h"
@@ -1021,6 +1022,9 @@ test_circuitpadding_tokens(void *arg)
monotime_coarse_set_mock_time_nsec(1*TOR_NSEC_PER_USEC);
curr_mocked_time = 1*TOR_NSEC_PER_USEC;
+ /* This is needed so that we are not considered to be dormant */
+ note_user_activity(20);
+
timers_initialize();
helper_create_basic_machine();
@@ -1750,6 +1754,9 @@ test_circuitpadding_conditions(void *arg)
monotime_coarse_set_mock_time_nsec(1*TOR_NSEC_PER_USEC);
curr_mocked_time = 1*TOR_NSEC_PER_USEC;
+ /* This is needed so that we are not considered to be dormant */
+ note_user_activity(20);
+
timers_initialize();
helper_create_conditional_machines();