aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-19 21:40:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-21 11:41:46 +0100
commitf36ef520c15b89b504ea8802d0f23b9aaf28ed91 (patch)
treea09e0b401e3548d4300a5562fdd1b2c9d5730a29 /src
parent766bc1798d93051c55555511ad5b2bfc97ed2f40 (diff)
downloadrspamd-f36ef520c15b89b504ea8802d0f23b9aaf28ed91.tar.gz
rspamd-f36ef520c15b89b504ea8802d0f23b9aaf28ed91.zip
Allow only one controller process to manage rrd file.
Diffstat (limited to 'src')
-rw-r--r--src/controller.c5
-rw-r--r--src/main.c15
-rw-r--r--src/main.h4
3 files changed, 13 insertions, 11 deletions
diff --git a/src/controller.c b/src/controller.c
index 646af0deb..6ad1f4d63 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -2254,7 +2254,7 @@ start_controller_worker (struct rspamd_worker *worker)
rspamd_controller_load_saved_stats (ctx);
/* RRD collector */
- if (ctx->cfg->rrd_file) {
+ if (ctx->cfg->rrd_file && worker->index == 0) {
ctx->rrd = rspamd_rrd_file_default (ctx->cfg->rrd_file, NULL);
if (ctx->rrd) {
@@ -2264,6 +2264,9 @@ start_controller_worker (struct rspamd_worker *worker)
event_add (ctx->rrd_event, &rrd_update_time);
}
}
+ else {
+ ctx->rrd = NULL;
+ }
rspamd_controller_password_sane (ctx, ctx->password, "normal password");
rspamd_controller_password_sane (ctx, ctx->enable_password, "enable "
diff --git a/src/main.c b/src/main.c
index 1686c39b4..8b8f02f14 100644
--- a/src/main.c
+++ b/src/main.c
@@ -73,7 +73,7 @@
#define HARD_TERMINATION_TIME 10
static struct rspamd_worker * fork_worker (struct rspamd_main *,
- struct rspamd_worker_conf *);
+ struct rspamd_worker_conf *, guint);
static gboolean load_rspamd_config (struct rspamd_config *cfg,
gboolean init_modules);
@@ -449,7 +449,8 @@ set_worker_limits (struct rspamd_worker_conf *cf)
}
static struct rspamd_worker *
-fork_worker (struct rspamd_main *rspamd, struct rspamd_worker_conf *cf)
+fork_worker (struct rspamd_main *rspamd, struct rspamd_worker_conf *cf,
+ guint index)
{
struct rspamd_worker *cur;
/* Starting worker process */
@@ -461,7 +462,7 @@ fork_worker (struct rspamd_main *rspamd, struct rspamd_worker_conf *cf)
cur->pid = fork ();
cur->cf = g_malloc (sizeof (struct rspamd_worker_conf));
memcpy (cur->cf, cf, sizeof (struct rspamd_worker_conf));
- cur->pending = FALSE;
+ cur->index = index;
cur->ctx = cf->ctx;
switch (cur->pid) {
case 0:
@@ -611,7 +612,7 @@ fork_delayed (struct rspamd_main *rspamd)
cf = cur->data;
workers_pending = g_list_remove_link (workers_pending, cur);
- fork_worker (rspamd, cf);
+ fork_worker (rspamd, cf, cf->count);
g_list_free_1 (cur);
}
}
@@ -708,14 +709,14 @@ spawn_workers (struct rspamd_main *rspamd)
msg_warn_main ("cannot spawn more than 1 %s worker, so spawn one",
cf->worker->name);
}
- fork_worker (rspamd, cf);
+ fork_worker (rspamd, cf, 0);
}
else if (cf->worker->threaded) {
- fork_worker (rspamd, cf);
+ fork_worker (rspamd, cf, 0);
}
else {
for (i = 0; i < cf->count; i++) {
- fork_worker (rspamd, cf);
+ fork_worker (rspamd, cf, i);
}
}
}
diff --git a/src/main.h b/src/main.h
index 9b1f928b9..5104040a9 100644
--- a/src/main.h
+++ b/src/main.h
@@ -44,9 +44,7 @@
*/
struct rspamd_worker {
pid_t pid; /**< pid of worker */
- gboolean is_initialized; /**< is initialized */
- gboolean is_dying; /**< if worker is going to shutdown */
- gboolean pending; /**< if worker is pending to run */
+ guint index; /**< index number */
struct rspamd_main *srv; /**< pointer to server structure */
GQuark type; /**< process type */
GHashTable *signal_events; /**< signal events */