diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-06 15:39:23 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-06 15:39:23 +0100 |
commit | 25b0522484e06ca21957abc2fa7f234fe23e8f7d (patch) | |
tree | 805c0bb4d4e99197b68db6edc37e15732b944cdc | |
parent | 2a5e10cd472278a35dc4a7980a8130bcb9ca6430 (diff) | |
download | rspamd-25b0522484e06ca21957abc2fa7f234fe23e8f7d.tar.gz rspamd-25b0522484e06ca21957abc2fa7f234fe23e8f7d.zip |
Avoid global rspamd_main usage.
-rw-r--r-- | src/controller.c | 1 | ||||
-rw-r--r-- | src/fuzzy_storage.c | 1 | ||||
-rw-r--r-- | src/http_proxy.c | 2 | ||||
-rw-r--r-- | src/libmime/message.c | 2 | ||||
-rw-r--r-- | src/libserver/buffer.c | 2 | ||||
-rw-r--r-- | src/libserver/html.c | 4 | ||||
-rw-r--r-- | src/libserver/symbols_cache.c | 10 | ||||
-rw-r--r-- | src/libutil/logger.c | 4 | ||||
-rw-r--r-- | src/libutil/logger.h | 27 | ||||
-rw-r--r-- | src/lua/lua_dns.c | 2 | ||||
-rw-r--r-- | src/lua/lua_logger.c | 8 | ||||
-rw-r--r-- | src/lua_worker.c | 2 | ||||
-rw-r--r-- | src/main.h | 4 | ||||
-rw-r--r-- | src/smtp_proxy.c | 1 | ||||
-rw-r--r-- | src/worker.c | 1 |
15 files changed, 22 insertions, 49 deletions
diff --git a/src/controller.c b/src/controller.c index f01b5a566..140b0b46b 100644 --- a/src/controller.c +++ b/src/controller.c @@ -67,6 +67,7 @@ #define RSPAMD_PBKDF_ID_V1 1 +extern struct rspamd_main *rspamd_main; gpointer init_controller_worker (struct rspamd_config *cfg); void start_controller_worker (struct rspamd_worker *worker); diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 4b9d118dc..deb08966f 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -49,6 +49,7 @@ #define INVALID_NODE_TIME (guint64) - 1 +extern struct rspamd_main *rspamd_main; /* Init functions */ gpointer init_fuzzy (struct rspamd_config *cfg); void start_fuzzy (struct rspamd_worker *worker); diff --git a/src/http_proxy.c b/src/http_proxy.c index cdd712931..12b237346 100644 --- a/src/http_proxy.c +++ b/src/http_proxy.c @@ -38,7 +38,7 @@ /* Rotate keys each minute by default */ #define DEFAULT_ROTATION_TIME 60.0 - +extern struct rspamd_main *rspamd_main; gpointer init_http_proxy (struct rspamd_config *cfg); void start_http_proxy (struct rspamd_worker *worker); diff --git a/src/libmime/message.c b/src/libmime/message.c index 83345a4d5..404c8f3c7 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -384,7 +384,7 @@ append_raw_header (GHashTable *target, struct raw_header *rh) else { g_hash_table_insert (target, rh->name, rh); } - debug_task ("add raw header %s: %s", rh->name, rh->value); + msg_debug ("add raw header %s: %s", rh->name, rh->value); } /* Convert raw headers to a list of struct raw_header * */ diff --git a/src/libserver/buffer.c b/src/libserver/buffer.c index 2e41dd94c..f67eacbe0 100644 --- a/src/libserver/buffer.c +++ b/src/libserver/buffer.c @@ -31,7 +31,7 @@ #include "utlist.h" #define G_DISPATCHER_ERROR dispatcher_error_quark () -#define debug_ip(...) rspamd_conditional_debug (rspamd_main->logger, \ +#define debug_ip(...) rspamd_conditional_debug (NULL, \ NULL, \ G_STRFUNC, \ __VA_ARGS__) diff --git a/src/libserver/html.c b/src/libserver/html.c index ab4a0c3bb..5b8be2939 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -900,7 +900,7 @@ rspamd_html_process_tag (rspamd_mempool_t *pool, struct html_content *hc, if (tag->flags & FL_CLOSING) { if (!*cur_level) { - debug_task ("bad parent node"); + msg_debug ("bad parent node"); g_node_destroy (nnode); return FALSE; } @@ -908,7 +908,7 @@ rspamd_html_process_tag (rspamd_mempool_t *pool, struct html_content *hc, g_node_append (*cur_level, nnode); if (!rspamd_html_check_balance (nnode, cur_level)) { - debug_task ( + msg_debug ( "mark part as unbalanced as it has not pairable closing tags"); hc->flags |= RSPAMD_HTML_FLAG_UNBALANCED; *balanced = FALSE; diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index e7e20eaea..6e97dbd38 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -962,15 +962,7 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task, rspamd_session_watch_start (task->s, rspamd_symbols_cache_watcher_cb, item); - if (item->symbol != NULL && - G_UNLIKELY (check_debug_symbol (task->cfg, item->symbol))) { - rspamd_log_debug (rspamd_main->logger); - item->func (task, item->user_data); - rspamd_log_nodebug (rspamd_main->logger); - } - else { - item->func (task, item->user_data); - } + item->func (task, item->user_data); t2 = rspamd_get_ticks (); diff = (t2 - t1) * 1000000; diff --git a/src/libutil/logger.c b/src/libutil/logger.c index 5c2670856..1cf348489 100644 --- a/src/libutil/logger.c +++ b/src/libutil/logger.c @@ -777,6 +777,10 @@ rspamd_conditional_debug (rspamd_logger_t *rspamd_log, va_list vp; u_char *end; + if (rspamd_log == NULL) { + rspamd_log = default_logger; + } + if (rspamd_log->cfg->log_level >= G_LOG_LEVEL_DEBUG || rspamd_log->is_debug) { if (rspamd_log->debug_ip && addr != NULL) { diff --git a/src/libutil/logger.h b/src/libutil/logger.h index 6948f8e04..8595f5481 100644 --- a/src/libutil/logger.h +++ b/src/libutil/logger.h @@ -111,28 +111,6 @@ void rspamd_log_nodebug (rspamd_logger_t *logger); /* Typical functions */ /* Logging in postfix style */ -#if defined(RSPAMD_MAIN) -#define msg_err(...) rspamd_common_log_function (rspamd_main->logger, \ - G_LOG_LEVEL_CRITICAL, \ - G_STRFUNC, \ - __VA_ARGS__) -#define msg_warn(...) rspamd_common_log_function (rspamd_main->logger, \ - G_LOG_LEVEL_WARNING, \ - G_STRFUNC, \ - __VA_ARGS__) -#define msg_info(...) rspamd_common_log_function (rspamd_main->logger, \ - G_LOG_LEVEL_INFO, \ - G_STRFUNC, \ - __VA_ARGS__) -#define msg_debug(...) rspamd_conditional_debug (rspamd_main->logger, \ - NULL, \ - G_STRFUNC, \ - __VA_ARGS__) -#define debug_task(...) rspamd_conditional_debug (rspamd_main->logger, \ - task->from_addr, \ - G_STRFUNC, \ - __VA_ARGS__) -#else #define msg_err(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ G_STRFUNC, \ __VA_ARGS__) @@ -145,9 +123,8 @@ void rspamd_log_nodebug (rspamd_logger_t *logger); #define msg_debug(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ G_STRFUNC, \ __VA_ARGS__) -#define debug_task(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ +#define debug_task(...) rspamd_conditional_debug (NULL, \ + task->from_addr, \ G_STRFUNC, \ __VA_ARGS__) #endif - -#endif diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c index a471662e2..df16c75eb 100644 --- a/src/lua/lua_dns.c +++ b/src/lua/lua_dns.c @@ -214,7 +214,7 @@ lua_dns_resolver_init (lua_State *L) cfg = pcfg ? *(pcfg) : NULL; if (base != NULL && cfg != NULL) { - resolver = dns_resolver_init (rspamd_main->logger, base, cfg); + resolver = dns_resolver_init (NULL, base, cfg); if (resolver) { presolver = lua_newuserdata (L, sizeof (gpointer)); rspamd_lua_setclass (L, "rspamd{resolver}", -1); diff --git a/src/lua/lua_logger.c b/src/lua/lua_logger.c index dd5d90cc8..425d277f9 100644 --- a/src/lua/lua_logger.c +++ b/src/lua/lua_logger.c @@ -156,14 +156,14 @@ lua_common_log_line (GLogLevelFlags level, lua_State *L, const gchar *msg) rspamd_snprintf (func_buf, sizeof (func_buf), "%s:%d", p, d.currentline); if (level == G_LOG_LEVEL_DEBUG) { - rspamd_conditional_debug (rspamd_main->logger, + rspamd_conditional_debug (NULL, NULL, func_buf, "%s", msg); } else { - rspamd_common_log_function (rspamd_main->logger, + rspamd_common_log_function (NULL, level, func_buf, "%s", @@ -172,14 +172,14 @@ lua_common_log_line (GLogLevelFlags level, lua_State *L, const gchar *msg) } else { if (level == G_LOG_LEVEL_DEBUG) { - rspamd_conditional_debug (rspamd_main->logger, + rspamd_conditional_debug (NULL, NULL, G_STRFUNC, "%s", msg); } else { - rspamd_common_log_function (rspamd_main->logger, + rspamd_common_log_function (NULL, level, G_STRFUNC, "%s", diff --git a/src/lua_worker.c b/src/lua_worker.c index 681971661..8e6aaa8fc 100644 --- a/src/lua_worker.c +++ b/src/lua_worker.c @@ -42,7 +42,7 @@ /* 60 seconds for worker's IO */ #define DEFAULT_WORKER_IO_TIMEOUT 60000 - +extern struct rspamd_main *rspamd_main; gpointer init_lua_worker (struct rspamd_config *cfg); void start_lua_worker (struct rspamd_worker *worker); diff --git a/src/main.h b/src/main.h index a4faa1d16..8374af56d 100644 --- a/src/main.h +++ b/src/main.h @@ -227,10 +227,6 @@ void register_custom_controller_command (const gchar *name, controller_func_t handler, gboolean privilleged, gboolean require_message); -/** - * If set, reopen log file on next write - */ -extern struct rspamd_main *rspamd_main; #endif diff --git a/src/smtp_proxy.c b/src/smtp_proxy.c index 7bf5b6db0..62d6ff6b7 100644 --- a/src/smtp_proxy.c +++ b/src/smtp_proxy.c @@ -43,6 +43,7 @@ #define SMTP_MAXERRORS 15 +extern struct rspamd_main *rspamd_main; /* Init functions */ gpointer init_smtp_proxy (struct rspamd_config *cfg); diff --git a/src/worker.c b/src/worker.c index da9ab7745..a3ed46e0e 100644 --- a/src/worker.c +++ b/src/worker.c @@ -44,6 +44,7 @@ /* 60 seconds for worker's IO */ #define DEFAULT_WORKER_IO_TIMEOUT 60000 +extern struct rspamd_main *rspamd_main; gpointer init_worker (struct rspamd_config *cfg); void start_worker (struct rspamd_worker *worker); |