aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-09-16 17:17:39 +0000
committerNick Mathewson <nickm@torproject.org>2003-09-16 17:17:39 +0000
commitc09de55fb843c2875caf59cc6447f184d51ce209 (patch)
tree3163492bdbc4903a96398cb8fda1c0f0b1930604 /src/or
parent8b71b7338faeaedf60e40b335b865781106ad1a2 (diff)
downloadtor-c09de55fb843c2875caf59cc6447f184d51ce209.tar
tor-c09de55fb843c2875caf59cc6447f184d51ce209.tar.gz
Add #ifdef'd code (on by default) to allocate ACIs sequentially.
svn:r462
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuit.c14
-rw-r--r--src/or/or.h4
2 files changed, 18 insertions, 0 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index 71258366e..2f5649f8b 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -122,6 +122,19 @@ static aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_t
aci_t test_aci;
connection_t *conn;
+#ifdef SEQUENTIAL_ACI
+ /* Right now, this is the only used aci_type. XXX The others should
+ be removed. */
+ assert(aci_type == ACI_TYPE_BOTH);
+ conn = connection_exact_get_by_addr_port(addr,port);
+ if (!conn)
+ return 1; /* No connection exists; conflict is impossible. */
+ do {
+ test_aci = conn->next_aci++; /* This can wrap around to 0; that's okay. */
+ if (test_aci == 0)
+ continue;
+ } while(circuit_get_by_aci_conn(test_aci, conn));
+#else
try_again:
log_fn(LOG_DEBUG,"trying to get a unique aci");
@@ -143,6 +156,7 @@ try_again:
if(circuit_get_by_aci_conn(test_aci, conn))
goto try_again;
+#endif
return test_aci;
}
diff --git a/src/or/or.h b/src/or/or.h
index c52fb3525..ad677d5ca 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -8,6 +8,7 @@
#include "orconfig.h"
#define USE_TLS
+#define SEQUENTIAL_ACI
#include <stdio.h>
#include <stdlib.h>
@@ -314,6 +315,9 @@ struct connection_t {
char nonce[8];
#endif
+#ifdef SEQUENTIAL_ACI
+ uint16_t next_aci; /* Which ACI do we try to use next on this connection? */
+#endif
/* Used only by edge connections: */
char stream_id[STREAM_ID_SIZE];