]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Further fixes to the monitored logic
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 6 Jul 2017 18:36:39 +0000 (19:36 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 6 Jul 2017 18:36:39 +0000 (19:36 +0100)
src/libserver/rspamd_control.c
src/libserver/rspamd_control.h
src/libserver/worker_util.c
src/worker.c

index 5d8008415962b9bb6b10a06d7938df67f5fbd786..90dabc4e131d62229a66e2b4ed0596fc0c15fe90 100644 (file)
@@ -823,6 +823,7 @@ rspamd_srv_handler (gint fd, short what, gpointer ud)
                                                cmd.cmd.monitored_change.tag,
                                                sizeof (wcmd.cmd.monitored_change.tag));
                                wcmd.cmd.monitored_change.alive = cmd.cmd.monitored_change.alive;
+                               wcmd.cmd.monitored_change.sender = cmd.cmd.monitored_change.sender;
                                rspamd_control_broadcast_cmd (srv, &wcmd, rfd,
                                                rspamd_control_hs_io_handler, NULL);
                                break;
index fd1395d96394acf59ead8015a6a722c7066053ad..ba26cd1879d6c4fcc79ae1a239aacddd7e9e9037 100644 (file)
@@ -69,6 +69,7 @@ struct rspamd_control_command {
                struct {
                        gchar tag[32];
                        gboolean alive;
+                       pid_t sender;
                } monitored_change;
                struct {
                        enum rspamd_log_pipe_type type;
@@ -138,6 +139,7 @@ struct rspamd_srv_command {
                struct {
                        gchar tag[32];
                        gboolean alive;
+                       pid_t sender;
                } monitored_change;
                struct {
                        enum rspamd_log_pipe_type type;
index 0c0cc9344225118f4ec2a8685ff0ab5dc2b4ed6c..1a564786fd94447c0499fd306f0340dabab279d4 100644 (file)
@@ -821,6 +821,7 @@ rspamd_worker_monitored_on_change (struct rspamd_monitored_ctx *ctx,
        rspamd_strlcpy (srv_cmd.cmd.monitored_change.tag, tag,
                        sizeof (srv_cmd.cmd.monitored_change.tag));
        srv_cmd.cmd.monitored_change.alive = alive;
+       srv_cmd.cmd.monitored_change.sender = getpid ();
        msg_info_config ("broadcast monitored update for %s: %s",
                        srv_cmd.cmd.monitored_change.tag, alive ? "alive" : "dead");
 
index 5c81f419ae4b5e1a4e2893ece785b72fe1d05920..3889d070953f6bf23713fd4583eb8e6690d1d902 100644 (file)
@@ -498,23 +498,25 @@ rspamd_worker_monitored_handler (struct rspamd_main *rspamd_main,
        struct rspamd_control_reply rep;
        struct rspamd_monitored *m;
        struct rspamd_monitored_ctx *mctx = worker->srv->cfg->monitored_ctx;
-       struct rspamd_config *cfg = worker->srv->cfg;
+       struct rspamd_config *cfg = ud;
 
        memset (&rep, 0, sizeof (rep));
        rep.type = RSPAMD_CONTROL_MONITORED_CHANGE;
-       m = rspamd_monitored_by_tag (mctx, cmd->cmd.monitored_change.tag);
-
-       if (!m) {
-               rspamd_monitored_set_alive (m, cmd->cmd.monitored_change.alive);
-               rep.reply.monitored_change.status = 1;
-               msg_info_config ("updated monitored status for %s: %s",
-                               cmd->cmd.monitored_change.tag,
-                               cmd->cmd.monitored_change.alive ? "alive" : "dead");
-       }
-       else {
-               msg_err ("cannot find monitored by tag: %*s", 32,
-                               cmd->cmd.monitored_change.tag);
-               rep.reply.monitored_change.status = 0;
+
+       if (cmd->cmd.monitored_change.sender != getpid ()) {
+               m = rspamd_monitored_by_tag (mctx, cmd->cmd.monitored_change.tag);
+
+               if (m != NULL) {
+                       rspamd_monitored_set_alive (m, cmd->cmd.monitored_change.alive);
+                       rep.reply.monitored_change.status = 1;
+                       msg_info_config ("updated monitored status for %s: %s",
+                                       cmd->cmd.monitored_change.tag,
+                                       cmd->cmd.monitored_change.alive ? "alive" : "dead");
+               } else {
+                       msg_err ("cannot find monitored by tag: %*s", 32,
+                                       cmd->cmd.monitored_change.tag);
+                       rep.reply.monitored_change.status = 0;
+               }
        }
 
        if (write (fd, &rep, sizeof (rep)) != sizeof (rep)) {