Browse Source

Implicitly initialize regexp library.

tags/0.9.0
Vsevolod Stakhov 9 years ago
parent
commit
281276572c
3 changed files with 22 additions and 18 deletions
  1. 2
    0
      src/libserver/cfg_utils.c
  2. 20
    16
      src/libutil/regexp.c
  3. 0
    2
      src/libutil/util.c

+ 2
- 0
src/libserver/cfg_utils.c View 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);

+ 20
- 16
src/libutil/regexp.c View 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

+ 0
- 2
src/libutil/util.c View 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);

Loading…
Cancel
Save