summaryrefslogtreecommitdiff
path: root/src/or/relay.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2009-07-12 16:33:31 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2009-07-15 16:12:45 +0200
commit3c051325758c0aeeeb44054715e16d8b8717948c (patch)
treea9e595b28ce218f3998ed0d3a10f54fc55eefd4e /src/or/relay.c
parent72c5a46b43c6d89c773a99240a95301b91b1f269 (diff)
downloadtor-3c051325758c0aeeeb44054715e16d8b8717948c.tar.gz
tor-3c051325758c0aeeeb44054715e16d8b8717948c.zip
Directories now also measure download times of network statuses.
Diffstat (limited to 'src/or/relay.c')
-rw-r--r--src/or/relay.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index eb18bbaade..580048be7b 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -532,6 +532,14 @@ relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ,
log_debug(LD_OR,"delivering %d cell %s.", relay_command,
cell_direction == CELL_DIRECTION_OUT ? "forward" : "backward");
+#ifdef ENABLE_GEOIP_STATS
+ /* If we are sending an END cell and this circuit is used for a tunneled
+ * directory request, advance its state. */
+ if (relay_command == RELAY_COMMAND_END && circ->request_id)
+ geoip_change_dirreq_state(circ->request_id, REQUEST_TUNNELED,
+ END_CELL_SENT);
+#endif
+
if (cell_direction == CELL_DIRECTION_OUT && circ->n_conn) {
/* if we're using relaybandwidthrate, this conn wants priority */
circ->n_conn->client_used = approx_time();
@@ -1032,6 +1040,18 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
"Begin cell for known stream. Dropping.");
return 0;
}
+#ifdef ENABLE_GEOIP_STATS
+ if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
+ /* Assign this circuit and its app-ward OR connection a unique ID,
+ * so that we can measure download times. The local edge and dir
+ * connection will be assigned the same ID when they are created
+ * and linked. */
+ static uint64_t next_id = 0;
+ circ->request_id = ++next_id;
+ TO_CONN(TO_OR_CIRCUIT(circ)->p_conn)->request_id = circ->request_id;
+ }
+#endif
+
return connection_exit_begin_conn(cell, circ);
case RELAY_COMMAND_DATA:
++stats_n_data_cells_received;
@@ -1821,6 +1841,14 @@ connection_or_flush_from_first_active_circuit(or_connection_t *conn, int max,
orcirc->processed_cells++;
}
#endif
+#ifdef ENABLE_GEOIP_STATS
+ /* If we just flushed our queue and this circuit is used for a
+ * tunneled directory request, possibly advance its state. */
+ if (queue->n == 0 && TO_CONN(conn)->request_id)
+ geoip_change_dirreq_state(TO_CONN(conn)->request_id,
+ REQUEST_TUNNELED, CIRC_QUEUE_FLUSHED);
+#endif
+
connection_write_to_buf(cell->body, CELL_NETWORK_SIZE, TO_CONN(conn));
packed_cell_free(cell);