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

[or-cvs] Clean up the rlimit thing somewhat.



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 or.h 
Log Message:
Clean up the rlimit thing somewhat.
Now we cap it better, and survive hups better.
I changed the name MaxConn to ConnLimit, to indicate
that it's a lower bound, not an upper bound. Perhaps it
needs an even better name?


Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.286.2.10
retrieving revision 1.286.2.11
diff -u -d -r1.286.2.10 -r1.286.2.11
--- config.c	5 Feb 2005 21:30:41 -0000	1.286.2.10
+++ config.c	19 Feb 2005 03:42:28 -0000	1.286.2.11
@@ -63,6 +63,7 @@
   { "BandwidthRateBytes", "BandwidthRate", 0},
   { "BandwidthBurstBytes", "BandwidthBurst", 0},
   { "DirFetchPostPeriod", "StatusFetchPeriod", 0},
+  { "MaxConn", "ConnLimit", 0},
   { NULL, NULL , 0},
 };
 #undef PLURAL
@@ -136,7 +137,7 @@
   VAR("LogLevel",            LINELIST_S, OldLogOptions,      NULL),
   VAR("LogFile",             LINELIST_S, OldLogOptions,      NULL),
   OBSOLETE("LinkPadding"),
-  VAR("MaxConn",             UINT,     _MaxConn,             "1024"),
+  VAR("ConnLimit",           UINT,     ConnLimit,            "1024"),
   VAR("MaxOnionsPending",    UINT,     MaxOnionsPending,     "100"),
   VAR("MonthlyAccountingStart",UINT,   _MonthlyAccountingStart,"0"),
   VAR("AccountingMaxKB",     UINT,     _AccountingMaxKB,     "0"),
@@ -287,25 +288,11 @@
   close_temp_logs();
   add_callback_log(LOG_NOTICE, LOG_ERR, control_event_logmsg);
 
-  if (options->_MaxConn < 1) {
-    options->_MaxConn = 1024;
-  }
-
-  if (set_max_file_descriptors(&options->_MaxConn) < 0)
+  options->_ConnLimit =
+    set_max_file_descriptors(options->ConnLimit, MAXCONNECTIONS);
+  if (options->_ConnLimit < 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 must be at most %d. Capping it.", MAXCONNECTIONS);
-    options->_MaxConn = MAXCONNECTIONS;
-  }
-
   {
     smartlist_t *sl = smartlist_create();
     for (cl = options->RedirectExit; cl; cl = cl->next) {

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.407.2.12
retrieving revision 1.407.2.13
diff -u -d -r1.407.2.12 -r1.407.2.13
--- main.c	5 Feb 2005 21:38:27 -0000	1.407.2.12
+++ main.c	19 Feb 2005 03:42:28 -0000	1.407.2.13
@@ -100,7 +100,7 @@
   tor_assert(conn);
   tor_assert(conn->s >= 0);
 
-  if (nfds >= get_options()->_MaxConn-1) {
+  if (nfds >= get_options()->_ConnLimit-1) {
     log_fn(LOG_WARN,"Failing because we have %d connections already. Please raise your ulimit -n.", nfds);
     return -1;
   }

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.508.2.12
retrieving revision 1.508.2.13
diff -u -d -r1.508.2.12 -r1.508.2.13
--- or.h	4 Feb 2005 07:16:13 -0000	1.508.2.12
+++ or.h	19 Feb 2005 03:42:28 -0000	1.508.2.13
@@ -927,7 +927,8 @@
   int DirPort; /**< Port to listen on for directory connections. */
   int AuthoritativeDir; /**< Boolean: is this an authoritative directory? */
   int ClientOnly; /**< Boolean: should we never evolve into a server role? */
-  int _MaxConn; /**< Maximum number of simultaneous connections. */
+  int ConnLimit; /**< Requested maximum number of simultaneous connections. */
+  int _ConnLimit; /**< Actual maximum number of simultaneous connections. */
   int IgnoreVersion; /**< If true, run no matter what versions of Tor the
                       * directory recommends. */
   int RunAsDaemon; /**< If true, run in the background. (Unix only) */