From ea95ce25b63e6a291d9c816308919caf887fa7ea Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 23 Jul 2008 15:58:38 +0000 Subject: r17323@aud-055: nickm | 2008-07-23 17:58:25 +0200 Implement most of proposal 110. svn:r16156 --- src/or/relay.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/or/relay.c') diff --git a/src/or/relay.c b/src/or/relay.c index 40a5ee0103..155f066692 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -338,6 +338,7 @@ circuit_package_relay_cell(cell_t *cell, circuit_t *circ, log_warn(LD_BUG,"outgoing relay cell has n_conn==NULL. Dropping."); return 0; /* just drop it */ } + relay_set_digest(layer_hint->f_digest, cell); thishop = layer_hint; @@ -506,6 +507,22 @@ relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ, circ->n_conn->client_used = time(NULL); } + if (cell_direction == CELL_DIRECTION_OUT) { + origin_circuit_t *origin_circ = TO_ORIGIN_CIRCUIT(circ); + if (origin_circ->remaining_relay_early_cells > 0) { + /* If we've got any relay_early cells left, use one. Don't worry + * about the conn protocol version: append_cell_to_circuit_queue will + * fix it up. */ + cell.command = CELL_RELAY_EARLY; + --origin_circ->remaining_relay_early_cells; + log_debug(LD_OR, "Sending a RELAY_EARLY cell; %d remaining.", + (int)origin_circ->remaining_relay_early_cells); + } else if (relay_command == RELAY_COMMAND_EXTEND) { + log_warn(LD_BUG, "Uh-oh. We're sending a RELAY_COMMAND_EXTEND cell, " + "but we have run out of RELAY_EARLY cells on that circuit."); + } + } + if (circuit_package_relay_cell(&cell, circ, cell_direction, cpath_layer) < 0) { log_warn(LD_BUG,"circuit_package_relay_cell failed. Closing."); -- cgit v1.2.3-54-g00ecf