]> source.dussan.org Git - rspamd.git/commitdiff
Implicitly initialize regexp library.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 28 Apr 2015 14:25:25 +0000 (15:25 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 28 Apr 2015 14:25:25 +0000 (15:25 +0100)
src/libserver/cfg_utils.c
src/libutil/regexp.c
src/libutil/util.c

index 9009145352cdad7de56c300200fb051887ac2f4c..4e1d6b2c8a8b6c15a8397eac4285a6cb3d2eecea 100644 (file)
@@ -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);
index 45f15b1e01db3dcea2ea42e8359e19400d56255f..c3b542fd9b148634d8c0007dffdd81ed033777ec 100644 (file)
@@ -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
index efb2f7e1353b9316b94d15f0f2ef6c7aea9bf575..6ecab9bcd9a2724580cd14a25587d5a46823e4da 100644 (file)
@@ -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);