aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2013-02-24 13:32:57 +0100
committerKarsten Loesing <karsten.loesing@gmx.net>2013-05-16 14:18:13 +0200
commit2925e2fe786dfd9a27c2dff503996712cd180de4 (patch)
treea7fc1aa600c0284461ad288622819230cd0c830c /src/or/connection.c
parentdd5ce2157d8c47ffa3686b0579813e7b1aae8069 (diff)
downloadtor-2925e2fe786dfd9a27c2dff503996712cd180de4.tar.gz
tor-2925e2fe786dfd9a27c2dff503996712cd180de4.zip
Add new CIRC_BW event.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index dfcd1ab210..a00351a77a 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -3203,14 +3203,25 @@ connection_read_to_buf(connection_t *conn, ssize_t *max_to_read,
/* change *max_to_read */
*max_to_read = at_most - n_read;
- /* Update edge_conn->n_read */
+ /* Update edge_conn->n_read and ocirc->n_read */
if (conn->type == CONN_TYPE_AP) {
edge_connection_t *edge_conn = TO_EDGE_CONN(conn);
+ circuit_t *circ = circuit_get_by_edge_conn(edge_conn);
+ origin_circuit_t *ocirc;
+
/* Check for overflow: */
if (PREDICT_LIKELY(UINT32_MAX - edge_conn->n_read > n_read))
edge_conn->n_read += (int)n_read;
else
edge_conn->n_read = UINT32_MAX;
+
+ if (circ && CIRCUIT_IS_ORIGIN(circ)) {
+ ocirc = TO_ORIGIN_CIRCUIT(circ);
+ if (PREDICT_LIKELY(UINT32_MAX - ocirc->n_read > n_read))
+ ocirc->n_read += (int)n_read;
+ else
+ ocirc->n_read = UINT32_MAX;
+ }
}
/* In TestingTorNetwork mode, update conn->n_read for OR/DIR/EXIT
@@ -3662,12 +3673,22 @@ connection_handle_write_impl(connection_t *conn, int force)
if (n_written && conn->type == CONN_TYPE_AP) {
edge_connection_t *edge_conn = TO_EDGE_CONN(conn);
+ circuit_t *circ = circuit_get_by_edge_conn(edge_conn);
+ origin_circuit_t *ocirc;
/* Check for overflow: */
if (PREDICT_LIKELY(UINT32_MAX - edge_conn->n_written > n_written))
edge_conn->n_written += (int)n_written;
else
edge_conn->n_written = UINT32_MAX;
+
+ if (circ && CIRCUIT_IS_ORIGIN(circ)) {
+ ocirc = TO_ORIGIN_CIRCUIT(circ);
+ if (PREDICT_LIKELY(UINT32_MAX - ocirc->n_written > n_written))
+ ocirc->n_written += (int)n_written;
+ else
+ ocirc->n_written = UINT32_MAX;
+ }
}
/* In TestingTorNetwork mode, update conn->n_written for OR/DIR/EXIT