commit 952850a: [Project] Add heartbeat events
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Sep 10 17:07:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-09-10 18:02:33 +0100
URL: https://github.com/rspamd/rspamd/commit/952850a4741c0e919879da7e16715d59c40eacca (HEAD -> master)
[Project] Add heartbeat events
---
src/libserver/rspamd_control.c | 4 ++++
src/libserver/rspamd_control.h | 8 ++++++++
src/libserver/worker_util.c | 4 ++++
3 files changed, 16 insertions(+)
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index 6c558629c..2ebdbc4d6 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -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;
diff --git a/src/libserver/rspamd_control.h b/src/libserver/rspamd_control.h
index 08d3946c7..87e5e3186 100644
--- a/src/libserver/rspamd_control.h
+++ b/src/libserver/rspamd_control.h
@@ -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;
};
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 47812ded1..56fdd70c1 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -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
More information about the Commits
mailing list