mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Change connstats.c identifers to start with conn_stats
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ rep_hist_conn_stats_init conn_stats_init \ rep_hist_note_or_conn_bytes conn_stats_note_or_conn_bytes \ rep_hist_reset_conn_stats conn_stats_reset \ rep_hist_format_conn_stats conn_stats_format \ rep_hist_conn_stats_write conn_stats_save \ rep_hist_conn_stats_term conn_stats_terminate \ bidi_map_free_all conn_stats_free_all
This commit is contained in:
parent
50bf2520b3
commit
3f2de0bcca
@ -3364,7 +3364,7 @@ record_num_bytes_transferred_impl(connection_t *conn,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (conn->type == CONN_TYPE_OR)
|
if (conn->type == CONN_TYPE_OR)
|
||||||
rep_hist_note_or_conn_bytes(conn->global_identifier, num_read,
|
conn_stats_note_or_conn_bytes(conn->global_identifier, num_read,
|
||||||
num_written, now);
|
num_written, now);
|
||||||
|
|
||||||
const bool is_ipv6 = (conn->socket_family == AF_INET6);
|
const bool is_ipv6 = (conn->socket_family == AF_INET6);
|
||||||
|
@ -1951,7 +1951,7 @@ write_stats_file_callback(time_t now, const or_options_t *options)
|
|||||||
next_time_to_write_stats_files = next_write;
|
next_time_to_write_stats_files = next_write;
|
||||||
}
|
}
|
||||||
if (options->ConnDirectionStatistics) {
|
if (options->ConnDirectionStatistics) {
|
||||||
time_t next_write = rep_hist_conn_stats_write(now);
|
time_t next_write = conn_stats_save(now);
|
||||||
if (next_write && next_write < next_time_to_write_stats_files)
|
if (next_write && next_write < next_time_to_write_stats_files)
|
||||||
next_time_to_write_stats_files = next_write;
|
next_time_to_write_stats_files = next_write;
|
||||||
}
|
}
|
||||||
|
@ -1308,7 +1308,7 @@ options_act_relay_stats(const or_options_t *old_options,
|
|||||||
}
|
}
|
||||||
if ((!old_options || !old_options->ConnDirectionStatistics) &&
|
if ((!old_options || !old_options->ConnDirectionStatistics) &&
|
||||||
options->ConnDirectionStatistics) {
|
options->ConnDirectionStatistics) {
|
||||||
rep_hist_conn_stats_init(now);
|
conn_stats_init(now);
|
||||||
}
|
}
|
||||||
if ((!old_options || !old_options->HiddenServiceStatistics) &&
|
if ((!old_options || !old_options->HiddenServiceStatistics) &&
|
||||||
options->HiddenServiceStatistics) {
|
options->HiddenServiceStatistics) {
|
||||||
@ -1338,7 +1338,7 @@ options_act_relay_stats(const or_options_t *old_options,
|
|||||||
rep_hist_exit_stats_term();
|
rep_hist_exit_stats_term();
|
||||||
if (old_options && old_options->ConnDirectionStatistics &&
|
if (old_options && old_options->ConnDirectionStatistics &&
|
||||||
!options->ConnDirectionStatistics)
|
!options->ConnDirectionStatistics)
|
||||||
rep_hist_conn_stats_term();
|
conn_stats_terminate();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ static time_t start_of_conn_stats_interval;
|
|||||||
|
|
||||||
/** Initialize connection stats. */
|
/** Initialize connection stats. */
|
||||||
void
|
void
|
||||||
rep_hist_conn_stats_init(time_t now)
|
conn_stats_init(time_t now)
|
||||||
{
|
{
|
||||||
start_of_conn_stats_interval = now;
|
start_of_conn_stats_interval = now;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ HT_GENERATE2(bidimap, bidi_map_entry_t, node, bidi_map_ent_hash,
|
|||||||
|
|
||||||
/** Release all storage held in connstats.c */
|
/** Release all storage held in connstats.c */
|
||||||
void
|
void
|
||||||
bidi_map_free_all(void)
|
conn_stats_free_all(void)
|
||||||
{
|
{
|
||||||
bidi_map_entry_t **ptr, **next, *ent;
|
bidi_map_entry_t **ptr, **next, *ent;
|
||||||
for (ptr = HT_START(bidimap, &bidi_map); ptr; ptr = next) {
|
for (ptr = HT_START(bidimap, &bidi_map); ptr; ptr = next) {
|
||||||
@ -108,22 +108,22 @@ bidi_map_free_all(void)
|
|||||||
|
|
||||||
/** Reset counters for conn statistics. */
|
/** Reset counters for conn statistics. */
|
||||||
void
|
void
|
||||||
rep_hist_reset_conn_stats(time_t now)
|
conn_stats_reset(time_t now)
|
||||||
{
|
{
|
||||||
start_of_conn_stats_interval = now;
|
start_of_conn_stats_interval = now;
|
||||||
below_threshold = 0;
|
below_threshold = 0;
|
||||||
mostly_read = 0;
|
mostly_read = 0;
|
||||||
mostly_written = 0;
|
mostly_written = 0;
|
||||||
both_read_and_written = 0;
|
both_read_and_written = 0;
|
||||||
bidi_map_free_all();
|
conn_stats_free_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stop collecting connection stats in a way that we can re-start doing
|
/** Stop collecting connection stats in a way that we can re-start doing
|
||||||
* so in rep_hist_conn_stats_init(). */
|
* so in conn_stats_init(). */
|
||||||
void
|
void
|
||||||
rep_hist_conn_stats_term(void)
|
conn_stats_terminate(void)
|
||||||
{
|
{
|
||||||
rep_hist_reset_conn_stats(0);
|
conn_stats_reset(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** We read <b>num_read</b> bytes and wrote <b>num_written</b> from/to OR
|
/** We read <b>num_read</b> bytes and wrote <b>num_written</b> from/to OR
|
||||||
@ -131,7 +131,7 @@ rep_hist_conn_stats_term(void)
|
|||||||
* observation in a new interval, sum up the last observations. Add bytes
|
* observation in a new interval, sum up the last observations. Add bytes
|
||||||
* for this connection. */
|
* for this connection. */
|
||||||
void
|
void
|
||||||
rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
|
conn_stats_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
|
||||||
size_t num_written, time_t when)
|
size_t num_written, time_t when)
|
||||||
{
|
{
|
||||||
if (!start_of_conn_stats_interval)
|
if (!start_of_conn_stats_interval)
|
||||||
@ -184,7 +184,7 @@ rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
|
|||||||
* until <b>now</b>, or NULL if we're not collecting conn stats. Caller must
|
* until <b>now</b>, or NULL if we're not collecting conn stats. Caller must
|
||||||
* ensure start_of_conn_stats_interval is in the past. */
|
* ensure start_of_conn_stats_interval is in the past. */
|
||||||
char *
|
char *
|
||||||
rep_hist_format_conn_stats(time_t now)
|
conn_stats_format(time_t now)
|
||||||
{
|
{
|
||||||
char *result, written[ISO_TIME_LEN+1];
|
char *result, written[ISO_TIME_LEN+1];
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ rep_hist_format_conn_stats(time_t now)
|
|||||||
* overwriting an existing file) and reset counters. Return when we would
|
* overwriting an existing file) and reset counters. Return when we would
|
||||||
* next want to write conn stats or 0 if we never want to write. */
|
* next want to write conn stats or 0 if we never want to write. */
|
||||||
time_t
|
time_t
|
||||||
rep_hist_conn_stats_write(time_t now)
|
conn_stats_save(time_t now)
|
||||||
{
|
{
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
|
|
||||||
@ -219,10 +219,10 @@ rep_hist_conn_stats_write(time_t now)
|
|||||||
goto done; /* Not ready to write */
|
goto done; /* Not ready to write */
|
||||||
|
|
||||||
/* Generate history string. */
|
/* Generate history string. */
|
||||||
str = rep_hist_format_conn_stats(now);
|
str = conn_stats_format(now);
|
||||||
|
|
||||||
/* Reset counters. */
|
/* Reset counters. */
|
||||||
rep_hist_reset_conn_stats(now);
|
conn_stats_reset(now);
|
||||||
|
|
||||||
/* Try to write to disk. */
|
/* Try to write to disk. */
|
||||||
if (!check_or_create_data_subdir("stats")) {
|
if (!check_or_create_data_subdir("stats")) {
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
#ifndef TOR_FEATURE_STATS_CONNSTATS_H
|
#ifndef TOR_FEATURE_STATS_CONNSTATS_H
|
||||||
#define TOR_FEATURE_STATS_CONNSTATS_H
|
#define TOR_FEATURE_STATS_CONNSTATS_H
|
||||||
|
|
||||||
void rep_hist_conn_stats_init(time_t now);
|
void conn_stats_init(time_t now);
|
||||||
void rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
|
void conn_stats_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
|
||||||
size_t num_written, time_t when);
|
size_t num_written, time_t when);
|
||||||
void rep_hist_reset_conn_stats(time_t now);
|
void conn_stats_reset(time_t now);
|
||||||
char *rep_hist_format_conn_stats(time_t now);
|
char *conn_stats_format(time_t now);
|
||||||
time_t rep_hist_conn_stats_write(time_t now);
|
time_t conn_stats_save(time_t now);
|
||||||
void rep_hist_conn_stats_term(void);
|
void conn_stats_terminate(void);
|
||||||
void bidi_map_free_all(void);
|
void conn_stats_free_all(void);
|
||||||
|
|
||||||
#endif /* !defined(TOR_FEATURE_STATS_CONNSTATS_H) */
|
#endif /* !defined(TOR_FEATURE_STATS_CONNSTATS_H) */
|
||||||
|
@ -2141,7 +2141,7 @@ rep_hist_free_all(void)
|
|||||||
tor_free(exit_bytes_written);
|
tor_free(exit_bytes_written);
|
||||||
tor_free(exit_streams);
|
tor_free(exit_streams);
|
||||||
predicted_ports_free_all();
|
predicted_ports_free_all();
|
||||||
bidi_map_free_all();
|
conn_stats_free_all();
|
||||||
|
|
||||||
if (circuits_for_buffer_stats) {
|
if (circuits_for_buffer_stats) {
|
||||||
SMARTLIST_FOREACH(circuits_for_buffer_stats, circ_buffer_stats_t *, s,
|
SMARTLIST_FOREACH(circuits_for_buffer_stats, circ_buffer_stats_t *, s,
|
||||||
|
@ -112,36 +112,36 @@ test_stats(void *arg)
|
|||||||
|
|
||||||
/* Continue with testing connection statistics; we shouldn't collect
|
/* Continue with testing connection statistics; we shouldn't collect
|
||||||
* conn stats without initializing them. */
|
* conn stats without initializing them. */
|
||||||
rep_hist_note_or_conn_bytes(1, 20, 400, now);
|
conn_stats_note_or_conn_bytes(1, 20, 400, now);
|
||||||
s = rep_hist_format_conn_stats(now + 86400);
|
s = conn_stats_format(now + 86400);
|
||||||
tt_ptr_op(s, OP_EQ, NULL);
|
tt_ptr_op(s, OP_EQ, NULL);
|
||||||
|
|
||||||
/* Initialize stats, note bytes, and generate history string. */
|
/* Initialize stats, note bytes, and generate history string. */
|
||||||
rep_hist_conn_stats_init(now);
|
conn_stats_init(now);
|
||||||
rep_hist_note_or_conn_bytes(1, 30000, 400000, now);
|
conn_stats_note_or_conn_bytes(1, 30000, 400000, now);
|
||||||
rep_hist_note_or_conn_bytes(1, 30000, 400000, now + 5);
|
conn_stats_note_or_conn_bytes(1, 30000, 400000, now + 5);
|
||||||
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 10);
|
conn_stats_note_or_conn_bytes(2, 400000, 30000, now + 10);
|
||||||
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
|
conn_stats_note_or_conn_bytes(2, 400000, 30000, now + 15);
|
||||||
s = rep_hist_format_conn_stats(now + 86400);
|
s = conn_stats_format(now + 86400);
|
||||||
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,1,0\n",OP_EQ, s);
|
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,1,0\n",OP_EQ, s);
|
||||||
tor_free(s);
|
tor_free(s);
|
||||||
|
|
||||||
/* Stop collecting stats, add some bytes, and ensure we don't generate
|
/* Stop collecting stats, add some bytes, and ensure we don't generate
|
||||||
* a history string. */
|
* a history string. */
|
||||||
rep_hist_conn_stats_term();
|
conn_stats_terminate();
|
||||||
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
|
conn_stats_note_or_conn_bytes(2, 400000, 30000, now + 15);
|
||||||
s = rep_hist_format_conn_stats(now + 86400);
|
s = conn_stats_format(now + 86400);
|
||||||
tt_ptr_op(s, OP_EQ, NULL);
|
tt_ptr_op(s, OP_EQ, NULL);
|
||||||
|
|
||||||
/* Re-start stats, add some bytes, reset stats, and see what history we
|
/* Re-start stats, add some bytes, reset stats, and see what history we
|
||||||
* get when observing no bytes at all. */
|
* get when observing no bytes at all. */
|
||||||
rep_hist_conn_stats_init(now);
|
conn_stats_init(now);
|
||||||
rep_hist_note_or_conn_bytes(1, 30000, 400000, now);
|
conn_stats_note_or_conn_bytes(1, 30000, 400000, now);
|
||||||
rep_hist_note_or_conn_bytes(1, 30000, 400000, now + 5);
|
conn_stats_note_or_conn_bytes(1, 30000, 400000, now + 5);
|
||||||
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 10);
|
conn_stats_note_or_conn_bytes(2, 400000, 30000, now + 10);
|
||||||
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
|
conn_stats_note_or_conn_bytes(2, 400000, 30000, now + 15);
|
||||||
rep_hist_reset_conn_stats(now);
|
conn_stats_reset(now);
|
||||||
s = rep_hist_format_conn_stats(now + 86400);
|
s = conn_stats_format(now + 86400);
|
||||||
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,0,0\n",OP_EQ, s);
|
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,0,0\n",OP_EQ, s);
|
||||||
tor_free(s);
|
tor_free(s);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user