forward-port the dns and maxconn fixes

svn:r3448
This commit is contained in:
Roger Dingledine 2005-01-28 08:53:47 +00:00
parent d7cee9dbf4
commit b2fbd834f0
5 changed files with 20 additions and 11 deletions

View File

@ -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;
}

View File

@ -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 */

View File

@ -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);

View File

@ -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;
}

View File

@ -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