]> source.dussan.org Git - rspamd.git/commitdiff
Check for SIGUSR1 by libevent to avoid signals collisions.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 30 Nov 2011 14:48:08 +0000 (17:48 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 30 Nov 2011 14:48:08 +0000 (17:48 +0300)
Remove greylist_storage as it was never used and is actually replaced with basic kvstorage.

13 files changed:
CMakeLists.txt
src/cfg_xml.c
src/controller.c
src/fuzzy_storage.c
src/greylist.h [deleted file]
src/greylist_storage.c [deleted file]
src/lmtp.c
src/main.c
src/main.h
src/smtp.c
src/util.c
src/util.h
src/worker.c

index ac401dd58ca628b2cb7f80f64d345d46ace7d413..dcc7da2fe9f1b0b8a2d6c6a0f9eddbff38a5682c 100644 (file)
@@ -777,7 +777,6 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}/src")
 SET(RSPAMDSRC  src/modules.c
                                src/controller.c
                                src/fuzzy_storage.c
-                               src/greylist_storage.c
                                src/kvstorage_server.c
                                src/lmtp.c
                                src/main.c
index 3709b496a847c4f0d6fdb3bd0b74def368d0b282..4b3a7970d37259f905def465b1b02212aa8ccfda 100644 (file)
@@ -916,10 +916,6 @@ worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GH
                wrk->type = TYPE_FUZZY;
                wrk->has_socket = FALSE;
        }
-       else if (g_ascii_strcasecmp (data, "greylist") == 0) {
-               wrk->type = TYPE_GREYLIST;
-               wrk->has_socket = FALSE;
-       }
        else if (g_ascii_strcasecmp (data, "keystorage") == 0) {
                wrk->type = TYPE_KVSTORAGE;
                wrk->has_socket = TRUE;
index 07eeef0ff45b838ed00440e41613e3e56ab991e2..206e17f82991cbfb594c248a2f7f712ee28afc24 100644 (file)
@@ -116,9 +116,6 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
 {
        struct timeval                  tv;
        switch (signo) {
-       case SIGUSR1:
-               reopen_log (rspamd_main->logger);
-               break;
        case SIGINT:
        case SIGTERM:
                if (!wanna_die) {
@@ -136,20 +133,34 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
 }
 
 static void
-sigusr_handler (gint fd, short what, void *arg)
+sigusr2_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
        struct timeval                  tv;
        tv.tv_sec = 2;
        tv.tv_usec = 0;
-       event_del (&worker->sig_ev);
+       event_del (&worker->sig_ev_usr1);
+       event_del (&worker->sig_ev_usr2);
        event_del (&worker->bind_ev);
        msg_info ("controller's shutdown is pending in %d sec", 2);
        event_loopexit (&tv);
        return;
 }
 
+/*
+ * Reopen log is designed by sending sigusr1 to active workers and pending shutdown of them
+ */
+static void
+sigusr1_handler (gint fd, short what, void *arg)
+{
+       struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
+
+       reopen_log (worker->srv->logger);
+
+       return;
+}
+
 static void
 free_session (void *ud)
 {
@@ -1231,9 +1242,14 @@ start_controller (struct rspamd_worker *worker)
        sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
 
        /* SIGUSR2 handler */
-       signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *)worker);
-       event_base_set (ctx->ev_base, &worker->sig_ev);
-       signal_add (&worker->sig_ev, NULL);
+       signal_set (&worker->sig_ev_usr2, SIGUSR2, sigusr2_handler, (void *) worker);
+       event_base_set (ctx->ev_base, &worker->sig_ev_usr2);
+       signal_add (&worker->sig_ev_usr2, NULL);
+
+       /* SIGUSR1 handler */
+       signal_set (&worker->sig_ev_usr1, SIGUSR1, sigusr1_handler, (void *) worker);
+       event_base_set (ctx->ev_base, &worker->sig_ev_usr1);
+       signal_add (&worker->sig_ev_usr1, NULL);
 
 
        start_time = time (NULL);
index b9b05cb87497fb55eab10d659a7aaf10f1de002c..408d39960c21f096f5841a3bc0cb4d0b4bfefb74 100644 (file)
@@ -102,9 +102,6 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
        switch (signo) {
-       case SIGUSR1:
-               reopen_log (rspamd_main->logger);
-               break;
        case SIGINT:
        case SIGTERM:
                /* Ignore SIGINT and SIGTERM as they are handled by libevent handler */
@@ -251,7 +248,7 @@ sigterm_handler (gint fd, short what, void *arg)
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (gint fd, short what, void *arg)
+sigusr2_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -261,7 +258,8 @@ sigusr_handler (gint fd, short what, void *arg)
        ctx = worker->ctx;
        tv.tv_sec = SOFT_SHUTDOWN_TIME;
        tv.tv_usec = 0;
-       event_del (&worker->sig_ev);
+       event_del (&worker->sig_ev_usr1);
+       event_del (&worker->sig_ev_usr2);
        event_del (&worker->bind_ev);
        close (worker->cf->listen_sock);
        msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
@@ -271,6 +269,19 @@ sigusr_handler (gint fd, short what, void *arg)
        return;
 }
 
+/*
+ * Reopen log is designed by sending sigusr1 to active workers and pending shutdown of them
+ */
+static void
+sigusr1_handler (gint fd, short what, void *arg)
+{
+       struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
+
+       reopen_log (worker->srv->logger);
+
+       return;
+}
+
 static                          gboolean
 read_hashes_file (struct rspamd_worker *wrk)
 {
@@ -790,8 +801,13 @@ start_fuzzy_storage (struct rspamd_worker *worker)
        sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
 
        /* SIGUSR2 handler */
-       signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *)worker);
-       signal_add (&worker->sig_ev, NULL);
+       signal_set (&worker->sig_ev_usr2, SIGUSR2, sigusr2_handler, (void *) worker);
+       signal_add (&worker->sig_ev_usr2, NULL);
+
+       /* SIGUSR1 handler */
+       signal_set (&worker->sig_ev_usr1, SIGUSR1, sigusr1_handler, (void *) worker);
+       signal_add (&worker->sig_ev_usr1, NULL);
+
        signal_set (&sev, SIGTERM, sigterm_handler, (void *)worker);
        signal_add (&sev, NULL);
 
diff --git a/src/greylist.h b/src/greylist.h
deleted file mode 100644 (file)
index e113d2e..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef RSPAMD_GREYLIST_H
-#define RSPAMD_GREYLIST_H
-
-#include "config.h"
-
-#define CHECKSUM_SIZE 16
-/* 5 minutes */
-#define DEFAULT_GREYLIST_TIME 300
-/* 2 days */
-#define DEFAULT_EXPIRE_TIME 60 * 60 * 24 * 2
-
-/**
- * Item in storage
- */
-struct rspamd_grey_item {
-       time_t age;                                     /**< age of checksum                    */
-       guint8 data[CHECKSUM_SIZE];     /**< checksum of triplet                */
-};
-
-/**
- * Protocol command that is used to work with greylist storage
- */
-struct rspamd_grey_command {
-       enum {
-               GREY_CMD_ADD = 0,
-               GREY_CMD_CHECK,
-               GREY_CMD_DEL
-       } cmd;
-       gint version;
-       guint8 data[CHECKSUM_SIZE];
-};
-
-/**
- * Reply packet
- */
-struct rspamd_grey_reply {
-       enum {
-               GREY_OK = 0,
-               GREY_GREYLISTED,
-               GREY_EXPIRED,
-               GREY_NOT_FOUND,
-               GREY_ERR
-       } reply;
-};
-
-typedef void (*greylist_cb_t) (gboolean greylisted, struct worker_task *task, gpointer ud);
-
-#endif
diff --git a/src/greylist_storage.c b/src/greylist_storage.c
deleted file mode 100644 (file)
index 42e9432..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright (c) 2009, Rambler media
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Store greylisting data in memory
- */
-
-#include "config.h"
-#include "util.h"
-#include "main.h"
-#include "protocol.h"
-#include "upstream.h"
-#include "cfg_file.h"
-#include "url.h"
-#include "modules.h"
-#include "message.h"
-#include "greylist.h"
-
-#ifdef WITH_JUDY
-#include <Judy.h>
-#endif
-
-/* Number of insuccessfull bind retries */
-#define MAX_RETRIES 40
-
-struct greylist_ctx {
-#ifdef WITH_JUDY
-       Pvoid_t                  jtree;
-#else
-       GTree                   *tree;
-#endif
-       time_t                   greylist_time;
-       time_t                   expire_time;
-};
-
-#ifndef HAVE_SA_SIGINFO
-static void
-sig_handler (gint signo)
-#else
-static void
-sig_handler (gint signo, siginfo_t *info, void *unused)
-#endif
-{
-       switch (signo) {
-       case SIGINT:
-               /* Ignore SIGINT as we should got SIGTERM after it anyway */
-               return;
-       case SIGTERM:
-#ifdef WITH_PROFILER
-               exit (0);
-#else
-               _exit (1);
-#endif
-               break;
-       }
-}
-
-static void
-sigterm_handler (gint fd, short what, void *arg)
-{
-       struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
-       static struct timeval           tv = {
-               .tv_sec = 0,
-               .tv_usec = 0
-       };
-
-       close (worker->cf->listen_sock);
-       (void)event_loopexit (&tv);
-}
-
-/*
- * Config reload is designed by sending sigusr to active workers and pending shutdown of them
- */
-static void
-sigusr_handler (gint fd, short what, void *arg)
-{
-       struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
-       /* Do not accept new connections, preparing to end worker's process */
-       struct timeval                  tv;
-
-       tv.tv_sec = SOFT_SHUTDOWN_TIME;
-       tv.tv_usec = 0;
-       event_del (&worker->sig_ev);
-       event_del (&worker->bind_ev);
-       close (worker->cf->listen_sock);
-       msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
-       event_loopexit (&tv);
-       return;
-}
-
-struct greylist_session {
-       struct rspamd_worker *worker;
-       gint                            fd;
-       socklen_t salen;
-       struct sockaddr_storage sa;
-       guint8 *pos;
-       struct rspamd_grey_command cmd;
-};
-
-static gint
-grey_cmp (gconstpointer a, gconstpointer b, gpointer unused)
-{
-       return memcmp (a, b, CHECKSUM_SIZE);
-}
-
-static gint
-greylist_process_add_command (struct rspamd_grey_command *cmd, struct greylist_ctx *ctx)
-{
-       struct rspamd_grey_reply          reply;
-       struct rspamd_grey_item          *item, **pitem = NULL;
-       
-       item = g_malloc (sizeof (struct rspamd_grey_item));
-       item->age = time (NULL);
-       memcpy (item->data, cmd->data, CHECKSUM_SIZE);
-#ifdef WITH_JUDY
-
-       JHSI (pitem, ctx->jtree, item->data, CHECKSUM_SIZE);
-       if (pitem == PJERR) {
-               reply.reply = GREY_ERR;
-       }
-       else if (*pitem != 0) {
-               g_free (*pitem);
-               *pitem = item;
-       }
-       else {
-               *pitem = item;
-       }
-#else
-       g_tree_insert (ctx->tree, item->data, item);
-       reply.reply = GREY_OK;
-       (void)pitem;
-#endif
-
-       return reply.reply;
-}
-
-static gint
-greylist_process_delete_command (struct rspamd_grey_command *cmd, struct greylist_ctx *ctx)
-{
-       struct rspamd_grey_reply          reply;
-#ifdef WITH_JUDY
-       gint                            rc;
-       struct rspamd_grey_item         **pitem = NULL;
-
-       JHSG (pitem, ctx->jtree, cmd->data, CHECKSUM_SIZE);
-       if (pitem != NULL) {
-               g_free (*pitem);
-               JHSD (rc, ctx->jtree, cmd->data, CHECKSUM_SIZE);
-               if (rc == 1) {
-                       reply.reply = GREY_OK;
-               }
-               else {
-                       reply.reply = GREY_NOT_FOUND;
-               }
-       }
-       else {
-               reply.reply = GREY_NOT_FOUND;
-       }
-#else
-       if(g_tree_remove (ctx->tree, cmd->data)) {
-               reply.reply = GREY_OK;
-       }
-       else {
-               reply.reply = GREY_NOT_FOUND;
-       }
-#endif
-       return reply.reply;
-}
-
-static gint
-greylist_process_check_command (struct rspamd_grey_command *cmd, struct greylist_ctx *ctx)
-{
-       struct rspamd_grey_reply          reply;
-       struct rspamd_grey_item          *item = NULL, **pitem = NULL;
-       time_t                            now;
-       
-       now = time (NULL);
-#ifdef WITH_JUDY
-       JHSG (pitem, ctx->jtree, cmd->data, CHECKSUM_SIZE);
-       if (pitem != NULL) {
-               item = *pitem;
-       }
-#else
-       item = g_tree_lookup (ctx->tree, cmd->data);
-       (void)pitem;
-#endif
-       if (item) {
-               if (now - item->age > ctx->expire_time) {
-                       /* Remove expired item */
-                       reply.reply = GREY_EXPIRED;
-                       greylist_process_delete_command (cmd, ctx);
-               }
-               else if (now - item->age > ctx->greylist_time) {
-                       reply.reply = GREY_OK;
-               }
-               else {
-                       reply.reply = GREY_GREYLISTED;
-               }
-       }
-       else {
-               reply.reply = GREY_NOT_FOUND;
-       }
-
-       return reply.reply;
-}
-
-#define CMD_PROCESS(x)                                                                                                                                                                                         \
-do {                                                                                                                                                                                                                           \
-       reply.reply = greylist_process_##x##_command (&session->cmd, (struct greylist_ctx *)session->worker->ctx);              \
-       if (sendto (session->fd, &reply, sizeof (reply), 0, (struct sockaddr *)&session->sa, session->salen) == -1) {   \
-               msg_err ("error while writing reply: %s", strerror (errno));                                                                                            \
-       }                                                                                                                                                                                                                               \
-} while(0)
-
-static void
-process_greylist_command (struct greylist_session *session)
-{
-       struct rspamd_grey_reply          reply;
-
-       switch (session->cmd.cmd) {
-       case GREY_CMD_CHECK:
-               CMD_PROCESS (check);
-               break;
-       case GREY_CMD_ADD:
-               CMD_PROCESS (add);
-               break;
-       case GREY_CMD_DEL:
-               CMD_PROCESS (delete);
-               break;
-       }
-}
-
-#undef CMD_PROCESS
-
-/*
- * Accept new connection and construct task
- */
-static void
-accept_greylist_socket (gint fd, short what, void *arg)
-{
-       struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
-       struct greylist_session         session;
-       ssize_t                         r;
-
-       session.worker = worker;
-       session.fd = fd;
-       session.pos = (guint8 *) & session.cmd;
-       session.salen = sizeof (session.sa);
-
-       /* Got some data */
-       if (what == EV_READ) {
-               if ((r = recvfrom (fd, session.pos, sizeof (struct rspamd_grey_command), MSG_WAITALL, (struct sockaddr *)&session.sa, &session.salen)) == -1) {
-                       msg_err ("got error while reading from socket: %d, %s", errno, strerror (errno));
-                       return;
-               }
-               else if (r == sizeof (struct rspamd_grey_command)) {
-                       /* Assume that the whole command was read */
-                       process_greylist_command (&session);
-               }
-               else {
-                       msg_err ("got incomplete data while reading from socket: %d, %s", errno, strerror (errno));
-                       return;
-               }
-       }
-}
-
-static gboolean
-config_greylist_worker (struct rspamd_worker *worker)
-{
-       struct greylist_ctx            *ctx;
-       gchar                           *value;
-
-       ctx = g_malloc0 (sizeof (struct greylist_ctx));
-#ifdef WITH_JUDY
-       ctx->jtree = NULL;
-#else
-       ctx->tree = g_tree_new_full (grey_cmp, NULL, NULL, g_free);
-#endif
-       
-       ctx->greylist_time = DEFAULT_GREYLIST_TIME;
-       ctx->expire_time = DEFAULT_EXPIRE_TIME;
-
-       if ((value = g_hash_table_lookup (worker->cf->params, "greylist_time")) != NULL) {
-               ctx->greylist_time = cfg_parse_time (value, TIME_SECONDS) / 1000;
-       }
-       if ((value = g_hash_table_lookup (worker->cf->params, "expire_time")) != NULL) {
-               ctx->expire_time = cfg_parse_time (value, TIME_SECONDS) / 1000;
-       }
-       worker->ctx = ctx;
-
-       return TRUE;
-}
-
-/*
- * Start worker process
- */
-void
-start_greylist_storage (struct rspamd_worker *worker)
-{
-       struct sigaction                signals;
-       struct event                    sev;
-       gint                            retries = 0;
-
-       worker->srv->pid = getpid ();
-       worker->srv->type = TYPE_GREYLIST;
-
-       event_init ();
-
-       init_signals (&signals, sig_handler);
-       sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
-
-       /* SIGUSR2 handler */
-       signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *)worker);
-       signal_add (&worker->sig_ev, NULL);
-       signal_set (&sev, SIGTERM, sigterm_handler, (void *)worker);
-       signal_add (&sev, NULL);
-
-       /* Accept event */
-       while ((worker->cf->listen_sock = make_udp_socket (&worker->cf->bind_addr, worker->cf->bind_port, TRUE, TRUE)) == -1) {
-               sleep (1);
-               if (++retries > MAX_RETRIES) {
-                       msg_err ("cannot bind to socket, exiting");
-                       exit (EXIT_SUCCESS);
-               }
-       }
-       event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST, accept_greylist_socket, (void *)worker);
-       event_add (&worker->bind_ev, NULL);
-
-       gperf_profiler_init (worker->srv->cfg, "greylist");
-
-       if (!config_greylist_worker (worker)) {
-               msg_err ("cannot configure greylisting worker, exiting");
-               exit (EXIT_SUCCESS);
-       }
-
-       event_loop (0);
-       exit (EXIT_SUCCESS);
-}
index 96dbb2bab419332fc5a7e2d54967dd7ec7ab02a1..81b546d4f069b02303376480591fcf29a705d917 100644 (file)
@@ -47,9 +47,6 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
        switch (signo) {
-       case SIGUSR1:
-               reopen_log (rspamd_main->logger);
-               break;
        case SIGINT:
        case SIGTERM:
                _exit (1);
@@ -61,20 +58,34 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (gint fd, short what, void *arg)
+sigusr2_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
        struct timeval                  tv;
        tv.tv_sec = SOFT_SHUTDOWN_TIME;
        tv.tv_usec = 0;
-       event_del (&worker->sig_ev);
+       event_del (&worker->sig_ev_usr1);
+       event_del (&worker->sig_ev_usr2);
        event_del (&worker->bind_ev);
        msg_info ("lmtp worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
        event_loopexit (&tv);
        return;
 }
 
+/*
+ * Reopen log is designed by sending sigusr1 to active workers and pending shutdown of them
+ */
+static void
+sigusr1_handler (gint fd, short what, void *arg)
+{
+       struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
+
+       reopen_log (worker->srv->logger);
+
+       return;
+}
+
 /*
  * Destructor for recipients list
  */
@@ -284,9 +295,14 @@ start_lmtp_worker (struct rspamd_worker *worker)
        sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
 
        /* SIGUSR2 handler */
-       signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *)worker);
-       event_base_set (worker->ctx, &worker->sig_ev);
-       signal_add (&worker->sig_ev, NULL);
+       signal_set (&worker->sig_ev_usr2, SIGUSR2, sigusr2_handler, (void *) worker);
+       event_base_set (worker->ctx, &worker->sig_ev_usr2);
+       signal_add (&worker->sig_ev_usr2, NULL);
+
+       /* SIGUSR1 handler */
+       signal_set (&worker->sig_ev_usr1, SIGUSR1, sigusr1_handler, (void *) worker);
+       event_base_set (worker->ctx, &worker->sig_ev_usr1);
+       signal_add (&worker->sig_ev_usr1, NULL);
 
        /* Accept event */
        event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST, accept_socket, (void *)worker);
index da6d76e48eb0d8722d7e51088a805c6a43e4a784..f91bf9b34500811785f89697eb3fa6192076cc95 100644 (file)
@@ -374,12 +374,6 @@ fork_worker (struct rspamd_main *rspamd, struct worker_conf *cf)
                                msg_info ("starting fuzzy storage process %P", getpid ());
                                start_fuzzy_storage (cur);
                                break;
-                       case TYPE_GREYLIST:
-                               setproctitle ("greylist storage");
-                               rspamd_pidfile_close (rspamd->pfh);
-                               msg_info ("starting greylist storage process %P", getpid ());
-                               start_greylist_storage (cur);
-                               break;
                        case TYPE_KVSTORAGE:
                                setproctitle ("kv storage");
                                rspamd_pidfile_close (rspamd->pfh);
@@ -573,7 +567,7 @@ spawn_workers (struct rspamd_main *rspamd)
                        cf->listen_sock = listen_sock;
                }
                
-               if (cf->type == TYPE_FUZZY || cf->type == TYPE_GREYLIST) {
+               if (cf->type == TYPE_FUZZY) {
                        if (cf->count > 1) {
                                msg_err ("cannot spawn more than 1 fuzzy storage worker, so spawn one");
                        }
index b7531fa83063a77135c7cebc876277faf913a46c..c111752da1279a20a8404036aa0fa81dac919561 100644 (file)
@@ -50,7 +50,8 @@ struct rspamd_worker {
        gboolean pending;                                                                                       /**< if worker is pending to run                                        */
        struct rspamd_main *srv;                                                                        /**< pointer to server structure                                        */
        enum process_type type;                                                                         /**< process type                                                                       */
-       struct event sig_ev;                                                                            /**< signals event                                                                      */
+       struct event sig_ev_usr1;                                                                       /**< signals event                                                                      */
+       struct event sig_ev_usr2;                                                                       /**< signals event                                                                      */
        struct event bind_ev;                                                                           /**< socket events                                                                      */
        struct worker_conf *cf;                                                                         /**< worker config data                                                         */
        gpointer ctx;                                                                                           /**< worker's specific data                                                     */
@@ -272,8 +273,6 @@ gpointer init_worker (void);
 void start_worker (struct rspamd_worker *worker);
 gpointer init_controller (void);
 void start_controller (struct rspamd_worker *worker);
-gpointer init_greylist (void);
-void start_greylist_storage (struct rspamd_worker *worker);
 
 /**
  * Register custom controller function
index 3c6726d97627a96c043b1814aa08b6405eb6d9e6..0c88df3b02a5bcb7946ec8e32d26eae1c9c22664 100644 (file)
@@ -64,9 +64,6 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
        struct timeval                  tv;
 
        switch (signo) {
-       case SIGUSR1:
-               reopen_log (rspamd_main->logger);
-               break;
        case SIGINT:
        case SIGTERM:
                if (!wanna_die) {
@@ -87,7 +84,7 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (gint fd, short what, void *arg)
+sigusr2_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -95,7 +92,8 @@ sigusr_handler (gint fd, short what, void *arg)
        if (! wanna_die) {
                tv.tv_sec = SOFT_SHUTDOWN_TIME;
                tv.tv_usec = 0;
-               event_del (&worker->sig_ev);
+               event_del (&worker->sig_ev_usr1);
+               event_del (&worker->sig_ev_usr2);
                event_del (&worker->bind_ev);
                msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
                event_loopexit (&tv);
@@ -103,6 +101,19 @@ sigusr_handler (gint fd, short what, void *arg)
        return;
 }
 
+/*
+ * Reopen log is designed by sending sigusr1 to active workers and pending shutdown of them
+ */
+static void
+sigusr1_handler (gint fd, short what, void *arg)
+{
+       struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
+
+       reopen_log (worker->srv->logger);
+
+       return;
+}
+
 static gboolean
 call_stage_filters (struct smtp_session *session, enum rspamd_smtp_stage stage)
 {
@@ -993,9 +1004,14 @@ start_smtp_worker (struct rspamd_worker *worker)
        sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
 
        /* SIGUSR2 handler */
-       signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *)worker);
-       event_base_set (ctx->ev_base, &worker->sig_ev);
-       signal_add (&worker->sig_ev, NULL);
+       signal_set (&worker->sig_ev_usr2, SIGUSR2, sigusr2_handler, (void *) worker);
+       event_base_set (ctx->ev_base, &worker->sig_ev_usr2);
+       signal_add (&worker->sig_ev_usr2, NULL);
+
+       /* SIGUSR1 handler */
+       signal_set (&worker->sig_ev_usr1, SIGUSR1, sigusr1_handler, (void *) worker);
+       event_base_set (ctx->ev_base, &worker->sig_ev_usr1);
+       signal_add (&worker->sig_ev_usr1, NULL);
 
        /* Accept event */
        event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST, accept_socket, (void *)worker);
index b39adfec10aa8f4b11b493b7f0b262e336b1b530..0fe899fe033a295a7f181d99f55e653f2a990ffc 100644 (file)
@@ -1231,8 +1231,6 @@ process_to_str (enum process_type type)
                return "worker";
        case TYPE_FUZZY:
                return "fuzzy";
-       case TYPE_GREYLIST:
-               return "greylist";
        case TYPE_CONTROLLER:
                return "controller";
        case TYPE_LMTP:
@@ -1260,9 +1258,6 @@ str_to_process (const gchar *str)
        else if (g_ascii_strcasecmp (str, "fuzzy") == 0) {
                return TYPE_FUZZY;
        }
-       else if (g_ascii_strcasecmp (str, "greylist") == 0) {
-               return TYPE_GREYLIST;
-       }
        else if (g_ascii_strcasecmp (str, "controller") == 0) {
                return TYPE_CONTROLLER;
        }
index 9d3d824164b97f950cc412b69e410ddd41fb1f2b..bbe49db673d9a01ad15e8158c2da9a285816e576 100644 (file)
@@ -25,7 +25,6 @@ enum process_type {
        TYPE_LMTP,
        TYPE_SMTP,
        TYPE_FUZZY,
-       TYPE_GREYLIST,
        TYPE_KVSTORAGE,
        TYPE_MAX=255
 };
index b3e56c13f219f5775afafeb329197ac139727a61..d1aeea8595010bd25991843014dad7a3eae5b2e7 100644 (file)
@@ -109,9 +109,6 @@ sig_handler (gint signo, siginfo_t * info, void *unused)
        struct timeval                  tv;
 
        switch (signo) {
-       case SIGUSR1:
-               reopen_log (rspamd_main->logger);
-               break;
        case SIGINT:
        case SIGTERM:
                if (!wanna_die) {
@@ -129,10 +126,10 @@ sig_handler (gint signo, siginfo_t * info, void *unused)
 }
 
 /*
- * Config reload is designed by sending sigusr to active workers and pending shutdown of them
+ * Config reload is designed by sending sigusr2 to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (gint fd, short what, void *arg)
+sigusr2_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -141,7 +138,8 @@ sigusr_handler (gint fd, short what, void *arg)
        if (!wanna_die) {
                tv.tv_sec = SOFT_SHUTDOWN_TIME;
                tv.tv_usec = 0;
-               event_del (&worker->sig_ev);
+               event_del (&worker->sig_ev_usr1);
+               event_del (&worker->sig_ev_usr2);
                event_del (&worker->bind_ev);
                msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
                event_loopexit (&tv);
@@ -149,6 +147,19 @@ sigusr_handler (gint fd, short what, void *arg)
        return;
 }
 
+/*
+ * Reopen log is designed by sending sigusr1 to active workers and pending shutdown of them
+ */
+static void
+sigusr1_handler (gint fd, short what, void *arg)
+{
+       struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
+
+       reopen_log (worker->srv->logger);
+
+       return;
+}
+
 #ifndef BUILD_STATIC
 static void
 fin_custom_filters (struct worker_task *task)
@@ -651,9 +662,14 @@ start_worker (struct rspamd_worker *worker)
        sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
 
        /* SIGUSR2 handler */
-       signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *) worker);
-       event_base_set (ctx->ev_base, &worker->sig_ev);
-       signal_add (&worker->sig_ev, NULL);
+       signal_set (&worker->sig_ev_usr2, SIGUSR2, sigusr2_handler, (void *) worker);
+       event_base_set (ctx->ev_base, &worker->sig_ev_usr2);
+       signal_add (&worker->sig_ev_usr2, NULL);
+
+       /* SIGUSR1 handler */
+       signal_set (&worker->sig_ev_usr1, SIGUSR1, sigusr1_handler, (void *) worker);
+       event_base_set (ctx->ev_base, &worker->sig_ev_usr1);
+       signal_add (&worker->sig_ev_usr1, NULL);
 
        /* Accept event */
        event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST,