diff options
author | Karsten Loesing <karsten.loesing@gmx.net> | 2013-05-24 12:01:32 +0200 |
---|---|---|
committer | Karsten Loesing <karsten.loesing@gmx.net> | 2013-05-25 19:51:38 +0200 |
commit | 2f893624abb65a0df4f0f8ca6fbbe0c00fbf216a (patch) | |
tree | 6878bf260ef828ab871d6bb8a30f6d057dda6b9c /src/or/connection.c | |
parent | a84fae789206db4e27486e693488328da7b3474a (diff) | |
download | tor-2f893624abb65a0df4f0f8ca6fbbe0c00fbf216a.tar.gz tor-2f893624abb65a0df4f0f8ca6fbbe0c00fbf216a.zip |
Tweak CONN_BW event based on comments by nickm.
- Rename read/write counters in connection_t to make it clear that these
are only used for CONN_BW events.
- Add TestingEnableConnBwEvent option.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index a00351a77a..f7f028b0b5 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -3224,16 +3224,16 @@ connection_read_to_buf(connection_t *conn, ssize_t *max_to_read, } } - /* In TestingTorNetwork mode, update conn->n_read for OR/DIR/EXIT - * connections, checking for overflow. */ - if (get_options()->TestingTorNetwork && + /* If CONN_BW events are enabled, update conn->n_read_conn_bw for + * OR/DIR/EXIT connections, checking for overflow. */ + if (get_options()->TestingEnableConnBwEvent && (conn->type == CONN_TYPE_OR || conn->type == CONN_TYPE_DIR || conn->type == CONN_TYPE_EXIT)) { - if (PREDICT_LIKELY(UINT32_MAX - conn->n_read > n_read)) - conn->n_read += (int)n_read; + if (PREDICT_LIKELY(UINT32_MAX - conn->n_read_conn_bw > n_read)) + conn->n_read_conn_bw += (int)n_read; else - conn->n_read = UINT32_MAX; + conn->n_read_conn_bw = UINT32_MAX; } } @@ -3691,16 +3691,16 @@ connection_handle_write_impl(connection_t *conn, int force) } } - /* In TestingTorNetwork mode, update conn->n_written for OR/DIR/EXIT - * connections, checking for overflow. */ - if (n_written && get_options()->TestingTorNetwork && + /* If CONN_BW events are enabled, update conn->n_written_conn_bw for + * OR/DIR/EXIT connections, checking for overflow. */ + if (n_written && get_options()->TestingEnableConnBwEvent && (conn->type == CONN_TYPE_OR || conn->type == CONN_TYPE_DIR || conn->type == CONN_TYPE_EXIT)) { - if (PREDICT_LIKELY(UINT32_MAX - conn->n_written > n_written)) - conn->n_written += (int)n_written; + if (PREDICT_LIKELY(UINT32_MAX - conn->n_written_conn_bw > n_written)) + conn->n_written_conn_bw += (int)n_written; else - conn->n_written = UINT32_MAX; + conn->n_written_conn_bw = UINT32_MAX; } connection_buckets_decrement(conn, approx_time(), n_read, n_written); |