goto repeat_connection_edge_package_raw_inbuf;
}
+#define MAX_STREAM_RETRIES 4
void connection_ap_expire_beginning(void) {
connection_t **carray;
connection_t *conn;
if (conn->type != CONN_TYPE_AP ||
conn->state != AP_CONN_STATE_CONNECT_WAIT)
continue;
- if (now - conn->timestamp_lastread >= 15) {
+ if (now - conn->timestamp_lastread < 15)
+ continue;
+ conn->num_retries++;
+ circ = circuit_get_by_conn(conn);
+ if(conn->num_retries >= MAX_STREAM_RETRIES) {
+ log_fn(LOG_WARN,"Stream is %d seconds late. Giving up.",
+ 15*conn->num_retries);
+ circuit_log_path(LOG_WARN, circ);
+ connection_mark_for_close(conn,END_STREAM_REASON_TIMEOUT);
+ } else {
log_fn(LOG_WARN,"Stream is %d seconds late. Retrying.",
(int)(now - conn->timestamp_lastread));
- circ = circuit_get_by_conn(conn);
circuit_log_path(LOG_WARN, circ);
/* send an end down the circuit */
connection_edge_end(conn, END_STREAM_REASON_TIMEOUT, conn->cpath_layer);
/* un-mark it as ending, since we're going to reuse it */
conn->has_sent_end = 0;
- /* move it back into 'pending' state. It's possible it will
- * reattach to this same circuit, but that's good enough for now.
- */
+ /* move it back into 'pending' state. */
conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
circuit_detach_stream(circ, conn);
/* kludge to make us not try this circuit again, yet to allow
/* Don't need to send end -- we're not connected */
connection_mark_for_close(conn, 0);
}
- }
- }
+ } /* end if max_retries */
+ } /* end for */
}
/* Tell any APs that are waiting for a new circuit that one is available */
#define RELAY_COMMAND_TRUNCATE 8
#define RELAY_COMMAND_TRUNCATED 9
#define RELAY_COMMAND_DROP 10
+#define RELAY_COMMAND_RESOLVE 11
+#define RELAY_COMMAND_RESOLVED 12
#define _MIN_END_STREAM_REASON 1
#define END_STREAM_REASON_MISC 1
int done_receiving;
char has_sent_end; /* for debugging: set once we've set the stream end,
and check in circuit_about_to_close_connection() */
+ char num_retries; /* how many times have we re-tried beginning this stream? */
/* Used only by AP connections */
socks_request_t *socks_request;