aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-10-08 19:09:51 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-10-08 19:09:51 +0400
commita1e2b2d84b185b5430252d7ead5806944be433af (patch)
treec1dcf94b6772aa0160cd3b5cc3be120f9f8ac7f2 /src
parent21f0f09256917dd5dff8d3cf4680322f96c67b7f (diff)
downloadrspamd-a1e2b2d84b185b5430252d7ead5806944be433af.tar.gz
rspamd-a1e2b2d84b185b5430252d7ead5806944be433af.zip
Make mlock option as tunable.
Diffstat (limited to 'src')
-rw-r--r--src/cfg_file.h1
-rw-r--r--src/cfg_xml.c6
-rw-r--r--src/main.c2
-rw-r--r--src/statfile.c4
-rw-r--r--src/statfile.h2
5 files changed, 11 insertions, 4 deletions
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