From 0852facdb91ae18d0fe255e575d8fa0fb7c4864c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 17 Apr 2015 14:19:32 +0100 Subject: Move libraries initialization to a specific routine. --- src/libutil/util.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/libutil/util.h | 5 +++++ 2 files changed, 46 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/util.c b/src/libutil/util.c index a001e5ed2..05bf4a31e 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -2368,3 +2368,44 @@ rspamd_array_free_hard (gpointer p) g_array_free (ar, TRUE); } + + +void +rspamd_init_libs (void) +{ + struct rlimit rlim; + + ottery_init (NULL); + + rspamd_cryptobox_init (); +#ifdef HAVE_SETLOCALE + /* Set locale setting to C locale to avoid problems in future */ + setlocale (LC_ALL, "C"); + setlocale (LC_CTYPE, "C"); + setlocale (LC_MESSAGES, "C"); + setlocale (LC_TIME, "C"); +#endif + +#ifdef HAVE_OPENSSL + ERR_load_crypto_strings (); + + OpenSSL_add_all_algorithms (); + OpenSSL_add_all_digests (); + OpenSSL_add_all_ciphers (); +#endif + g_random_set_seed (ottery_rand_uint32 ()); + + /* Set stack size for pcre */ + getrlimit (RLIMIT_STACK, &rlim); + 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); +#else + g_mime_init (0); +#endif +} diff --git a/src/libutil/util.h b/src/libutil/util.h index 2f58c51b6..b3d7f42e0 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -455,4 +455,9 @@ void rspamd_ptr_array_free_hard (gpointer p); */ void rspamd_array_free_hard (gpointer p); +/** + * Initialize rspamd libraries + */ +void rspamd_init_libs (void); + #endif -- cgit v1.2.3