diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2011-05-21 12:54:33 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2011-05-21 12:54:33 +0400 |
commit | d0371ca7cd2ed125bb293f23e020bfb4e12d0d19 (patch) | |
tree | 4fe7bdb62db3087593521fc61d097dfcd9249cd9 | |
parent | 4f248a91e5fedd5298c1bb99e309f9a5986f770c (diff) | |
parent | ef71ca445b7c99f28ca80fe75fbe6b843ecc6fcb (diff) | |
download | accel-ppp-xebd-d0371ca7cd2ed125bb293f23e020bfb4e12d0d19.tar.gz accel-ppp-xebd-d0371ca7cd2ed125bb293f23e020bfb4e12d0d19.zip |
Merge branch 'master' of ssh://accel-ppp.git.sourceforge.net/gitroot/accel-ppp/accel-ppp
-rw-r--r-- | accel-pppd/main.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/accel-pppd/main.c b/accel-pppd/main.c index 2e48c45..c408736 100644 --- a/accel-pppd/main.c +++ b/accel-pppd/main.c @@ -89,19 +89,28 @@ static void change_limits(void) { FILE *f; struct rlimit lim; - unsigned int file_max; + unsigned int file_max = 1024*1024; + unsigned int nr_open = 1024*1024; + + f = fopen("/proc/sys/fs/nr_open", "r"); + if (f) { + fscanf(f, "%d", &nr_open); + fclose(f); + } f = fopen("/proc/sys/fs/file-max", "r"); if (f) { fscanf(f, "%d", &file_max); fclose(f); + } + + if (file_max > nr_open) + file_max = nr_open; - lim.rlim_cur = file_max; - lim.rlim_max = file_max; - if (setrlimit(RLIMIT_NOFILE, &lim)) - log_emerg("main: setrlimit: %s\n", strerror(errno)); - } else - log_emerg("main: failed to open '/proc/sys/fs/file-max': %s\n", strerror(errno)); + lim.rlim_cur = file_max; + lim.rlim_max = file_max; + if (setrlimit(RLIMIT_NOFILE, &lim)) + log_emerg("main: setrlimit: %s\n", strerror(errno)); } static void config_reload_notify(int r) |