#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
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 */
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) {
}
g_hash_table_unref (ctx->keys);
+ g_hash_table_unref (ctx->keys_stats);
exit (EXIT_SUCCESS);
}
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);
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),
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;