diff options
author | Ian Goldberg <iang@cs.uwaterloo.ca> | 2011-07-18 12:56:45 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-07-18 12:56:45 -0400 |
commit | 326d5c156dce64c115a76427a4dabb0e93a90033 (patch) | |
tree | 2823206a6159f269944d06ce7f627f3e45000a73 /src | |
parent | bb105ef1f604720f50466d0b375a73c3927dd010 (diff) | |
download | tor-326d5c156dce64c115a76427a4dabb0e93a90033.tar tor-326d5c156dce64c115a76427a4dabb0e93a90033.tar.gz |
Implement the client side of optimistic data (proposal 174)
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection_edge.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index f2ddfc76d..7551c3943 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -157,13 +157,22 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial) case EXIT_CONN_STATE_CONNECTING: case AP_CONN_STATE_RENDDESC_WAIT: case AP_CONN_STATE_CIRCUIT_WAIT: - case AP_CONN_STATE_CONNECT_WAIT: case AP_CONN_STATE_RESOLVE_WAIT: case AP_CONN_STATE_CONTROLLER_WAIT: log_info(LD_EDGE, "data from edge while in '%s' state. Leaving it on buffer.", conn_state_to_string(conn->_base.type, conn->_base.state)); return 0; + case AP_CONN_STATE_CONNECT_WAIT: + log_info(LD_EDGE, + "data from edge while in '%s' state. Sending it anyway. package_partial=%d, buflen=%d", + conn_state_to_string(conn->_base.type, conn->_base.state), package_partial, buf_datalen(TO_CONN(conn)->inbuf)); + if (connection_edge_package_raw_inbuf(conn, package_partial, NULL) < 0) { + /* (We already sent an end cell if possible) */ + connection_mark_for_close(TO_CONN(conn)); + return -1; + } + return 0; } log_warn(LD_BUG,"Got unexpected state %d. Closing.",conn->_base.state); tor_fragile_assert(); @@ -2395,6 +2404,13 @@ connection_ap_handshake_send_begin(edge_connection_t *ap_conn) log_info(LD_APP,"Address/port sent, ap socket %d, n_circ_id %d", ap_conn->_base.s, circ->_base.n_circ_id); control_event_stream_status(ap_conn, STREAM_EVENT_SENT_CONNECT, 0); + + /* If there's queued-up data, send it now */ + log_warn(LD_APP, "Possibly sending queued-up data: %d", buf_datalen(TO_CONN(ap_conn)->inbuf)); + if (connection_edge_package_raw_inbuf(ap_conn, 1, NULL) < 0) { + connection_mark_for_close(TO_CONN(ap_conn)); + } + return 0; } |