diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-03-19 12:32:19 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-03-19 12:32:19 +0000 |
commit | e49164c4fd5756bbf950f5a2fb77e9685c07d806 (patch) | |
tree | 4f7814f6c353fb28dcc9222120e36b94b778442e | |
parent | 99ff1c8add46cf0f32610ee8145ea3fe20654c5e (diff) | |
download | rspamd-e49164c4fd5756bbf950f5a2fb77e9685c07d806.tar.gz rspamd-e49164c4fd5756bbf950f5a2fb77e9685c07d806.zip |
[Feature] Check limits after being set, migrate to uint64
-rw-r--r-- | src/libserver/cfg_file.h | 4 | ||||
-rw-r--r-- | src/libserver/cfg_rcl.c | 4 | ||||
-rw-r--r-- | src/libserver/worker_util.c | 20 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index c102ef570..5b9e89c6c 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -212,8 +212,8 @@ struct rspamd_worker_conf { struct rspamd_worker_bind_conf *bind_conf; /**< bind configuration */ gint16 count; /**< number of workers */ GList *listen_socks; /**< listening sockets descriptors */ - guint32 rlimit_nofile; /**< max files limit */ - guint32 rlimit_maxcore; /**< maximum core file size */ + guint64 rlimit_nofile; /**< max files limit */ + guint64 rlimit_maxcore; /**< maximum core file size */ GHashTable *params; /**< params for worker */ GQueue *active_workers; /**< linked list of spawned workers */ gboolean has_socket; /**< whether we should make listening socket in main process */ diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 59b1fc932..9ea80a49c 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -2255,13 +2255,13 @@ rspamd_rcl_config_init (struct rspamd_config *cfg, GHashTable *skip_sections) "max_files", rspamd_rcl_parse_struct_integer, G_STRUCT_OFFSET (struct rspamd_worker_conf, rlimit_nofile), - RSPAMD_CL_FLAG_INT_32, + RSPAMD_CL_FLAG_INT_64, "Maximum number of opened files per worker"); rspamd_rcl_add_default_handler (sub, "max_core", rspamd_rcl_parse_struct_integer, G_STRUCT_OFFSET (struct rspamd_worker_conf, rlimit_maxcore), - RSPAMD_CL_FLAG_INT_32, + RSPAMD_CL_FLAG_INT_64, "Max size of core file in bytes"); rspamd_rcl_add_default_handler (sub, "enabled", diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 06296bba2..a5bb968e6 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -557,10 +557,28 @@ rspamd_worker_set_limits (struct rspamd_main *rspamd_main, rlmt.rlim_max = (rlim_t) cf->rlimit_maxcore; if (setrlimit (RLIMIT_CORE, &rlmt) == -1) { - msg_warn_main ("cannot set max core rlimit: %d, %s", + msg_warn_main ("cannot set max core rlimit: %HL, %s", cf->rlimit_maxcore, strerror (errno)); } + + /* Ensure that we did it */ + memset (&rlmt, 0, sizeof (rlmt)); + + if (getrlimit (RLIMIT_CORE, &rlmt) == -1) { + msg_warn_main ("cannot get max core rlimit: %HL, %s", + cf->rlimit_maxcore, + strerror (errno)); + } + + if (rlmt.rlim_cur != cf->rlimit_maxcore || + rlmt.rlim_max != cf->rlimit_maxcore) { + msg_warn_main ("setting of limits was unsuccessful: %HL was wanted, " + "but we have %HL cur and %HL max", + cf->rlimit_maxcore, + (guint64)rlmt.rlim_cur, + (guint64)rlmt.rlim_max); + } } } } |