aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/fuzzy_storage.c7
-rw-r--r--src/libserver/rspamd_control.c28
2 files changed, 33 insertions, 2 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 50aff7141..9bb542df8 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -41,6 +41,7 @@
#include "ref.h"
#include "xxhash.h"
#include "libutil/hash.h"
+#include "unix-std.h"
/* This number is used as expire time in seconds for cache items (2 days) */
#define DEFAULT_EXPIRE 172800L
@@ -852,6 +853,10 @@ rspamd_fuzzy_storage_stat (struct rspamd_main *rspamd_main,
ucl_object_emit_full (obj, UCL_EMIT_JSON_COMPACT, emit_subr);
ucl_object_emit_funcs_free (emit_subr);
ucl_object_unref (obj);
+ /* Rewind output file */
+ close (outfd);
+ outfd = open (tmppath, O_RDONLY);
+ unlink (tmppath);
}
/* Now we can send outfd and status message */
@@ -927,6 +932,7 @@ fuzzy_parse_keypair (rspamd_mempool_t *pool,
keystat->last_ips = rspamd_lru_hash_new_full (0, 1024,
(GDestroyNotify)rspamd_inet_address_destroy, fuzzy_key_stat_dtor,
rspamd_inet_address_hash, rspamd_inet_address_equal);
+ g_hash_table_insert (ctx->keys_stats, kp->pk, keystat);
msg_info_pool ("loaded keypair %8xs", kp->pk);
}
else if (ucl_object_type (obj) == UCL_ARRAY) {
@@ -1183,6 +1189,7 @@ start_fuzzy (struct rspamd_worker *worker)
}
g_hash_table_unref (ctx->keys);
+ g_hash_table_unref (ctx->keys_stats);
exit (EXIT_SUCCESS);
}
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index 90f1c27b6..cd6b7829b 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -185,6 +185,12 @@ rspamd_control_write_reply (struct rspamd_control_session *session)
workers = ucl_object_typed_new (UCL_OBJECT);
DL_FOREACH (session->replies, elt) {
+ /* Skip incompatible worker for fuzzy_stat */
+ if (session->cmd.type == RSPAMD_CONTROL_FUZZY_STAT &&
+ elt->wrk->type != g_quark_from_static_string ("fuzzy")) {
+ continue;
+ }
+
rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "%P", elt->wrk->pid);
cur = ucl_object_typed_new (UCL_OBJECT);
@@ -226,8 +232,12 @@ rspamd_control_write_reply (struct rspamd_control_session *session)
if (elt->attached_fd != -1) {
/* We have some data to parse */
parser = ucl_parser_new (0);
- ucl_object_insert_key (cur, ucl_object_fromint (
- elt->reply.reply.fuzzy_stat.status), "status", 0, false);
+ ucl_object_insert_key (cur,
+ ucl_object_fromint (
+ elt->reply.reply.fuzzy_stat.status),
+ "status",
+ 0,
+ false);
if (ucl_parser_add_fd (parser, elt->attached_fd)) {
ucl_object_insert_key (cur, ucl_parser_get_object (parser),
@@ -235,12 +245,26 @@ rspamd_control_write_reply (struct rspamd_control_session *session)
ucl_parser_free (parser);
}
else {
+
ucl_object_insert_key (cur, ucl_object_fromstring (
ucl_parser_get_error (parser)), "error", 0, false);
ucl_parser_free (parser);
}
}
+ else {
+ ucl_object_insert_key (cur,
+ ucl_object_fromstring ("missing file"),
+ "error",
+ 0,
+ false);
+ ucl_object_insert_key (cur,
+ ucl_object_fromint (
+ elt->reply.reply.fuzzy_stat.status),
+ "status",
+ 0,
+ false);
+ }
break;
default:
break;