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;
}
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 */
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;
}
struct cached_resolve search;
struct cached_resolve *resolve;
connection_t *pendconn;
+ circuit_t *circ;
strlcpy(search.address, address, sizeof(search.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);
/** 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;
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;
}
/** 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
#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