aboutsummaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-07-20 18:42:29 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-07-20 18:42:29 +0100
commit8abd76b18ff391376fff2f6652a7f9711d7766d2 (patch)
treef0467d461f4fccb1c2dfe30b0f19ad4f15d98129 /src/fuzzy_storage.c
parent7522608cb80dc227c05f4e254ba13e9f86d7a07f (diff)
downloadrspamd-8abd76b18ff391376fff2f6652a7f9711d7766d2.tar.gz
rspamd-8abd76b18ff391376fff2f6652a7f9711d7766d2.zip
Allow listening on multiply addresses.
Now rspamd can listen on multiply ipv4/ipv6 addresses. Removed legacy workers (lmtp, kvstorage) as they are never used in production. Try to unify workers initialization.
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r--src/fuzzy_storage.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index c5ceb1b1c..7bd950014 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -71,10 +71,11 @@ worker_t fuzzy_worker = {
"fuzzy", /* Name */
init_fuzzy, /* Init function */
start_fuzzy, /* Start function */
- FALSE, /* No socket */
+ TRUE, /* No socket */
TRUE, /* Unique */
TRUE, /* Threaded */
- FALSE /* Non killable */
+ FALSE, /* Non killable */
+ SOCK_DGRAM /* UDP socket */
};
static GQueue *hashes[BUCKETS];
@@ -364,8 +365,6 @@ sigterm_handler (gint fd, short what, void *arg)
ctx = worker->ctx;
event_del (&worker->sig_ev_usr1);
event_del (&worker->sig_ev_usr2);
- event_del (&worker->bind_ev);
- close (worker->cf->listen_sock);
rspamd_mutex_lock (ctx->update_mtx);
mods = ctx->max_mods + 1;
@@ -392,8 +391,7 @@ sigusr2_handler (gint fd, short what, void *arg)
tv.tv_usec = 0;
event_del (&worker->sig_ev_usr1);
event_del (&worker->sig_ev_usr2);
- event_del (&worker->bind_ev);
- close (worker->cf->listen_sock);
+ worker_stop_accept (worker);
msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
rspamd_mutex_lock (ctx->update_mtx);
mods = ctx->max_mods + 1;
@@ -1025,21 +1023,14 @@ init_fuzzy (void)
void
start_fuzzy (struct rspamd_worker *worker)
{
- struct sigaction signals;
struct event sev;
- gint retries = 0;
struct rspamd_fuzzy_storage_ctx *ctx = worker->ctx;
GError *err = NULL;
- worker->srv->pid = getpid ();
-
- ctx->ev_base = event_init ();
+ ctx->ev_base = prepare_worker (worker, "controller", sig_handler, accept_fuzzy_socket);
server_stat = worker->srv->stat;
- init_signals (&signals, sig_handler);
- sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
-
/* SIGUSR2 handler */
signal_set (&worker->sig_ev_usr2, SIGUSR2, sigusr2_handler, (void *) worker);
event_base_set (ctx->ev_base, &worker->sig_ev_usr2);
@@ -1054,16 +1045,6 @@ start_fuzzy (struct rspamd_worker *worker)
event_base_set (ctx->ev_base, &sev);
signal_add (&sev, NULL);
- /* Listen event */
- while ((worker->cf->listen_sock =
- make_universal_socket (worker->cf->bind_addr, worker->cf->bind_port, SOCK_DGRAM, TRUE, TRUE, FALSE)) == -1) {
- sleep (1);
- if (++retries > MAX_RETRIES) {
- msg_err ("cannot bind to socket, exiting");
- exit (0);
- }
- }
-
/* Init bloom filter */
bf = bloom_create (20000000L, DEFAULT_BLOOM_HASHES);
/* Try to read hashes from file */
@@ -1078,10 +1059,6 @@ start_fuzzy (struct rspamd_worker *worker)
tmv.tv_usec = 0;
evtimer_add (&tev, &tmv);
- event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST, accept_fuzzy_socket, (void *)worker);
- event_base_set (ctx->ev_base, &worker->bind_ev);
- event_add (&worker->bind_ev, NULL);
-
/* Create radix tree */
if (ctx->update_map != NULL) {
if (!add_map (worker->srv->cfg, ctx->update_map, "Allow fuzzy updates from specified addresses",
@@ -1095,8 +1072,6 @@ start_fuzzy (struct rspamd_worker *worker)
/* Maps events */
start_map_watch (worker->srv->cfg, ctx->ev_base);
- gperf_profiler_init (worker->srv->cfg, "fuzzy");
-
ctx->update_thread = rspamd_create_thread ("fuzzy update", sync_cache, worker, &err);
if (ctx->update_thread == NULL) {
msg_err ("error creating update thread: %s", err->message);