summaryrefslogtreecommitdiffstats
path: root/src/libserver/worker_util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-07-06 19:08:15 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-07-06 19:08:15 +0100
commit52b4b8db0b126f7004d6aff79cbea3b06f94c927 (patch)
treeaeed0cb84fc81a93133f0f817675a86b6cd62b53 /src/libserver/worker_util.c
parentfd20fa9f63e72df66b2b702cde982f729f704480 (diff)
downloadrspamd-52b4b8db0b126f7004d6aff79cbea3b06f94c927.tar.gz
rspamd-52b4b8db0b126f7004d6aff79cbea3b06f94c927.zip
[Rework] Send health checks from a single worker
Diffstat (limited to 'src/libserver/worker_util.c')
-rw-r--r--src/libserver/worker_util.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index fcd9a8be9..0c0cc9344 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -802,4 +802,37 @@ rspamd_worker_session_cache_remove (void *cache, void *ptr)
struct rspamd_worker_session_cache *c = cache;
g_hash_table_remove (c->cache, ptr);
+}
+
+static void
+rspamd_worker_monitored_on_change (struct rspamd_monitored_ctx *ctx,
+ struct rspamd_monitored *m, gboolean alive,
+ void *ud)
+{
+ struct rspamd_worker *worker = ud;
+ struct rspamd_config *cfg = worker->srv->cfg;
+ struct event_base *ev_base;
+ guchar tag[RSPAMD_MONITORED_TAG_LEN];
+ static struct rspamd_srv_command srv_cmd;
+
+ rspamd_monitored_get_tag (m, tag);
+ ev_base = rspamd_monitored_ctx_get_ev_base (ctx);
+ srv_cmd.type = RSPAMD_SRV_MONITORED_CHANGE;
+ rspamd_strlcpy (srv_cmd.cmd.monitored_change.tag, tag,
+ sizeof (srv_cmd.cmd.monitored_change.tag));
+ srv_cmd.cmd.monitored_change.alive = alive;
+ msg_info_config ("broadcast monitored update for %s: %s",
+ srv_cmd.cmd.monitored_change.tag, alive ? "alive" : "dead");
+
+ rspamd_srv_send_command (worker, ev_base, &srv_cmd, -1, NULL, NULL);
+}
+
+void
+rspamd_worker_init_monitored (struct rspamd_worker *worker,
+ struct event_base *ev_base,
+ struct rspamd_dns_resolver *resolver)
+{
+ rspamd_monitored_ctx_config (worker->srv->cfg->monitored_ctx,
+ worker->srv->cfg, ev_base, resolver->r,
+ rspamd_worker_monitored_on_change, worker);
} \ No newline at end of file