[packages] transmission: set ulimit for open files
authorCezary Jackiewicz <cezary@eko.one.pl>
Thu, 10 Mar 2011 05:58:02 +0000 (05:58 +0000)
committerCezary Jackiewicz <cezary@eko.one.pl>
Thu, 10 Mar 2011 05:58:02 +0000 (05:58 +0000)
Currently, transmission daemon allows you to set the max number of open
files, but it can be more than allowed by the system, thus resulting in
errors if transmission uses more than set in ulimit. The following is
a patch to compare ulimit vs open_file_limit from /etc/config/transmission.
If the open_file_limit is greater than `ulimit -n`, then invoke
ulimit -n open_file_limit + 8 (since transmission's open file limit any
seems to pertain only to open torrent files)

Signed-off-by: Joe Roback <joe at roback.cc>
SVN-Revision: 25991

net/transmission/Makefile
net/transmission/files/transmission.init

index a92db7c6f952e2b046f83fcd66c0992a9f18ee64..679a7e398641a7303759fa1b6b6e120a390db107 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=transmission
 PKG_VERSION:=2.22
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://mirrors.m0k.org/transmission/files
index bdfe2e0081892951619ad9c389a1ccaeaf46acb7..54951782282d8f9cc15179d13ccb4b78b8af52e3 100644 (file)
@@ -40,6 +40,8 @@ start_service() {
        local enable=0
        local enabled=0
        local run_as_usr='root'
+       local open_file_limit=0
+       local ulimit_files=`ulimit -n`
 
        # disabled?
        config_get_bool enable "$s" enable 0 # compatibility with prev version
@@ -75,6 +77,13 @@ start_service() {
 
        chown -R $run_as_usr $config_dir
 
+       config_get open_file_limit "$s" open_file_limit
+       let open_limit_files="$open_file_limit + 8"
+
+       if [ ${open_file_limit} -gt ${ulimit_files} ]; then
+               ulimit -n $open_limit_files
+       fi
+
        eval "$SSD -c $run_as_usr -q -b -x $BIN -S -- -g $config_dir"
 }