From 962e95df5231c6f8ccb3ad5d4f3a1cf5a327e142 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Loyet?= Date: Wed, 19 May 2010 18:37:25 +0000 Subject: [PATCH] - set hard and soft limit (instead of only the soft limit) when setting rlimit_core or rlimit_files - remove the debug log about getrlimit on the main process wich is meaningless when rlmit_* settings are set --- sapi/fpm/fpm/fpm_unix.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c index 0cec761167..395d703d18 100644 --- a/sapi/fpm/fpm/fpm_unix.c +++ b/sapi/fpm/fpm/fpm_unix.c @@ -150,21 +150,20 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ if (wp->config->rlimit_files) { struct rlimit r; - getrlimit(RLIMIT_NOFILE, &r); - r.rlim_cur = (rlim_t) wp->config->rlimit_files; -// r.rlim_max = (rlim_t) wp->config->rlimit_files; + r.rlim_max = r.rlim_cur = (rlim_t) wp->config->rlimit_files; + if (0 > setrlimit(RLIMIT_NOFILE, &r)) { - zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_NOFILE) failed", wp->config->name); + zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_NOFILE, %d) failed (%d)", wp->config->name, wp->config->rlimit_files, errno); } } if (wp->config->rlimit_core) { struct rlimit r; - getrlimit(RLIMIT_CORE, &r); - r.rlim_cur = wp->config->rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) wp->config->rlimit_core; + r.rlim_max = r.rlim_cur = wp->config->rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) wp->config->rlimit_core; + if (0 > setrlimit(RLIMIT_CORE, &r)) { - zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_CORE) failed", wp->config->name); + zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_CORE, %d) failed (%d)", wp->config->name, wp->config->rlimit_core, errno); } } @@ -248,14 +247,6 @@ int fpm_unix_init_main() /* {{{ */ } fpm_stdio_init_final(); - - { - struct rlimit r; - getrlimit(RLIMIT_NOFILE, &r); - - zlog(ZLOG_STUFF, ZLOG_NOTICE, "getrlimit(nofile): max:%lld, cur:%lld", - (long long) r.rlim_max, (long long) r.rlim_cur); - } return 0; } /* }}} */ -- 2.40.0