aboutsummaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-10 13:54:35 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-10 13:54:35 +0100
commitdc7afbd65040bb286b369adb0e8510209accf4d2 (patch)
treed320cae889496855c4ae91508873f0238997dbd4 /src/fuzzy_storage.c
parent0d218b76d12633a36832794bb8eb1bd840d0cc1a (diff)
downloadrspamd-dc7afbd65040bb286b369adb0e8510209accf4d2.tar.gz
rspamd-dc7afbd65040bb286b369adb0e8510209accf4d2.zip
[CritFix] Distinguish socketpairs between different fuzzy workers
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r--src/fuzzy_storage.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 99e79e098..256241a95 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -2324,8 +2324,22 @@ start_fuzzy (struct rspamd_worker *worker)
srv_cmd.cmd.spair.af = SOCK_DGRAM;
srv_cmd.cmd.spair.pair_num = worker->index;
memset (srv_cmd.cmd.spair.pair_id, 0, sizeof (srv_cmd.cmd.spair.pair_id));
+ /* 6 bytes of id (including \0) and bind_conf id */
+ G_STATIC_ASSERT (sizeof (srv_cmd.cmd.spair.pair_id) >=
+ sizeof ("fuzzy") + sizeof (guint64));
+
memcpy (srv_cmd.cmd.spair.pair_id, "fuzzy", sizeof ("fuzzy"));
+ /* Distinguish workers from each others... */
+ if (worker->cf->bind_conf && worker->cf->bind_conf->bind_line) {
+ guint64 bind_hash = rspamd_cryptobox_fast_hash (worker->cf->bind_conf->bind_line,
+ strlen (worker->cf->bind_conf->bind_line), 0xdeadbabe);
+
+ /* 8 more bytes */
+ memcpy (srv_cmd.cmd.spair.pair_id + sizeof ("fuzzy"), &bind_hash,
+ sizeof (bind_hash));
+ }
+
rspamd_srv_send_command (worker, ctx->event_loop, &srv_cmd, -1,
fuzzy_peer_rep, ctx);