aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-02-29 00:11:37 +0000
committerRoger Dingledine <arma@torproject.org>2004-02-29 00:11:37 +0000
commit195ee8c845482c827761acae07175d57e287717e (patch)
tree525a1159e27089e67e7bc669b3cdd6b8fefd6a8e /src/or
parent62d3df8633ff5e00eddc76dc690fe6696f1c583b (diff)
downloadtor-195ee8c845482c827761acae07175d57e287717e.tar
tor-195ee8c845482c827761acae07175d57e287717e.tar.gz
create a separate connection_edge_destroy() function
svn:r1176
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuit.c4
-rw-r--r--src/or/connection.c12
-rw-r--r--src/or/connection_edge.c10
-rw-r--r--src/or/or.h1
4 files changed, 14 insertions, 13 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index f4d8bf895..ae2e77b8c 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -661,12 +661,12 @@ void circuit_close(circuit_t *circ) {
if(circ->n_conn)
connection_send_destroy(circ->n_circ_id, circ->n_conn);
for(conn=circ->n_streams; conn; conn=conn->next_stream) {
- connection_send_destroy(circ->n_circ_id, conn);
+ connection_edge_destroy(circ->n_circ_id, conn);
}
if(circ->p_conn)
connection_send_destroy(circ->n_circ_id, circ->p_conn);
for(conn=circ->p_streams; conn; conn=conn->next_stream) {
- connection_send_destroy(circ->p_circ_id, conn);
+ connection_edge_destroy(circ->p_circ_id, conn);
}
if (circ->state == CIRCUIT_STATE_BUILDING ||
circ->state == CIRCUIT_STATE_OR_WAIT) {
diff --git a/src/or/connection.c b/src/or/connection.c
index 1ebc65aad..700c056fb 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -752,17 +752,7 @@ int connection_send_destroy(uint16_t circ_id, connection_t *conn) {
cell_t cell;
assert(conn);
-
- if(!connection_speaks_cells(conn)) {
- log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
- circ_id);
- conn->has_sent_end = 1; /* we're closing the circuit, nothing to send to */
-/* XXX really, we should separate this function into two functions.
- * one of them actually sends the destroy cell, as this function's name
- * implies, and another one destroys a stream. Yes/no? -RD */
- connection_mark_for_close(conn, END_STREAM_REASON_DESTROY);
- return 0;
- }
+ assert(connection_speaks_cells(conn));
memset(&cell, 0, sizeof(cell_t));
cell.circ_id = circ_id;
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index b159c194b..9c245044f 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -88,6 +88,16 @@ int connection_edge_process_inbuf(connection_t *conn) {
return -1;
}
+int connection_edge_destroy(uint16_t circ_id, connection_t *conn) {
+ assert(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT);
+
+ log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
+ circ_id);
+ conn->has_sent_end = 1; /* we're closing the circuit, nothing to send to */
+ connection_mark_for_close(conn, END_STREAM_REASON_DESTROY);
+ return 0;
+}
+
static char *connection_edge_end_reason(char *payload, uint16_t length) {
if(length < 1) {
log_fn(LOG_WARN,"End cell arrived with length 0. Should be at least 1.");
diff --git a/src/or/or.h b/src/or/or.h
index c8433bdf4..dc513f99e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -698,6 +698,7 @@ void assert_connection_ok(connection_t *conn, time_t now);
void relay_header_pack(char *dest, const relay_header_t *src);
void relay_header_unpack(relay_header_t *dest, const char *src);
int connection_edge_process_inbuf(connection_t *conn);
+int connection_edge_destroy(uint16_t circ_id, connection_t *conn);
int connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer);
int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int relay_command,