diff options
author | Roger Dingledine <arma@torproject.org> | 2002-07-18 06:37:58 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2002-07-18 06:37:58 +0000 |
commit | 267434bdeac40a2ccc2677119ddc1925b80c0c4c (patch) | |
tree | 27ce149ec317584dddb923f8e7fd4544baf59d15 /src/or/connection_ap.c | |
parent | ccdef66b68a2f61dfe600fddafaf270537928fac (diff) | |
download | tor-267434bdeac40a2ccc2677119ddc1925b80c0c4c.tar.gz tor-267434bdeac40a2ccc2677119ddc1925b80c0c4c.zip |
Implemented congestion control
Servers are allowed to send 100 cells initially, and can't send more until
they receive a 'sendme' cell from that direction, indicating that they
can send 10 more cells. As it currently stands, the exit node quickly
runs out of window, and sends bursts of 10 whenever a sendme cell gets
to him. This is much much much faster (and more flexible) than the old
"give each circuit 1 kB/s and hope nothing overflows" approach.
Also divided out the connection_watch_events into stop_reading,
start_writing, etc. That way we can control them separately.
svn:r54
Diffstat (limited to 'src/or/connection_ap.c')
-rw-r--r-- | src/or/connection_ap.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/or/connection_ap.c b/src/or/connection_ap.c index 95f60445dd..ce4fdcd89b 100644 --- a/src/or/connection_ap.c +++ b/src/or/connection_ap.c @@ -343,14 +343,17 @@ int connection_ap_process_data_cell(cell_t *cell, connection_t *conn) { assert(conn && conn->type == CONN_TYPE_AP); - if(conn->state == AP_CONN_STATE_OPEN) { - log(LOG_DEBUG,"connection_ap_process_data_cell(): In state 'open', writing to buf."); - return connection_write_to_buf(cell->payload, cell->length, conn); + if(conn->state != AP_CONN_STATE_OPEN) { + /* we should not have gotten this cell */ + log(LOG_DEBUG,"connection_ap_process_data_cell(): Got a data cell when not in 'open' state. Closing."); + return -1; } - /* else we shouldn't have gotten this cell */ - log(LOG_DEBUG,"connection_ap_process_data_cell(): Got a data cell when not in 'open' state. Closing."); - return -1; + log(LOG_DEBUG,"connection_ap_process_data_cell(): In state 'open', writing to buf."); + + if(connection_write_to_buf(cell->payload, cell->length, conn) < 0) + return -1; + return connection_consider_sending_sendme(conn); } int connection_ap_finished_flushing(connection_t *conn) { @@ -360,7 +363,8 @@ int connection_ap_finished_flushing(connection_t *conn) { switch(conn->state) { case AP_CONN_STATE_OPEN: /* FIXME down the road, we'll clear out circuits that are pending to close */ - connection_watch_events(conn, POLLIN); + connection_stop_writing(conn); + connection_consider_sending_sendme(conn); return 0; default: log(LOG_DEBUG,"Bug: connection_ap_finished_flushing() called in unexpected state."); @@ -377,7 +381,7 @@ int connection_ap_create_listener(RSA *prkey, struct sockaddr_in *local) { } int connection_ap_handle_listener_read(connection_t *conn) { - log(LOG_NOTICE,"AP: Received a connection request. Waiting for keys."); + log(LOG_NOTICE,"AP: Received a connection request. Waiting for SS."); return connection_handle_listener_read(conn, CONN_TYPE_AP, AP_CONN_STATE_SS_WAIT); } |