diff -r e30e9b2b0e37 src/master/master-settings.c --- a/src/master/master-settings.c Wed Jan 21 02:21:35 2015 +0200 +++ b/src/master/master-settings.c Thu Jan 22 13:39:41 2015 +0200 @@ -18,6 +18,7 @@ #include #include #include +#include static bool master_settings_verify(void *_set, pool_t pool, const char **error_r); @@ -418,7 +419,7 @@ #ifdef CONFIG_BINARY const struct service_settings *default_service; #else - rlim_t fd_limit; + struct rlimit fd_limit; const char *max_client_limit_source = "default_client_limit"; unsigned int max_client_limit = set->default_client_limit; #endif @@ -591,12 +592,18 @@ client_limit, max_anvil_client_processes); } #ifndef CONFIG_BINARY - if (restrict_get_fd_limit(&fd_limit) == 0 && - fd_limit < (rlim_t)max_client_limit) { - i_warning("fd limit (ulimit -n) is lower than required " - "under max. load (%u < %u), because of %s", - (unsigned int)fd_limit, max_client_limit, - max_client_limit_source); + if (getrlimit(RLIMIT_NOFILE, &fd_limit) == 0) { +#ifdef HAVE_SETRLIMIT + rlim_t old = fd_limit.rlim_cur; + fd_limit.rlim_cur = I_MAX(old, max_client_limit); + if (setrlimit(RLIMIT_NOFILE, &fd_limit) < 0) + fd_limit.rlim_cur = old; +#endif + if (fd_limit.rlim_cur < (rlim_t)max_client_limit) + i_warning("fd limit (ulimit -n) is lower than required " + "under max. load (%u < %u), because of %s", + (unsigned int)fd_limit.rlim_cur, max_client_limit, + max_client_limit_source); } #endif