]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Project] Add heartbeat events
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 10 Sep 2019 17:02:33 +0000 (18:02 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 10 Sep 2019 17:02:33 +0000 (18:02 +0100)
src/libserver/rspamd_control.c
src/libserver/rspamd_control.h
src/libserver/worker_util.c

index 6c558629c3bbdcd744ddee706bfcd0df29edc94d..2ebdbc4d6246e91fcc5d1c55f3ea8a2f39c5df4b 100644 (file)
@@ -912,6 +912,10 @@ rspamd_srv_handler (EV_P_ ev_io *w, int revents)
                                rdata->rep.reply.on_fork.status = 0;
                                rspamd_control_handle_on_fork (&cmd, srv);
                                break;
+                       case RSPAMD_SRV_HEARTBEAT:
+                               worker->hb.last_event = ev_time ();
+                               rdata->rep.reply.heartbeat.status = 0;
+                               break;
                        default:
                                msg_err ("unknown command type: %d", cmd.type);
                                break;
index 08d3946c7741bc2379d428cd635d1614178ddc22..87e5e318691463b6ddc288b5ede4cd2321d718b2 100644 (file)
@@ -46,6 +46,7 @@ enum rspamd_srv_type {
        RSPAMD_SRV_MONITORED_CHANGE,
        RSPAMD_SRV_LOG_PIPE,
        RSPAMD_SRV_ON_FORK,
+       RSPAMD_SRV_HEARTBEAT,
 };
 
 enum rspamd_log_pipe_type {
@@ -157,6 +158,10 @@ struct rspamd_srv_command {
                                child_dead,
                        } state;
                } on_fork;
+               struct {
+                       guint status;
+                       /* TODO: add more fields */
+               } heartbeat;
        } cmd;
 };
 
@@ -179,6 +184,9 @@ struct rspamd_srv_reply {
                struct {
                        gint status;
                } on_fork;
+               struct {
+                       gint status;
+               } heartbeat;
        } reply;
 };
 
index 47812ded1f63e38ed5e1afca777812213d8360bc..56fdd70c1861041f5860b6b6908162688f8841e9 100644 (file)
@@ -692,7 +692,11 @@ static void
 rspamd_worker_heartbeat_cb (EV_P_ ev_timer *w, int revents)
 {
        struct rspamd_worker *wrk = (struct rspamd_worker *)w->data;
+       struct rspamd_srv_command cmd;
 
+       memset (&cmd, 0, sizeof (cmd));
+       cmd.type = RSPAMD_SRV_HEARTBEAT;
+       rspamd_srv_send_command (wrk, EV_A, &cmd, -1, NULL, NULL);
 }
 
 static void