summaryrefslogtreecommitdiffstats
path: root/src/controller.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/controller.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/controller.c')
-rw-r--r--src/controller.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/controller.c b/src/controller.c
index 45c026425..b712895d2 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -60,7 +60,8 @@ worker_t controller_worker = {
TRUE, /* Has socket */
FALSE, /* Non unique */
FALSE, /* Non threaded */
- TRUE /* Killable */
+ TRUE, /* Killable */
+ SOCK_STREAM /* TCP socket */
};
enum command_type {
@@ -171,7 +172,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);
+ worker_stop_accept (worker);
msg_info ("controller's shutdown is pending in %d sec", 2);
event_loopexit (&tv);
return;
@@ -1886,22 +1887,15 @@ init_controller (void)
void
start_controller (struct rspamd_worker *worker)
{
- struct sigaction signals;
gchar *hostbuf;
gsize hostmax;
- struct rspamd_controller_ctx *ctx;
+ struct rspamd_controller_ctx *ctx = worker->ctx;
GError *err = NULL;
struct timeval tv;
- worker->srv->pid = getpid ();
- ctx = worker->ctx;
-
- ctx->ev_base = event_init ();
+ ctx->ev_base = prepare_worker (worker, "controller", sig_handler, accept_socket);
g_mime_init (0);
- 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);
@@ -1949,16 +1943,10 @@ start_controller (struct rspamd_worker *worker)
gethostname (hostbuf, hostmax);
hostbuf[hostmax - 1] = '\0';
rspamd_snprintf (greetingbuf, sizeof (greetingbuf), "Rspamd version %s is running on %s" CRLF, RVERSION, hostbuf);
- /* Accept event */
- event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST, accept_socket, (void *)worker);
- event_base_set (ctx->ev_base, &worker->bind_ev);
- event_add (&worker->bind_ev, NULL);
start_map_watch (worker->srv->cfg, ctx->ev_base);
ctx->resolver = dns_resolver_init (ctx->ev_base, worker->srv->cfg);
- gperf_profiler_init (worker->srv->cfg, "controller");
-
event_base_loop (ctx->ev_base, 0);
close_log (worker->srv->logger);