From 15dc327ac96fe547b8bcd7676e76a26fe8c9fd33 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 3 Nov 2014 10:23:32 +0000 Subject: [PATCH] Configure upstreams in workers. --- src/controller.c | 1 + src/smtp_proxy.c | 1 + src/worker.c | 1 + test/rspamd_upstream_test.c | 6 ++++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/controller.c b/src/controller.c index 98a9df614..2fb23877e 100644 --- a/src/controller.c +++ b/src/controller.c @@ -1721,6 +1721,7 @@ start_controller_worker (struct rspamd_worker *worker) worker->srv->cfg); rspamd_upstreams_library_init (ctx->resolver->r, ctx->ev_base); + rspamd_upstreams_library_config (worker->srv->cfg); /* Maps events */ start_map_watch (worker->srv->cfg, ctx->ev_base); diff --git a/src/smtp_proxy.c b/src/smtp_proxy.c index 7e881994f..2db126d37 100644 --- a/src/smtp_proxy.c +++ b/src/smtp_proxy.c @@ -1073,6 +1073,7 @@ start_smtp_proxy (struct rspamd_worker *worker) worker->srv->cfg); rspamd_upstreams_library_init (ctx->resolver->r, ctx->ev_base); + rspamd_upstreams_library_config (worker->srv->cfg); /* Set umask */ umask (S_IWGRP | S_IWOTH | S_IROTH | S_IRGRP); diff --git a/src/worker.c b/src/worker.c index afd9a9b72..4bca03f2d 100644 --- a/src/worker.c +++ b/src/worker.c @@ -319,6 +319,7 @@ start_worker (struct rspamd_worker *worker) worker->srv->cfg); rspamd_upstreams_library_init (ctx->resolver->r, ctx->ev_base); + rspamd_upstreams_library_config (worker->srv->cfg); /* Create classify pool */ ctx->classify_pool = NULL; diff --git a/test/rspamd_upstream_test.c b/test/rspamd_upstream_test.c index fa81aecd9..16ce27160 100644 --- a/test/rspamd_upstream_test.c +++ b/test/rspamd_upstream_test.c @@ -61,6 +61,7 @@ rspamd_upstream_test_func (void) struct rspamd_config *cfg; gint i, success = 0; const gint assumptions = 100500; + gdouble p; cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config)); bzero (cfg, sizeof (struct rspamd_config)); @@ -103,12 +104,13 @@ rspamd_upstream_test_func (void) } } + p = 1.0 - fabs (3.0 / 4.0 - (gdouble)success / (gdouble)assumptions); /* * P value is calculated as following: * when we add/remove M upstreams from the list, the probability of hash * miss should be close to the relation N / (N + M), where N is the size of * the previous upstreams list. */ - msg_info ("p value for hash consistency: %.6f", 1.0 - fabs ((3.0 / 4.0 - - (gdouble)success / (gdouble)assumptions))); + msg_info ("p value for hash consistency: %.6f", p); + g_assert (p > 0.9); } -- 2.39.5