aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-05-20 06:41:23 +0000
committerRoger Dingledine <arma@torproject.org>2003-05-20 06:41:23 +0000
commit39e9d79038f6075ec59fdafba811ffa406796b5c (patch)
treeefc72733f83deda7f2390c5ed49138441b979421 /src/or/connection_edge.c
parent59029a3eedf934407db17b29be77b89d9a12d77e (diff)
downloadtor-39e9d79038f6075ec59fdafba811ffa406796b5c.tar
tor-39e9d79038f6075ec59fdafba811ffa406796b5c.tar.gz
add circuit-level sendme relay cells
remove sendme cells replace malloc with tor_malloc patch (but not track down) bug in onion pending list streamline connection_ap handshake svn:r293
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index bae7ae8d0..0c38f6af1 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -50,7 +50,7 @@ int connection_edge_process_inbuf(connection_t *conn) {
case EXIT_CONN_STATE_OPEN:
if(connection_package_raw_inbuf(conn) < 0)
return -1;
- circuit_consider_stop_edge_reading(circuit_get_by_conn(conn), EDGE_AP);
+ circuit_consider_stop_edge_reading(circuit_get_by_conn(conn), conn->type == CONN_TYPE_AP ? EDGE_AP : EDGE_EXIT, conn->cpath_layer);
return 0;
case EXIT_CONN_STATE_CONNECTING:
log(LOG_DEBUG,"connection_edge_process_inbuf(): text from server while in 'connecting' state at exit. Leaving it on buffer.");
@@ -90,7 +90,8 @@ int connection_edge_send_command(connection_t *conn, circuit_t *circ, int relay_
return 0;
}
-int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection_t *conn, int edge_type) {
+int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection_t *conn,
+ int edge_type, crypt_path_t *layer_hint) {
int relay_command;
static int num_seen=0;
@@ -103,8 +104,6 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
num_seen++;
log(LOG_DEBUG,"connection_edge_process_relay_cell(): Now seen %d relay cells here.", num_seen);
- circuit_consider_sending_sendme(circ, edge_type);
-
/* either conn is NULL, in which case we've got a control cell, or else
* conn points to the recognized stream. */
@@ -130,13 +129,23 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
}
return connection_exit_begin_conn(cell, circ);
case RELAY_COMMAND_DATA:
+ if((edge_type == EDGE_AP && --layer_hint->deliver_window < 0) ||
+ (edge_type == EDGE_EXIT && --circ->deliver_window < 0)) {
+ log(LOG_DEBUG,"connection_edge_process_relay_cell(): circ deliver_window below 0. Killing.");
+ return -1; /* XXX kill the whole circ? */
+ }
+ log(LOG_DEBUG,"connection_edge_process_relay_cell(): circ deliver_window now %d.", edge_type == EDGE_AP ? layer_hint->deliver_window : circ->deliver_window);
+
+ if(circuit_consider_sending_sendme(circ, edge_type, layer_hint) < 0)
+ return -1;
+
if(!conn) {
log(LOG_DEBUG,"connection_edge_process_relay_cell(): relay cell dropped, unknown stream %d.",*(int*)conn->stream_id);
return 0;
}
- if((edge_type == EDGE_AP && --conn->n_receive_streamwindow < 0) ||
- (edge_type == EDGE_EXIT && --conn->p_receive_streamwindow < 0)) { /* is it below 0 after decrement? */
- log(LOG_DEBUG,"connection_edge_process_relay_cell(): receive_streamwindow below 0. Killing.");
+
+ if(--conn->deliver_window < 0) { /* is it below 0 after decrement? */
+ log(LOG_DEBUG,"connection_edge_process_relay_cell(): conn deliver_window below 0. Killing.");
return -1; /* somebody's breaking protocol. kill the whole circuit. */
}
@@ -206,16 +215,23 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
break;
case RELAY_COMMAND_SENDME:
if(!conn) {
- log(LOG_DEBUG,"connection_edge_process_relay_cell(): sendme cell dropped, unknown stream %d.",*(int*)conn->stream_id);
+ if(edge_type == EDGE_AP) {
+ assert(layer_hint);
+ layer_hint->package_window += CIRCWINDOW_INCREMENT;
+ log(LOG_DEBUG,"connection_edge_process_relay_cell(): circ-level sendme at AP, packagewindow %d.", layer_hint->package_window);
+ circuit_resume_edge_reading(circ, EDGE_AP, layer_hint);
+ } else {
+ assert(!layer_hint);
+ circ->package_window += CIRCWINDOW_INCREMENT;
+ log(LOG_DEBUG,"connection_edge_process_relay_cell(): circ-level sendme at exit, packagewindow %d.", circ->package_window);
+ circuit_resume_edge_reading(circ, EDGE_EXIT, layer_hint);
+ }
return 0;
}
- if(edge_type == EDGE_AP)
- conn->p_receive_streamwindow += STREAMWINDOW_INCREMENT;
- else
- conn->n_receive_streamwindow += STREAMWINDOW_INCREMENT;
+ conn->package_window += STREAMWINDOW_INCREMENT;
connection_start_reading(conn);
connection_package_raw_inbuf(conn); /* handle whatever might still be on the inbuf */
- circuit_consider_stop_edge_reading(circ, edge_type);
+ circuit_consider_stop_edge_reading(circ, edge_type, layer_hint);
break;
default:
log(LOG_DEBUG,"connection_edge_process_relay_cell(): unknown relay command %d.",relay_command);