]> source.dussan.org Git - rspamd.git/commitdiff
Make mlock option as tunable.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 8 Oct 2012 15:09:51 +0000 (19:09 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 8 Oct 2012 15:09:51 +0000 (19:09 +0400)
src/cfg_file.h
src/cfg_xml.c
src/main.c
src/statfile.c
src/statfile.h

index eaad2ff224055d86fc27989454525aac0215e711..47e22cafdcaeba25c4f89b31944d4a0ca7a8c8a2 100644 (file)
@@ -280,6 +280,7 @@ struct config_file {
        gsize max_statfile_size;                                                /**< maximum size for statfile                                                  */
        guint32 statfile_sync_interval;                                 /**< synchronization interval                                                   */
        guint32 statfile_sync_timeout;                                  /**< synchronization timeout                                                    */
+       gboolean mlock_statfile_pool;                                   /**< use mlock (2) for locking statfiles                                */
 
        struct memcached_server memcached_servers[MAX_MEMCACHED_SERVERS];       /**< memcached servers                          */
        gsize memcached_servers_num;                                    /**< number of memcached servers                                                */
index a144db720b05677977017c69cd06e3be50a5e56a..99aad12ab8cff0ad6792590e9ca27e578b9c7ce2 100644 (file)
@@ -318,6 +318,12 @@ static struct xml_parser_rule grammar[] = {
                                G_STRUCT_OFFSET (struct config_file, dynamic_conf),
                                NULL
                        },
+                       {
+                               "use_mlock",
+                               xml_handle_boolean,
+                               G_STRUCT_OFFSET (struct config_file, mlock_statfile_pool),
+                               NULL
+                       },
                        NULL_ATTR
                },
                NULL_DEF_ATTR
index 406df0adfb2f983f2f7b7e609094a7aa0d52e51f..a5cad0ba9af9e57a4fd5b585daf29853ae31dedd 100644 (file)
@@ -977,7 +977,7 @@ main (gint argc, gchar **argv, gchar **env)
        setproctitle ("main process");
 
        /* Init statfile pool */
-       rspamd_main->statfile_pool = statfile_pool_new (rspamd_main->server_pool, rspamd_main->cfg->max_statfile_size);
+       rspamd_main->statfile_pool = statfile_pool_new (rspamd_main->server_pool, rspamd_main->cfg->max_statfile_size, rspamd_main->cfg->mlock_statfile_pool);
 
        event_init ();
        g_mime_init (0);
index 0c1cee2e04d4e3ae17ddf5b3449530cdcafca89d..e5672f8fadf2fcab63a5b70a65435ece256c8a61 100644 (file)
@@ -205,7 +205,7 @@ statfile_pool_expire (statfile_pool_t * pool)
 }
 
 statfile_pool_t                *
-statfile_pool_new (memory_pool_t *pool, size_t max_size)
+statfile_pool_new (memory_pool_t *pool, size_t max_size, gboolean use_mlock)
 {
        statfile_pool_t                *new;
 
@@ -214,7 +214,7 @@ statfile_pool_new (memory_pool_t *pool, size_t max_size)
        new->max = max_size;
        new->files = memory_pool_alloc0 (new->pool, STATFILES_MAX * sizeof (stat_file_t));
        new->lock = memory_pool_get_mutex (new->pool);
-       new->mlock_ok = TRUE;
+       new->mlock_ok = use_mlock;
 
        return new;
 }
index 5f7e856e53b4917f26de17fe0f4cedd7d838a409..b6c6d001174c781972980bb635a20e044dbf6a18 100644 (file)
@@ -106,7 +106,7 @@ struct statfile;
  * @param max_size maximum size
  * @return statfile pool object
  */
-statfile_pool_t* statfile_pool_new (memory_pool_t *pool, size_t max_size);
+statfile_pool_t* statfile_pool_new (memory_pool_t *pool, size_t max_size, gboolean use_mlock);
 
 /**
  * Open statfile and attach it to pool