[or-cvs] forward-port the dns and maxconn fixes

Roger Dingledine arma at seul.org
Fri Jan 28 08:53:49 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	or.h config.c connection_edge.c main.c dns.c 
Log Message:
forward-port the dns and maxconn fixes


Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.529
retrieving revision 1.530
diff -u -d -r1.529 -r1.530
--- or.h	20 Jan 2005 20:18:32 -0000	1.529
+++ or.h	28 Jan 2005 08:53:47 -0000	1.530
@@ -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 @@
 #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

Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.304
retrieving revision 1.305
diff -u -d -r1.304 -r1.305
--- config.c	20 Jan 2005 18:39:48 -0000	1.304
+++ config.c	28 Jan 2005 08:53:47 -0000	1.305
@@ -1328,8 +1328,8 @@
     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: connection_edge.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.268
retrieving revision 1.269
diff -u -d -r1.268 -r1.269
--- connection_edge.c	17 Jan 2005 18:13:09 -0000	1.268
+++ connection_edge.c	28 Jan 2005 08:53:47 -0000	1.269
@@ -842,7 +842,10 @@
       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: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.429
retrieving revision 1.430
diff -u -d -r1.429 -r1.430
--- main.c	27 Jan 2005 21:45:32 -0000	1.429
+++ main.c	28 Jan 2005 08:53:47 -0000	1.430
@@ -65,7 +65,7 @@
 
 /** 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 @@
   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: dns.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- dns.c	19 Jan 2005 21:34:42 -0000	1.131
+++ dns.c	28 Jan 2005 08:53:47 -0000	1.132
@@ -280,8 +280,9 @@
 
   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 @@
   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 @@
     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);



More information about the tor-commits mailing list