aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2012-10-01 20:27:51 -0700
committerAndrea Shepard <andrea@torproject.org>2012-10-10 00:44:47 -0700
commit9d615cc5c0a645060781797b23a73df158a1dfb6 (patch)
tree95f1bf0aa1b2c6ddf36942252c2d60453b789905 /src/or
parentbb62281ba48d946e2f948a9c3088f1d0ca481d57 (diff)
downloadtor-9d615cc5c0a645060781797b23a73df158a1dfb6.tar
tor-9d615cc5c0a645060781797b23a73df158a1dfb6.tar.gz
Set circuitmux policy on existing active channels when ewma_enabled changes
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c11
-rw-r--r--src/or/networkstatus.c16
2 files changed, 26 insertions, 1 deletions
diff --git a/src/or/config.c b/src/or/config.c
index babbfb0a9..81528c827 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -12,6 +12,7 @@
#define CONFIG_PRIVATE
#include "or.h"
+#include "channel.h"
#include "circuitbuild.h"
#include "circuitlist.h"
#include "circuitmux.h"
@@ -1169,6 +1170,7 @@ options_act(const or_options_t *old_options)
char *msg=NULL;
const int transition_affects_workers =
old_options && options_transition_affects_workers(old_options, options);
+ int old_ewma_enabled;
/* disable ptrace and later, other basic debugging techniques */
{
@@ -1376,8 +1378,17 @@ options_act(const or_options_t *old_options)
connection_bucket_init();
#endif
+ old_ewma_enabled = cell_ewma_enabled();
/* Change the cell EWMA settings */
cell_ewma_set_scale_factor(options, networkstatus_get_latest_consensus());
+ /* If we just enabled ewma, set the cmux policy on all active channels */
+ if (cell_ewma_enabled() && !old_ewma_enabled) {
+ channel_set_cmux_policy_everywhere(&ewma_policy);
+ } else if (!cell_ewma_enabled() && old_ewma_enabled) {
+ /* Turn it off everywhere */
+ channel_set_cmux_policy_everywhere(NULL);
+ }
+
/* Update the BridgePassword's hashed version as needed. We store this as a
* digest so that we can do side-channel-proof comparisons on it.
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 619099b82..0f6161e2e 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -11,6 +11,7 @@
*/
#include "or.h"
+#include "channel.h"
#include "circuitbuild.h"
#include "circuitmux.h"
#include "circuitmux_ewma.h"
@@ -1636,6 +1637,7 @@ networkstatus_set_current_consensus(const char *consensus,
consensus_waiting_for_certs_t *waiting = NULL;
time_t current_valid_after = 0;
int free_consensus = 1; /* Free 'c' at the end of the function */
+ int old_ewma_enabled;
if (flav < 0) {
/* XXXX we don't handle unrecognized flavors yet. */
@@ -1829,7 +1831,19 @@ networkstatus_set_current_consensus(const char *consensus,
dirvote_recalculate_timing(options, now);
routerstatus_list_update_named_server_map();
- cell_ewma_set_scale_factor(options, current_consensus);
+
+ /* Update ewma and adjust policy if needed; first cache the old value */
+ old_ewma_enabled = cell_ewma_enabled();
+ /* Change the cell EWMA settings */
+ cell_ewma_set_scale_factor(options, networkstatus_get_latest_consensus());
+ /* If we just enabled ewma, set the cmux policy on all active channels */
+ if (cell_ewma_enabled() && !old_ewma_enabled) {
+ channel_set_cmux_policy_everywhere(&ewma_policy);
+ } else if (!cell_ewma_enabled() && old_ewma_enabled) {
+ /* Turn it off everywhere */
+ channel_set_cmux_policy_everywhere(NULL);
+ }
+
/* XXXX024 this call might be unnecessary here: can changing the
* current consensus really alter our view of any OR's rate limits? */