aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/or/circuitbuild.c2
-rw-r--r--src/or/circuitlist.c8
-rw-r--r--src/or/command.c2
-rw-r--r--src/or/or.h1
4 files changed, 11 insertions, 2 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 354a9767e1..69ace8838e 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -99,7 +99,7 @@ get_unique_circ_id_by_conn(or_connection_t *conn)
return 0;
}
test_circ_id |= high_bit;
- } while (circuit_get_by_circid_orconn(test_circ_id, conn));
+ } while (circuit_id_in_use_on_orconn(test_circ_id, conn));
return test_circ_id;
}
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 7bd3829f62..adb0d7867e 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -661,6 +661,14 @@ circuit_get_by_circid_orconn(uint16_t circ_id, or_connection_t *conn)
return circ;
}
+/** Return true iff the circuit ID <b>circ_id</b> is currently used by a
+ * circuit, marked or not, on <b>conn</b>. */
+int
+circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn)
+{
+ return circuit_get_by_circid_orconn_impl(circ_id, conn) != NULL;
+}
+
/** Return the circuit that a given edge connection is using. */
circuit_t *
circuit_get_by_edge_conn(edge_connection_t *conn)
diff --git a/src/or/command.c b/src/or/command.c
index 79e6133f19..4a08842396 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -252,7 +252,7 @@ command_process_create_cell(cell_t *cell, or_connection_t *conn)
return;
}
- if (circuit_get_by_circid_orconn(cell->circ_id, conn)) {
+ if (circuit_id_in_use_on_orconn(cell->circ_id, conn)) {
routerinfo_t *router = router_get_by_digest(conn->identity_digest);
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
"Received CREATE cell (circID %d) for known circ. "
diff --git a/src/or/or.h b/src/or/or.h
index b81db6f7af..ffcb686cbe 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2623,6 +2623,7 @@ origin_circuit_t *origin_circuit_new(void);
or_circuit_t *or_circuit_new(uint16_t p_circ_id, or_connection_t *p_conn);
circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id,
or_connection_t *conn);
+int circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn);
circuit_t *circuit_get_by_edge_conn(edge_connection_t *conn);
void circuit_unlink_all_from_or_conn(or_connection_t *conn, int reason);
origin_circuit_t *circuit_get_by_global_id(uint32_t id);