aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-05-30 16:21:00 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-05-30 16:21:00 +0100
commita6bae9237be62e785a4c4e207d3f5038fb70ca6e (patch)
tree0cba2e1620536c150a7e4d566fcc49f3428c3e03
parent0b4e01b39ed800d77452b6721122c84f8139daa6 (diff)
downloadrspamd-a6bae9237be62e785a4c4e207d3f5038fb70ca6e.tar.gz
rspamd-a6bae9237be62e785a4c4e207d3f5038fb70ca6e.zip
[Minor] Fix pcre2 jit checks
-rw-r--r--src/libutil/regexp.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c
index 4eb0361ec..8b35ea395 100644
--- a/src/libutil/regexp.c
+++ b/src/libutil/regexp.c
@@ -158,7 +158,7 @@ rspamd_regexp_post_process (rspamd_regexp_t *r)
}
#if defined(WITH_PCRE2)
gsize jsz;
- guint jit_flags = PCRE2_JIT_COMPLETE;
+ guint jit_flags = can_jit ? PCRE2_JIT_COMPLETE : 0;
/* Create match context */
r->mcontext = pcre2_match_context_create (NULL);
@@ -171,22 +171,27 @@ rspamd_regexp_post_process (rspamd_regexp_t *r)
}
#ifdef HAVE_PCRE_JIT
- if (pcre2_jit_compile (r->re, jit_flags) < 0) {
- msg_err ("jit compilation of %s is not supported: %d", r->pattern, jit_flags);
- r->flags |= RSPAMD_REGEXP_FLAG_DISABLE_JIT;
- }
- else {
- if (!(pcre2_pattern_info (r->re, PCRE2_INFO_JITSIZE, &jsz) >= 0 && jsz > 0)) {
- msg_err ("jit compilation of %s is not supported", r->pattern);
+ if (can_jit) {
+ if (pcre2_jit_compile (r->re, jit_flags) < 0) {
+ msg_err ("jit compilation of %s is not supported: %d", r->pattern, jit_flags);
r->flags |= RSPAMD_REGEXP_FLAG_DISABLE_JIT;
}
+ else {
+ if (!(pcre2_pattern_info (r->re, PCRE2_INFO_JITSIZE, &jsz) >= 0 && jsz > 0)) {
+ msg_err ("jit compilation of %s is not supported", r->pattern);
+ r->flags |= RSPAMD_REGEXP_FLAG_DISABLE_JIT;
+ }
+ }
+ }
+ else {
+ r->flags |= RSPAMD_REGEXP_FLAG_DISABLE_JIT;
}
if (!(r->flags & RSPAMD_REGEXP_FLAG_DISABLE_JIT)) {
pcre2_jit_stack_assign (r->mcontext, NULL, global_re_cache->jstack);
}
- if (r->re != r->raw_re) {
+ if (r->re != r->raw_re && !(r->flags & RSPAMD_REGEXP_FLAG_DISABLE_JIT)) {
if (pcre2_jit_compile (r->raw_re, jit_flags) < 0) {
msg_debug ("jit compilation of %s is not supported", r->pattern);
r->flags |= RSPAMD_REGEXP_FLAG_DISABLE_JIT;
@@ -1107,11 +1112,13 @@ rspamd_regexp_library_init (struct rspamd_config *cfg)
} else {
msg_info ("pcre is compiled without JIT support, so many optimizations"
" are impossible");
+ can_jit = FALSE;
}
}
#else
msg_info ("pcre is too old and has no JIT support, so many optimizations"
" are impossible");
+ can_jit = FALSE;
#endif
}
}