aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-28 15:25:25 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-28 15:25:25 +0100
commit281276572c49edd9f612daa0e25fb2a3f4450ad8 (patch)
tree97e9ac6d8be327ef25e439346cd1dbed0e10ef63
parentb64cb0ef4685038fff4e902d592fcbe9937c3abf (diff)
downloadrspamd-281276572c49edd9f612daa0e25fb2a3f4450ad8.tar.gz
rspamd-281276572c49edd9f612daa0e25fb2a3f4450ad8.zip
Implicitly initialize regexp library.
-rw-r--r--src/libserver/cfg_utils.c2
-rw-r--r--src/libutil/regexp.c36
-rw-r--r--src/libutil/util.c2
3 files changed, 22 insertions, 18 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 900914535..4e1d6b2c8 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -372,6 +372,8 @@ rspamd_config_post_load (struct rspamd_config *cfg)
cfg->clock_res = 1;
#endif
+ rspamd_regexp_library_init ();
+
if ((def_metric =
g_hash_table_lookup (cfg->metrics, DEFAULT_METRIC)) == NULL) {
def_metric = rspamd_config_new_metric (cfg, NULL);
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c
index 45f15b1e0..c3b542fd9 100644
--- a/src/libutil/regexp.c
+++ b/src/libutil/regexp.c
@@ -87,7 +87,6 @@ static void
rspamd_regexp_dtor (rspamd_regexp_t *re)
{
if (re) {
- msg_info("dtor of %s", re->pattern);
if (re->re) {
pcre_free (re->re);
#ifdef HAVE_PCRE_JIT
@@ -132,6 +131,8 @@ rspamd_regexp_new (const gchar *pattern, const gchar *flags,
gint regexp_flags = 0, rspamd_flags = 0, err_off, study_flags = 0;
gboolean strict_flags = FALSE;
+ rspamd_regexp_library_init ();
+
if (flags == NULL) {
/* We need to parse pattern and detect flags set */
if (*start == '/') {
@@ -524,6 +525,7 @@ rspamd_regexp_cache_query (struct rspamd_regexp_cache* cache,
regexp_id_t id;
if (cache == NULL) {
+ rspamd_regexp_library_init ();
cache = global_re_cache;
}
@@ -544,6 +546,7 @@ rspamd_regexp_cache_create (struct rspamd_regexp_cache *cache,
rspamd_regexp_t *res;
if (cache == NULL) {
+ rspamd_regexp_library_init ();
cache = global_re_cache;
}
@@ -572,6 +575,7 @@ void rspamd_regexp_cache_insert (struct rspamd_regexp_cache* cache,
g_assert (pattern != NULL);
if (cache == NULL) {
+ rspamd_regexp_library_init ();
cache = global_re_cache;
}
@@ -610,29 +614,29 @@ 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;
+ gint jit, rc;
+ const gchar *str;
- rc = pcre_config (PCRE_CONFIG_JIT, &jit);
+ rc = pcre_config (PCRE_CONFIG_JIT, &jit);
- if (rc == 0 && jit == 1) {
- pcre_config (PCRE_CONFIG_JITTARGET, &str);
+ if (rc == 0 && jit == 1) {
+ pcre_config (PCRE_CONFIG_JITTARGET, &str);
- msg_info ("pcre is compiled with JIT for %s", 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"
+ 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
diff --git a/src/libutil/util.c b/src/libutil/util.c
index efb2f7e13..6ecab9bcd 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -2402,8 +2402,6 @@ rspamd_init_libs (void)
rlim.rlim_cur = 100 * 1024 * 1024;
setrlimit (RLIMIT_STACK, &rlim);
- rspamd_regexp_library_init ();
-
event_init ();
#ifdef GMIME_ENABLE_RFC2047_WORKAROUNDS
g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);