]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
forward-port the dns and maxconn fixes
authorRoger Dingledine <arma@torproject.org>
Fri, 28 Jan 2005 08:53:47 +0000 (08:53 +0000)
committerRoger Dingledine <arma@torproject.org>
Fri, 28 Jan 2005 08:53:47 +0000 (08:53 +0000)
svn:r3448

src/or/config.c
src/or/connection_edge.c
src/or/dns.c
src/or/main.c
src/or/or.h

index 3175e13a119292bf65122143df21518d83fc5884..33f0e023d39a61b38e8439b74ca50419f23158a3 100644 (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;
   }
 
index 1d5c4ad396646c7ab1a05aebb403f8caec583d50..16ef484f878227271abf4c29592e792cd7761cf5 100644 (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 */
index dfa6876d915ca95ae099b92b6ed5d9ced508c62d..6d98c89d83b70f11f58eacaa522707582d2d0413 100644 (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);
index 3bd618b2c42023efa7a1496e6eab9ead0b9ee57c..0e0af46b4e625213e355b1f88cd54ee729699ca7 100644 (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;
   }
 
index 55d492a5435235ae7c20d70b0dfa6869cf96dce9..bdc880df69aa0298502394987dee2c4a8594ac6a 100644 (file)
 
 /** 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