From: Vsevolod Stakhov Date: Mon, 8 Oct 2012 15:09:51 +0000 (+0400) Subject: Make mlock option as tunable. X-Git-Tag: 0.5.3~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a1e2b2d84b185b5430252d7ead5806944be433af;p=rspamd.git Make mlock option as tunable. --- diff --git a/src/cfg_file.h b/src/cfg_file.h index eaad2ff22..47e22cafd 100644 --- a/src/cfg_file.h +++ b/src/cfg_file.h @@ -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 */ diff --git a/src/cfg_xml.c b/src/cfg_xml.c index a144db720..99aad12ab 100644 --- a/src/cfg_xml.c +++ b/src/cfg_xml.c @@ -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 diff --git a/src/main.c b/src/main.c index 406df0adf..a5cad0ba9 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/statfile.c b/src/statfile.c index 0c1cee2e0..e5672f8fa 100644 --- a/src/statfile.c +++ b/src/statfile.c @@ -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; } diff --git a/src/statfile.h b/src/statfile.h index 5f7e856e5..b6c6d0011 100644 --- a/src/statfile.h +++ b/src/statfile.h @@ -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