diff options
Diffstat (limited to 'src/or/relay.c')
-rw-r--r-- | src/or/relay.c | 28 |
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); |