[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] hack: set MaxConn to the hard ulimit -n rather than letting...



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

Modified Files:
      Tag: tor-0_0_9-patches
	config.c main.c 
Log Message:
hack: set MaxConn to the hard ulimit -n rather than letting the
user pick one.


Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.286.2.6
retrieving revision 1.286.2.7
diff -u -d -r1.286.2.6 -r1.286.2.7
--- config.c	3 Feb 2005 23:05:39 -0000	1.286.2.6
+++ config.c	4 Feb 2005 00:44:03 -0000	1.286.2.7
@@ -287,8 +287,25 @@
   close_temp_logs();
   add_callback_log(LOG_NOTICE, LOG_ERR, control_event_logmsg);
 
-  if (set_max_file_descriptors(options->MaxConn) < 0)
+  if (options->MaxConn < 1) {
+    log(LOG_WARN, "MaxConn option must be a non-zero positive integer.");
     return -1;
+  }
+
+  if (set_max_file_descriptors(&options->MaxConn) < 0)
+    return -1;
+
+#ifdef USE_FAKE_POLL
+  if (options->MaxConn > 1024) {
+    log(LOG_INFO, "Systems without a working poll() can't set MaxConn higher than 1024 in Tor 0.0.9.x. Capping.");
+    options->MaxConn = 1024;
+  }
+#endif
+
+  if (options->MaxConn > MAXCONNECTIONS) {
+    log(LOG_INFO, "MaxConn option must be at most %d. Capping it.", MAXCONNECTIONS);
+    options->MaxConn = MAXCONNECTIONS;
+  }
 
   {
     smartlist_t *sl = smartlist_create();
@@ -1299,23 +1316,6 @@
     result = -1;
   }
 
-  if (options->MaxConn < 1) {
-    log(LOG_WARN, "MaxConn option must be a non-zero positive integer.");
-    result = -1;
-  }
-
-#ifdef USE_FAKE_POLL
-  if (options->MaxConn > 1024) {
-    log(LOG_WARN, "Systems without a working poll() can't set MaxConn higher than 1024 in Tor 0.0.9.x.");
-    result = -1;
-  }
-#endif
-
-  if (options->MaxConn > MAXCONNECTIONS) {
-    log(LOG_WARN, "MaxConn option must be at most %d.", MAXCONNECTIONS);
-    result = -1;
-  }
-
 #define MIN_DIR_FETCH_PERIOD 600
 #define MIN_DIR_POST_PERIOD 300
 #define MIN_REND_POST_PERIOD 300

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.407.2.7
retrieving revision 1.407.2.8
diff -u -d -r1.407.2.7 -r1.407.2.8
--- main.c	28 Jan 2005 08:50:10 -0000	1.407.2.7
+++ main.c	4 Feb 2005 00:44:04 -0000	1.407.2.8
@@ -100,7 +100,7 @@
   tor_assert(conn->s >= 0);
 
   if (nfds >= get_options()->MaxConn-1) {
-    log_fn(LOG_WARN,"Failing because we have %d connections already. Please set MaxConn higher.", nfds);
+    log_fn(LOG_WARN,"Failing because we have %d connections already. Please raise your ulimit -n.", nfds);
     return -1;
   }