Procházet zdrojové kódy

Change the default for MAX_FILEDESCRIPTORS in our init script to depend on the
number of system-wide available file descriptors: /proc/sys/fs/file-max is
bigger than 100k, set ulimit -n to 32k, if it's smaller than 20k set it to
1024. Big servers at the moment regularly use more than 10k FDs, so our old
default of 8k no longer is sufficient. On the other hand we don't want lower
end systems to run out of FDs on Tor's account.


svn:r13625

Peter Palfrader před 16 roky
rodič
revize
644452a62f
3 změnil soubory, kde provedl 33 přidání a 3 odebrání
  1. 12 0
      debian/changelog
  2. 7 2
      debian/tor.default
  3. 14 1
      debian/tor.init

+ 12 - 0
debian/changelog

@@ -1,3 +1,15 @@
+tor (0.2.0.19-alpha+svn-1) unreleased; urgency=low
+
+  * Change the default for MAX_FILEDESCRIPTORS in our init script to depend
+    on the number of system-wide available file descriptors:
+    /proc/sys/fs/file-max is bigger than 100k, set ulimit -n to 32k, if it's
+    smaller than 20k set it to 1024.  Big servers at the moment regularly use
+    more than 10k FDs, so our old default of 8k no longer is sufficient.  On
+    the other hand we don't want lower end systems to run out of FDs on Tor's
+    account.
+
+ -- Peter Palfrader <weasel@debian.org>  Wed, 20 Feb 2008 23:27:35 +0100
+
 tor (0.2.0.19-alpha-1) experimental; urgency=low
 
   * New upstream version.

+ 7 - 2
debian/tor.default

@@ -9,10 +9,15 @@ RUN_DAEMON="yes"
 
 #
 # Servers sometimes may need more than the default 1024 file descriptors
-# if they are very busy and have many clients connected to them.
+# if they are very busy and have many clients connected to them.  The top
+# servers as of early 2008 regularly have more than 10000 connected
+# clients.
 #  (ulimit -n)
 #
-MAX_FILEDESCRIPTORS=8192
+# (the default varies as it depends on the number of available system-wide file
+#  descriptors.  See the init script in /etc/init.d/tor for details.)
+#
+# MAX_FILEDESCRIPTORS=
 
 #
 # If tor is seriously hogging your CPU, taking away too much cycles from

+ 14 - 1
debian/tor.init

@@ -25,7 +25,20 @@ TORPID=$TORPIDDIR/tor.pid
 DEFAULTSFILE=/etc/default/$NAME
 WAITFORDAEMON=60
 ARGS=""
-MAX_FILEDESCRIPTORS=8192
+# Let's try to figure our some sane defaults:
+if [ -r /proc/sys/fs/file-max ]; then
+	system_max=`cat /proc/sys/fs/file-max`
+	if [ "$system_max" -gt "100000" ] ; then
+		MAX_FILEDESCRIPTORS=32768
+	elif [ "$system_max" -gt "20000" ] ; then
+		MAX_FILEDESCRIPTORS=8192
+	else
+		MAX_FILEDESCRIPTORS=1024
+	fi
+else
+	MAX_FILEDESCRIPTORS=8192
+fi
+
 NICE=""
 
 test -x $DAEMON || exit 0