]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Check limits after being set, migrate to uint64
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 Mar 2019 12:32:19 +0000 (12:32 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 Mar 2019 12:32:19 +0000 (12:32 +0000)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/worker_util.c

index c102ef570ce3a4663ce4c8f1b98f5d9eb2f6a874..5b9e89c6c8947f633594b24f362c6c9aeba4251b 100644 (file)
@@ -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 */
index 59b1fc932e0595104c8f1de3b2aac46e762b4d0c..9ea80a49cf1f4a652a2708a84612616f6a1f2eb9 100644 (file)
@@ -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",
index 06296bba2e2c7cf97e3f0b2be4c5b944cdbce0db..a5bb968e60b41fdba359716b3505003ccc040023 100644 (file)
@@ -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);
+                       }
                }
        }
 }