summaryrefslogtreecommitdiffstats
path: root/src/libutil/regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-27 17:40:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-27 17:40:57 +0100
commit1bb534f67d6e15e4cce60d9da838bc604e8eb408 (patch)
treeeb4854cb2fe250c8c54093f1702a1c2ad175900f /src/libutil/regexp.c
parentfe57024591e73d052af72d60ca80971ab07566f0 (diff)
downloadrspamd-1bb534f67d6e15e4cce60d9da838bc604e8eb408.tar.gz
rspamd-1bb534f67d6e15e4cce60d9da838bc604e8eb408.zip
Be more clever about logging of JIT support.
Diffstat (limited to 'src/libutil/regexp.c')
-rw-r--r--src/libutil/regexp.c71
1 files changed, 49 insertions, 22 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c
index 120175016..45f15b1e0 100644
--- a/src/libutil/regexp.c
+++ b/src/libutil/regexp.c
@@ -59,6 +59,7 @@ struct rspamd_regexp_cache {
};
static struct rspamd_regexp_cache *global_re_cache = NULL;
+static gboolean can_jit = FALSE;
static GQuark
rspamd_regexp_quark (void)
@@ -264,17 +265,19 @@ fin:
#ifdef HAVE_PCRE_JIT
gint jit, n;
- jit = 0;
- n = pcre_fullinfo (res->re, res->extra,
- PCRE_INFO_JIT, &jit);
-
- if (n != 0 || jit != 1) {
- msg_info ("jit compilation of %s is not supported", pattern);
- res->jstack = NULL;
- }
- else {
- res->jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024);
- pcre_assign_jit_stack (res->extra, NULL, res->jstack);
+ if (can_jit) {
+ jit = 0;
+ n = pcre_fullinfo (res->re, res->extra,
+ PCRE_INFO_JIT, &jit);
+
+ if (n != 0 || jit != 1) {
+ msg_info ("jit compilation of %s is not supported", pattern);
+ res->jstack = NULL;
+ }
+ else {
+ res->jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024);
+ pcre_assign_jit_stack (res->extra, NULL, res->jstack);
+ }
}
#endif
}
@@ -289,17 +292,19 @@ fin:
#ifdef HAVE_PCRE_JIT
gint jit, n;
- jit = 0;
- n = pcre_fullinfo (res->re, res->extra,
- PCRE_INFO_JIT, &jit);
-
- if (n != 0 || jit != 1) {
- msg_info ("jit compilation of %s is not supported", pattern);
- res->jstack = NULL;
- }
- else {
- res->jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024);
- pcre_assign_jit_stack (res->extra, NULL, res->jstack);
+ if (can_jit) {
+ jit = 0;
+ n = pcre_fullinfo (res->re, res->extra,
+ PCRE_INFO_JIT, &jit);
+
+ if (n != 0 || jit != 1) {
+ msg_info ("jit compilation of %s is not supported", pattern);
+ res->jstack = NULL;
+ }
+ else {
+ res->jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024);
+ pcre_assign_jit_stack (res->extra, NULL, res->jstack);
+ }
}
#endif
}
@@ -606,6 +611,28 @@ rspamd_regexp_library_init (void)
if (global_re_cache == NULL) {
global_re_cache = rspamd_regexp_cache_new ();
}
+#ifdef HAVE_PCRE_JIT
+ gint jit, rc;
+ const gchar *str;
+
+
+ rc = pcre_config (PCRE_CONFIG_JIT, &jit);
+
+ if (rc == 0 && jit == 1) {
+ pcre_config (PCRE_CONFIG_JITTARGET, &str);
+
+ msg_info ("pcre is compiled with JIT for %s", str);
+
+ can_jit = TRUE;
+ }
+ else {
+ msg_info ("pcre is compiled without JIT support, so many optimisations"
+ " are impossible");
+ }
+#else
+ msg_info ("pcre is too old and has no JIT support, so many optimisations"
+ " are impossible");
+#endif
}
void