--- /dev/null
+ o Major bugfix (control-events, bw-cache):
+ - Fixes spikes occurring in bandwidth cache on control connection.
+ Fixes bug 31524; bugfix on 0.4.8.12-dev.
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2021, The Tor Project, Inc. */
+ * Copyright (c) 2007-2024, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
if (conn->is_owning_control_connection) {
lost_owning_controller("connection", "closed");
}
+
+ control_remove_authenticated_connection(conn);
}
/** Return true iff <b>cmd</b> is allowable (or at least forgivable) at this
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2021, The Tor Project, Inc. */
+ * Copyright (c) 2007-2024, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "feature/control/control.h"
+#include "feature/control/control_events.h"
#include "feature/control/control_cmd.h"
#include "feature/control/control_auth.h"
#include "feature/control/control_cmd_args_st.h"
#include "lib/crypt_ops/crypto_s2k.h"
+/* List of authenticated control connections */
+static smartlist_t *control_auth_conns = NULL;
+
+static void
+control_add_authenticated_connection(control_connection_t *conn)
+{
+ if (!control_auth_conns)
+ control_auth_conns = smartlist_new();
+
+ smartlist_add(control_auth_conns, conn);
+
+ if (smartlist_len(control_auth_conns) == 1)
+ stats_init();
+}
+
+void
+control_remove_authenticated_connection(const control_connection_t *conn)
+{
+ if (!control_auth_conns)
+ return;
+
+ smartlist_remove(control_auth_conns, conn);
+
+ if (smartlist_len(control_auth_conns) == 0) {
+ smartlist_free(control_auth_conns);
+ control_auth_conns = NULL;
+ stats_clear();
+ }
+}
+
/** If we're using cookie-type authentication, how long should our cookies be?
*/
#define AUTHENTICATION_COOKIE_LEN 32
SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
}
+
+ control_add_authenticated_connection(conn);
+
return 0;
}
if (authentication_cookie) /* Free the auth cookie */
tor_free(authentication_cookie);
authentication_cookie_is_set = 0;
+
+ if (control_auth_conns)
+ smartlist_free(control_auth_conns);
}
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2021, The Tor Project, Inc. */
+ * Copyright (c) 2007-2024, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
#ifndef TOR_CONTROL_AUTH_H
#define TOR_CONTROL_AUTH_H
+void control_remove_authenticated_connection(const control_connection_t *conn);
+
struct control_cmd_args_t;
struct control_cmd_syntax_t;
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2021, The Tor Project, Inc. */
+ * Copyright (c) 2007-2024, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
uint32_t n_written;
} cached_bw_events[N_BW_EVENTS_TO_CACHE];
+void
+stats_init(void)
+{
+ stats_prev_n_read = get_bytes_read();
+ stats_prev_n_written = get_bytes_written();
+}
+
+void
+stats_clear(void)
+{
+ memset(cached_bw_events, 0, sizeof cached_bw_events);
+ stats_prev_n_read = stats_prev_n_written = 0;
+ n_measurements = next_measurement_idx = 0;
+}
+
/** A second or more has elapsed: tell any interested control
* connections how much bandwidth we used. */
int
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2021, The Tor Project, Inc. */
+ * Copyright (c) 2007-2024, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
int control_event_enter_controller_wait(void);
+void stats_init(void);
+void stats_clear(void);
+
void control_events_free_all(void);
#ifdef CONTROL_MODULE_PRIVATE