]> source.dussan.org Git - rspamd.git/commitdiff
Configure upstreams in workers.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Nov 2014 10:23:32 +0000 (10:23 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Nov 2014 10:23:32 +0000 (10:23 +0000)
src/controller.c
src/smtp_proxy.c
src/worker.c
test/rspamd_upstream_test.c

index 98a9df614b72994665aaa09f788b7bfd710f633e..2fb23877e38df2800663b298d647e5b703c24fa8 100644 (file)
@@ -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);
 
index 7e881994fff412ca31088ef062bddbca94cced6f..2db126d37516b54ab97fc4190d0ce278dea9477d 100644 (file)
@@ -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);
 
index afd9a9b72523315720d519a0f95a79dc6a67c034..4bca03f2df3b6639175f87de56540a4e41eddac7 100644 (file)
@@ -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;
index fa81aecd97dcae16b54290fbf5c0f0e3940933cb..16ce27160fe60099a75f15b034c47aaaa5ad16f3 100644 (file)
@@ -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);
 }