Rename circuit_get_by_stream to circuit_get_by_edge_conn, and actually start using it. Watch out, kids!

svn:r4026
This commit is contained in:
Nick Mathewson 2005-04-06 06:43:21 +00:00
parent 716d9bc99a
commit 88dc243bb5
7 changed files with 25 additions and 23 deletions

View File

@ -324,7 +324,7 @@ circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id, connection_t *conn) {
}
/** DOCDOC */
circuit_t *circuit_get_by_stream(connection_t *conn)
circuit_t *circuit_get_by_edge_conn(connection_t *conn)
{
circuit_t *circ;
connection_t *tmpconn;

View File

@ -501,7 +501,7 @@ void circuit_about_to_close_connection(connection_t *conn) {
* been sent. But don't kill the circuit.
*/
circ = circuit_get_by_conn(conn);
circ = circuit_get_by_edge_conn(conn);
if (!circ)
return;

View File

@ -295,7 +295,7 @@ void connection_about_to_close_connection(connection_t *conn)
break;
case CONN_TYPE_EXIT:
if (conn->state == EXIT_CONN_STATE_RESOLVING) {
circ = circuit_get_by_conn(conn);
circ = circuit_get_by_edge_conn(conn);
if (circ)
circuit_detach_stream(circ, conn);
connection_dns_remove(conn);
@ -1209,7 +1209,7 @@ void connection_write_to_buf(const char *string, size_t len, connection_t *conn)
/* if it failed, it means we have our package/delivery windows set
wrong compared to our max outbuf size. close the whole circuit. */
log_fn(LOG_WARN,"write_to_buf failed. Closing circuit (fd %d).", conn->s);
circuit_mark_for_close(circuit_get_by_conn(conn));
circuit_mark_for_close(circuit_get_by_edge_conn(conn));
} else {
log_fn(LOG_WARN,"write_to_buf failed. Closing connection (fd %d).", conn->s);
connection_mark_for_close(conn);

View File

@ -66,7 +66,8 @@ int connection_edge_reached_eof(connection_t *conn) {
connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer);
connection_mark_for_close(conn);
} else {
connection_edge_send_command(conn, circuit_get_by_conn(conn), RELAY_COMMAND_END,
connection_edge_send_command(conn, circuit_get_by_edge_conn(conn),
RELAY_COMMAND_END,
NULL, 0, conn->cpath_layer);
}
return 0;
@ -195,7 +196,7 @@ connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer)
payload_len += 4;
}
circ = circuit_get_by_conn(conn);
circ = circuit_get_by_edge_conn(conn);
if (circ && !circ->marked_for_close) {
log_fn(LOG_DEBUG,"Marking conn (fd %d) and sending end.",conn->s);
connection_edge_send_command(conn, circ, RELAY_COMMAND_END,
@ -278,12 +279,12 @@ int connection_edge_finished_connecting(connection_t *conn)
connection_start_writing(conn);
/* deliver a 'connected' relay cell back through the circuit. */
if (connection_edge_is_rendezvous_stream(conn)) {
if (connection_edge_send_command(conn, circuit_get_by_conn(conn),
if (connection_edge_send_command(conn, circuit_get_by_edge_conn(conn),
RELAY_COMMAND_CONNECTED, NULL, 0, conn->cpath_layer) < 0)
return 0; /* circuit is closed, don't continue */
} else {
*(uint32_t*)connected_payload = htonl(conn->addr);
if (connection_edge_send_command(conn, circuit_get_by_conn(conn),
if (connection_edge_send_command(conn, circuit_get_by_edge_conn(conn),
RELAY_COMMAND_CONNECTED, connected_payload, 4, conn->cpath_layer) < 0)
return 0; /* circuit is closed, don't continue */
}
@ -328,7 +329,7 @@ void connection_ap_expire_beginning(void) {
continue;
if (now - conn->timestamp_lastread < 15)
continue;
circ = circuit_get_by_conn(conn);
circ = circuit_get_by_edge_conn(conn);
if (!circ) { /* it's vanished? */
log_fn(LOG_INFO,"Conn is waiting (address %s), but lost its circ.",
conn->socks_request->address);
@ -1476,7 +1477,7 @@ connection_exit_connect(connection_t *conn) {
router_compare_to_my_exit_policy(conn) == ADDR_POLICY_REJECTED) {
log_fn(LOG_INFO,"%s:%d failed exit policy. Closing.", conn->address, conn->port);
connection_edge_end(conn, END_STREAM_REASON_EXITPOLICY, conn->cpath_layer);
circuit_detach_stream(circuit_get_by_conn(conn), conn);
circuit_detach_stream(circuit_get_by_edge_conn(conn), conn);
connection_free(conn);
return;
}
@ -1507,7 +1508,7 @@ connection_exit_connect(connection_t *conn) {
switch (connection_connect(conn, conn->address, addr, port)) {
case -1:
connection_edge_end_errno(conn, conn->cpath_layer);
circuit_detach_stream(circuit_get_by_conn(conn), conn);
circuit_detach_stream(circuit_get_by_edge_conn(conn), conn);
connection_free(conn);
return;
case 0:
@ -1530,12 +1531,12 @@ connection_exit_connect(connection_t *conn) {
/* also, deliver a 'connected' cell back through the circuit. */
if (connection_edge_is_rendezvous_stream(conn)) { /* rendezvous stream */
/* don't send an address back! */
connection_edge_send_command(conn, circuit_get_by_conn(conn), RELAY_COMMAND_CONNECTED,
connection_edge_send_command(conn, circuit_get_by_edge_conn(conn), RELAY_COMMAND_CONNECTED,
NULL, 0, conn->cpath_layer);
} else { /* normal stream */
/* This must be the original address, not the redirected address. */
*(uint32_t*)connected_payload = htonl(conn->addr);
connection_edge_send_command(conn, circuit_get_by_conn(conn), RELAY_COMMAND_CONNECTED,
connection_edge_send_command(conn, circuit_get_by_edge_conn(conn), RELAY_COMMAND_CONNECTED,
connected_payload, 4, conn->cpath_layer);
}
}

View File

@ -156,7 +156,7 @@ static void purge_expired_resolves(uint32_t now) {
pendconn = pend->conn;
connection_edge_end(pendconn, END_STREAM_REASON_TIMEOUT,
pendconn->cpath_layer);
circuit_detach_stream(circuit_get_by_conn(pendconn), pendconn);
circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
connection_free(pendconn);
tor_free(pend);
}
@ -192,7 +192,7 @@ static void send_resolved_cell(connection_t *conn, uint8_t answer_type)
default:
tor_assert(0);
}
connection_edge_send_command(conn, circuit_get_by_conn(conn),
connection_edge_send_command(conn, circuit_get_by_edge_conn(conn),
RELAY_COMMAND_RESOLVED, buf, buflen,
conn->cpath_layer);
}
@ -274,7 +274,7 @@ int dns_resolve(connection_t *exitconn) {
exitconn->s, exitconn->address);
if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
circ = circuit_get_by_conn(exitconn);
circ = circuit_get_by_edge_conn(exitconn);
if (circ)
circuit_detach_stream(circ, exitconn);
if (!exitconn->marked_for_close)
@ -455,7 +455,7 @@ void dns_cancel_pending_resolve(char *address) {
connection_edge_end(pendconn, END_STREAM_REASON_RESOURCELIMIT,
pendconn->cpath_layer);
}
circ = circuit_get_by_conn(pendconn);
circ = circuit_get_by_edge_conn(pendconn);
if (circ)
circuit_detach_stream(circ, pendconn);
connection_free(pendconn);
@ -553,11 +553,11 @@ static void dns_found_answer(char *address, uint32_t addr, char outcome) {
if (pendconn->purpose == EXIT_PURPOSE_CONNECT) {
connection_edge_end(pendconn, END_STREAM_REASON_RESOLVEFAILED, pendconn->cpath_layer);
/* This detach must happen after we send the end cell. */
circuit_detach_stream(circuit_get_by_conn(pendconn), pendconn);
circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
} else {
send_resolved_cell(pendconn, RESOLVED_TYPE_ERROR);
/* This detach must happen after we send the resolved cell. */
circuit_detach_stream(circuit_get_by_conn(pendconn), pendconn);
circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
}
connection_free(pendconn);
} else {
@ -565,7 +565,7 @@ static void dns_found_answer(char *address, uint32_t addr, char outcome) {
/* prevent double-remove. */
pend->conn->state = EXIT_CONN_STATE_CONNECTING;
circ = circuit_get_by_conn(pend->conn);
circ = circuit_get_by_edge_conn(pend->conn);
tor_assert(circ);
/* unlink pend->conn from resolving_streams, */
circuit_detach_stream(circ, pend->conn);
@ -580,7 +580,7 @@ static void dns_found_answer(char *address, uint32_t addr, char outcome) {
* but it does the right thing. */
pendconn->state = EXIT_CONN_STATE_RESOLVEFAILED;
send_resolved_cell(pendconn, RESOLVED_TYPE_IPV4);
circ = circuit_get_by_conn(pendconn);
circ = circuit_get_by_edge_conn(pendconn);
tor_assert(circ);
circuit_detach_stream(circ, pendconn);
connection_free(pendconn);

View File

@ -1173,6 +1173,7 @@ void circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
void circuit_close_all_marked(void);
circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn);
circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id, connection_t *conn);
circuit_t *circuit_get_by_edge_conn(connection_t *conn);
circuit_t *circuit_get_by_conn(connection_t *conn);
circuit_t *circuit_get_by_global_id(uint32_t id);
circuit_t *circuit_get_by_rend_query_and_purpose(const char *rend_query, uint8_t purpose);

View File

@ -1008,7 +1008,7 @@ int connection_edge_package_raw_inbuf(connection_t *conn, int package_partial) {
repeat_connection_edge_package_raw_inbuf:
circ = circuit_get_by_conn(conn);
circ = circuit_get_by_edge_conn(conn);
if (!circ) {
log_fn(LOG_INFO,"conn has no circuit! Closing.");
return -1;
@ -1085,7 +1085,7 @@ void connection_edge_consider_sending_sendme(connection_t *conn) {
if (connection_outbuf_too_full(conn))
return;
circ = circuit_get_by_conn(conn);
circ = circuit_get_by_edge_conn(conn);
if (!circ) {
/* this can legitimately happen if the destroy has already
* arrived and torn down the circuit */