From: Vsevolod Stakhov Date: Thu, 3 Dec 2015 09:24:59 +0000 (+0000) Subject: Add cache id support for regexp X-Git-Tag: 1.1.0~427 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a752628025143687ee60f6f1cf94ad483023d1db;p=rspamd.git Add cache id support for regexp --- diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 2ddfa694d..eaea894c0 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -51,6 +51,7 @@ struct rspamd_regexp_s { regexp_id_t id; ref_entry_t ref; gpointer ud; + guint64 cache_id; gint flags; gint ncaptures; gint nbackref; @@ -245,6 +246,7 @@ fin: REF_INIT_RETAIN (res, rspamd_regexp_dtor); res->flags = rspamd_flags; res->pattern = real_pattern; + res->cache_id = RSPAMD_INVALID_ID; if (rspamd_flags & RSPAMD_REGEXP_FLAG_RAW) { res->raw_re = r; @@ -502,6 +504,26 @@ rspamd_regexp_get_ncaptures (rspamd_regexp_t *re) return re->ncaptures; } +guint64 +rspamd_regexp_get_cache_id (rspamd_regexp_t *re) +{ + g_assert (re != NULL); + + return re->cache_id; +} + +guint64 +rspamd_regexp_set_cache_id (rspamd_regexp_t *re, guint64 id) +{ + guint64 old; + + g_assert (re != NULL); + old = re->cache_id; + re->cache_id = id; + + return old; +} + gboolean rspamd_regexp_match (rspamd_regexp_t *re, const gchar *text, gsize len, gboolean raw) diff --git a/src/libutil/regexp.h b/src/libutil/regexp.h index 2c33f780d..cf012668a 100644 --- a/src/libutil/regexp.h +++ b/src/libutil/regexp.h @@ -27,6 +27,8 @@ #include "config.h" +#define RSPAMD_INVALID_ID ((guint64)-1LL) + typedef struct rspamd_regexp_s rspamd_regexp_t; struct rspamd_regexp_cache; struct rspamd_re_capture { @@ -120,6 +122,16 @@ gint rspamd_regexp_get_nbackrefs (rspamd_regexp_t *re); */ gint rspamd_regexp_get_ncaptures (rspamd_regexp_t *re); +/** + * Returns cache id for a regexp + */ +guint64 rspamd_regexp_get_cache_id (rspamd_regexp_t *re); + +/** + * Sets cache id for a regexp + */ +guint64 rspamd_regexp_set_cache_id (rspamd_regexp_t *re, guint64 id); + /** * Create new regexp cache * @return