diff options
author | Roger Dingledine <arma@torproject.org> | 2005-01-28 08:53:47 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-01-28 08:53:47 +0000 |
commit | b2fbd834f0c339ce2102af424e68c85aa566153e (patch) | |
tree | 3c7994e1298d0b9786cb4a644b401107c399f28b /src | |
parent | d7cee9dbf430ddbf24095287984b305659db9670 (diff) | |
download | tor-b2fbd834f0c339ce2102af424e68c85aa566153e.tar.gz tor-b2fbd834f0c339ce2102af424e68c85aa566153e.zip |
forward-port the dns and maxconn fixes
svn:r3448
Diffstat (limited to 'src')
-rw-r--r-- | src/or/config.c | 4 | ||||
-rw-r--r-- | src/or/connection_edge.c | 5 | ||||
-rw-r--r-- | src/or/dns.c | 13 | ||||
-rw-r--r-- | src/or/main.c | 4 | ||||
-rw-r--r-- | src/or/or.h | 5 |
5 files changed, 20 insertions, 11 deletions
diff --git a/src/or/config.c b/src/or/config.c index 3175e13a11..33f0e023d3 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1328,8 +1328,8 @@ options_validate(or_options_t *options) result = -1; } - if (options->MaxConn >= MAXCONNECTIONS) { - log(LOG_WARN, "MaxConn option must be less than %d.", MAXCONNECTIONS); + if (options->MaxConn > MAXCONNECTIONS) { + log(LOG_WARN, "MaxConn option must be at most %d.", MAXCONNECTIONS); result = -1; } diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 1d5c4ad396..16ef484f87 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -842,7 +842,10 @@ int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) { return 0; case -1: /* resolve failed */ log_fn(LOG_INFO,"Resolve failed (%s).", n_stream->address); - connection_edge_end(n_stream, END_STREAM_REASON_RESOLVEFAILED, n_stream->cpath_layer); + if (!n_stream->marked_for_close) { + connection_edge_end(n_stream, END_STREAM_REASON_RESOLVEFAILED, + n_stream->cpath_layer); + } connection_free(n_stream); break; case 0: /* resolve added to pending list */ diff --git a/src/or/dns.c b/src/or/dns.c index dfa6876d91..6d98c89d83 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -280,8 +280,9 @@ static int assign_to_dnsworker(connection_t *exitconn) { if (!dnsconn) { log_fn(LOG_WARN,"no idle dns workers. Failing."); - dns_cancel_pending_resolve(exitconn->address); - send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR_TRANSIENT); + if (exitconn->purpose == EXIT_PURPOSE_RESOLVE) + send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR_TRANSIENT); + dns_cancel_pending_resolve(exitconn->address); /* also sends end */ return -1; } @@ -387,6 +388,7 @@ void dns_cancel_pending_resolve(char *address) { struct cached_resolve search; struct cached_resolve *resolve; connection_t *pendconn; + circuit_t *circ; strlcpy(search.address, address, sizeof(search.address)); @@ -412,9 +414,12 @@ void dns_cancel_pending_resolve(char *address) { pendconn = pend->conn; tor_assert(pendconn->s == -1); if (!pendconn->marked_for_close) { - connection_edge_end(pendconn, END_STREAM_REASON_MISC, pendconn->cpath_layer); + connection_edge_end(pendconn, END_STREAM_REASON_RESOURCELIMIT, + pendconn->cpath_layer); } - circuit_detach_stream(circuit_get_by_conn(pendconn), pendconn); + circ = circuit_get_by_conn(pendconn); + if (circ) + circuit_detach_stream(circ, pendconn); connection_free(pendconn); resolve->pending_connections = pend->next; tor_free(pend); diff --git a/src/or/main.c b/src/or/main.c index 3bd618b2c4..0e0af46b4e 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -65,7 +65,7 @@ static time_t time_to_fetch_running_routers = 0; /** Array of all open connections; each element corresponds to the element of * poll_array in the same position. The first nfds elements are valid. */ -static connection_t *connection_array[MAXCONNECTIONS] = +static connection_t *connection_array[MAXCONNECTIONS+1] = { NULL }; static smartlist_t *closeable_connection_lst = NULL; @@ -115,7 +115,7 @@ int connection_add(connection_t *conn) { tor_assert(conn->s >= 0); if (nfds >= get_options()->MaxConn-1) { - log_fn(LOG_WARN,"failing because nfds is too high."); + log_fn(LOG_WARN,"Failing because we have %d connections already. Please set MaxConn higher.", nfds); return -1; } diff --git a/src/or/or.h b/src/or/or.h index 55d492a543..bdc880df69 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -130,7 +130,7 @@ /** Upper bound on maximum simultaneous connections; can be lowered by * config file. */ -#define MAXCONNECTIONS 10000 +#define MAXCONNECTIONS 15000 #define DEFAULT_BANDWIDTH_OP (1024 * 1000) #define MAX_NICKNAME_LEN 19 @@ -401,7 +401,8 @@ typedef enum { #define END_STREAM_REASON_DESTROY 5 #define END_STREAM_REASON_DONE 6 #define END_STREAM_REASON_TIMEOUT 7 -#define _MAX_END_STREAM_REASON 7 +#define END_STREAM_REASON_RESOURCELIMIT 8 +#define _MAX_END_STREAM_REASON 8 #define RESOLVED_TYPE_IPV4 4 #define RESOLVED_TYPE_IPV6 6 |