re-try streams at most 4 times

svn:r1242
This commit is contained in:
Roger Dingledine 2004-03-07 23:50:15 +00:00
parent 694d287774
commit 0ab367ed91
4 changed files with 20 additions and 8 deletions

View File

@ -491,6 +491,8 @@ int fetch_from_buf_socks(buf_t *buf, socks_request_t *req) {
}
assert(0);
case 4: /* socks4 */
/* http://archive.socks.permeo.com/protocol/socks4.protocol */
/* http://archive.socks.permeo.com/protocol/socks4a.protocol */
req->socks_version = 4;
if(buf->datalen < SOCKS4_NETWORK_LEN) /* basic info available? */

View File

@ -540,6 +540,7 @@ repeat_connection_edge_package_raw_inbuf:
goto repeat_connection_edge_package_raw_inbuf;
}
#define MAX_STREAM_RETRIES 4
void connection_ap_expire_beginning(void) {
connection_t **carray;
connection_t *conn;
@ -554,18 +555,24 @@ void connection_ap_expire_beginning(void) {
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
@ -580,8 +587,8 @@ void connection_ap_expire_beginning(void) {
/* 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 */

View File

@ -189,6 +189,8 @@
#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
@ -363,6 +365,7 @@ struct connection_t {
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;

View File

@ -846,7 +846,7 @@ routerinfo_t *router_get_entry_from_string(const char *s,
tok = find_first_by_keyword(tokens, K_PORTS);
if (tok && ports_set) {
log_fn(LOG_WARN,"Rendundant ports line");
log_fn(LOG_WARN,"Redundant ports line");
goto err;
} else if (tok) {
if (tok->n_args != 3) {