|
|
|
@ -998,7 +998,7 @@ rspamd_regexp_cache_create (struct rspamd_regexp_cache *cache, |
|
|
|
res = rspamd_regexp_new (pattern, flags, err); |
|
|
|
|
|
|
|
if (res) { |
|
|
|
REF_RETAIN (res); |
|
|
|
/* REF_RETAIN (res); */ |
|
|
|
g_hash_table_insert (cache->tbl, res->id, res); |
|
|
|
} |
|
|
|
|
|
|
|
@ -1058,6 +1058,24 @@ rspamd_regexp_cache_destroy (struct rspamd_regexp_cache *cache) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RSPAMD_CONSTRUCTOR (rspamd_re_static_pool_ctor) |
|
|
|
{ |
|
|
|
global_re_cache = rspamd_regexp_cache_new (); |
|
|
|
#ifdef WITH_PCRE2 |
|
|
|
pcre2_ctx = pcre2_compile_context_create (NULL); |
|
|
|
pcre2_set_newline (pcre2_ctx, PCRE_FLAG(NEWLINE_ANY)); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
RSPAMD_DESTRUCTOR (rspamd_re_static_pool_dtor) |
|
|
|
{ |
|
|
|
rspamd_regexp_cache_destroy (global_re_cache); |
|
|
|
#ifdef WITH_PCRE2 |
|
|
|
pcre2_compile_context_free (pcre2_ctx); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
rspamd_regexp_library_init (struct rspamd_config *cfg) |
|
|
|
{ |
|
|
|
@ -1066,19 +1084,16 @@ rspamd_regexp_library_init (struct rspamd_config *cfg) |
|
|
|
can_jit = FALSE; |
|
|
|
check_jit = FALSE; |
|
|
|
} |
|
|
|
else if (!can_jit) { |
|
|
|
check_jit = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (global_re_cache == NULL) { |
|
|
|
global_re_cache = rspamd_regexp_cache_new (); |
|
|
|
if (check_jit) { |
|
|
|
#ifdef HAVE_PCRE_JIT |
|
|
|
gint jit, rc; |
|
|
|
gchar *str; |
|
|
|
|
|
|
|
if (check_jit) { |
|
|
|
#ifdef WITH_PCRE2 |
|
|
|
pcre2_ctx = pcre2_compile_context_create (NULL); |
|
|
|
pcre2_set_newline (pcre2_ctx, PCRE_FLAG(NEWLINE_ANY)); |
|
|
|
#endif |
|
|
|
#ifndef WITH_PCRE2 |
|
|
|
rc = pcre_config (PCRE_CONFIG_JIT, &jit); |
|
|
|
#else |
|
|
|
@ -1118,23 +1133,12 @@ rspamd_regexp_library_init (struct rspamd_config *cfg) |
|
|
|
" are impossible"); |
|
|
|
can_jit = FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
msg_info ("pcre is too old and has no JIT support, so many optimizations" |
|
|
|
" are impossible"); |
|
|
|
" are impossible"); |
|
|
|
can_jit = FALSE; |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
rspamd_regexp_library_finalize (void) |
|
|
|
{ |
|
|
|
if (global_re_cache != NULL) { |
|
|
|
rspamd_regexp_cache_destroy (global_re_cache); |
|
|
|
#ifdef WITH_PCRE2 |
|
|
|
pcre2_compile_context_free (pcre2_ctx); |
|
|
|
#endif |
|
|
|
check_jit = FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|