[or-cvs] Try to make tor work better through squid: Limit number of ...

Peter Palfrader weasel at seul.org
Fri Feb 3 15:17:50 UTC 2006


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv7891

Modified Files:
	directory.c routerlist.c 
Log Message:
Try to make tor work better through squid: Limit number of descriptors we fetch
to 96 (was 128 previously).

We limit this number even when we do not have a http proxy explicitly
configured as some people mistakenly believe transparent proxies are a neat
idea.


Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.344
retrieving revision 1.345
diff -u -p -d -r1.344 -r1.345
--- directory.c	3 Feb 2006 12:08:31 -0000	1.344
+++ directory.c	3 Feb 2006 15:17:48 -0000	1.345
@@ -579,6 +579,11 @@ directory_send_command(connection_t *con
       tor_assert(0);
       return;
   }
+
+  if (strlen(proxystring) + strlen(url) >= 4096) {
+    warn(LD_BUG,"Bug: squid does not like URLs longer than 4095 bytes, this one is %d bytes long: %s%s", strlen(proxystring) + strlen(url), proxystring, url);
+  }
+
   tor_snprintf(request, sizeof(request), "%s %s", httpcommand, proxystring);
   connection_write_to_buf(request, strlen(request), conn);
   connection_write_to_buf(url, strlen(url), conn);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.433
retrieving revision 1.434
diff -u -p -d -r1.433 -r1.434
--- routerlist.c	1 Feb 2006 03:53:52 -0000	1.433
+++ routerlist.c	3 Feb 2006 15:17:48 -0000	1.434
@@ -3311,7 +3311,13 @@ router_list_client_downloadable(void)
 static void
 update_router_descriptor_client_downloads(time_t now)
 {
-#define MAX_DL_PER_REQUEST 128
+	/* Max amount of hashes to download per request.
+	 * Since squid does not like URLs >= 4096 bytes we limit it to 96.
+	 *   4096 - strlen(http://255.255.255.255/tor/server/d/.z) == 4058
+	 *   4058/41 (40 for the hash and 1 for the + that separates them) => 98
+	 *   So use 96 because it's a nice number.
+	 */
+#define MAX_DL_PER_REQUEST 96
 #define MIN_DL_PER_REQUEST 4
 #define MIN_REQUESTS 3
 #define MAX_DL_TO_DELAY 16



More information about the tor-commits mailing list