#include "unix-std.h"
#endif
+#define msg_err_re_cache(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
+ "re_cache", cache->hash, \
+ G_STRFUNC, \
+ __VA_ARGS__)
+#define msg_warn_re_cache(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \
+ "re_cache", cache->hash, \
+ G_STRFUNC, \
+ __VA_ARGS__)
+#define msg_info_re_cache(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \
+ "re_cache", cache->hash, \
+ G_STRFUNC, \
+ __VA_ARGS__)
+#define msg_debug_re_cache(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \
+ "re_cache", cache->hash, \
+ G_STRFUNC, \
+ __VA_ARGS__)
+
struct rspamd_re_class {
guint64 id;
enum rspamd_re_type type;
ref_entry_t ref;
guint nre;
guint max_re_data;
+ gchar hash[rspamd_cryptobox_HASHBYTES * 2 + 1];
#ifdef WITH_HYPERSCAN
hs_platform_info_t plt;
#endif
GHashTableIter it, cit;
gpointer k, v;
struct rspamd_re_class *re_class;
- rspamd_cryptobox_hash_state_t st;
+ rspamd_cryptobox_hash_state_t st, st_global;
rspamd_regexp_t *re;
guchar hash_out[rspamd_cryptobox_HASHBYTES];
g_assert (cache != NULL);
g_hash_table_iter_init (&it, cache->re_classes);
+ rspamd_cryptobox_hash_init (&st_global, NULL, 0);
while (g_hash_table_iter_next (&it, &k, &v)) {
re_class = v;
rspamd_cryptobox_hash_init (&st, NULL, 0);
rspamd_cryptobox_hash_update (&st, (gpointer)&re_class->id,
sizeof (re_class->id));
+ rspamd_cryptobox_hash_update (&st_global, (gpointer) &re_class->id,
+ sizeof (re_class->id));
g_hash_table_iter_init (&cit, re_class->re);
while (g_hash_table_iter_next (&cit, &k, &v)) {
re = v;
rspamd_cryptobox_hash_update (&st, rspamd_regexp_get_id (re),
rspamd_cryptobox_HASHBYTES);
+ rspamd_cryptobox_hash_update (&st_global, rspamd_regexp_get_id (re),
+ rspamd_cryptobox_HASHBYTES);
}
rspamd_cryptobox_hash_final (&st, hash_out);
(gint)rspamd_cryptobox_HASHBYTES, hash_out);
}
+ rspamd_cryptobox_hash_final (&st, hash_out);
+ rspamd_snprintf (cache->hash, sizeof (cache->hash), "%*xs",
+ (gint) rspamd_cryptobox_HASHBYTES, hash_out);
+
#ifdef WITH_HYPERSCAN
const gchar *platform = "generic";
rspamd_fstring_t *features = rspamd_fstring_new ();
hs_set_allocator (g_malloc, g_free);
- msg_info ("loaded hyperscan engine witch cpu tune '%s' and features '%V'",
+ msg_info_re_cache ("loaded hyperscan engine witch cpu tune '%s' and features '%V'",
platform, features);
rspamd_fstring_free (features);
&cache->plt,
&test_db,
&hs_errors) != HS_SUCCESS) {
- msg_info ("cannot compile %s to hyperscan, try prefilter match",
+ msg_info_re_cache ("cannot compile %s to hyperscan, try prefilter match",
rspamd_regexp_get_pattern (re));
hs_free_compile_error (hs_errors);
&cache->plt,
&test_db,
&hs_errors) != HS_SUCCESS) {
- msg_info (
+ msg_info_re_cache (
"cannot compile %s to hyperscan even using prefilter",
rspamd_regexp_get_pattern (re));
hs_free_compile_error (hs_errors);
iov[2].iov_len = serialized_len;
if (writev (fd, iov, 3) !=
- (gssize)serialized_len + sizeof (n) + sizeof (*hs_ids) * n) {
+ (gssize)(serialized_len + sizeof (n) + sizeof (*hs_ids) * n)) {
g_set_error (err,
rspamd_re_cache_quark (),
errno,