diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-12-18 17:48:06 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-12-18 17:48:06 +0300 |
commit | c6e6ea88a2e03609b0be013d2df0de1c6062712f (patch) | |
tree | 7492bb4cb0d47466c900319fa040b0d428560431 /src/main.c | |
parent | 1b1bcd6966f47a2568acee011dd4b9f18195d765 (diff) | |
download | rspamd-c6e6ea88a2e03609b0be013d2df0de1c6062712f.tar.gz rspamd-c6e6ea88a2e03609b0be013d2df0de1c6062712f.zip |
* Add limits support to each worker (max open files and max core size)
* Fix dependency on lex and yacc sources
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c index 49ef09b59..dd17b98d1 100644 --- a/src/main.c +++ b/src/main.c @@ -329,6 +329,31 @@ reread_config (struct rspamd_main *rspamd) } } +static void +set_worker_limits (struct worker_conf *cf) +{ + struct rlimit rlmt; + + if (cf->rlimit_nofile != 0) { + rlmt.rlim_cur = (rlim_t) cf->rlimit_nofile; + rlmt.rlim_max = (rlim_t) cf->rlimit_nofile; + + if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) { + msg_warn ("set_worker_limits: cannot set files rlimit: %d, %s", cf->rlimit_nofile, strerror (errno)); + } + } + + if (cf->rlimit_maxcore != 0) { + rlmt.rlim_cur = (rlim_t) cf->rlimit_maxcore; + rlmt.rlim_max = (rlim_t) cf->rlimit_maxcore; + + if (setrlimit(RLIMIT_CORE, &rlmt) == -1) { + msg_warn ("set_worker_limits: cannot set max core rlimit: %d, %s", cf->rlimit_maxcore, strerror (errno)); + } + } + +} + static struct rspamd_worker * fork_worker (struct rspamd_main *rspamd, struct worker_conf *cf) { @@ -347,6 +372,8 @@ fork_worker (struct rspamd_main *rspamd, struct worker_conf *cf) case 0: /* Drop privilleges */ drop_priv (cfg); + /* Set limits */ + set_worker_limits (cf); switch (cf->type) { case TYPE_CONTROLLER: setproctitle ("controller process"); |