aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-06 15:30:10 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-06 15:30:10 +0100
commit2a5e10cd472278a35dc4a7980a8130bcb9ca6430 (patch)
treefb960ce0e37eaca6788f27f620547231fc0a5a22 /src/libserver
parent2c33c006c2b7f8cea8bbbb157c39268705211e8a (diff)
downloadrspamd-2a5e10cd472278a35dc4a7980a8130bcb9ca6430.tar.gz
rspamd-2a5e10cd472278a35dc4a7980a8130bcb9ca6430.zip
Hide workers and modules definitions.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_file.h7
-rw-r--r--src/libserver/cfg_rcl.c3
-rw-r--r--src/libserver/cfg_utils.c2
-rw-r--r--src/libserver/worker_util.c7
-rw-r--r--src/libserver/worker_util.h17
5 files changed, 22 insertions, 14 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 37d65bd74..7ec39fa88 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -20,6 +20,8 @@
struct expression;
struct tokenizer;
struct rspamd_stat_classifier;
+struct module_s;
+struct worker_s;
enum { VAL_UNDEF=0, VAL_TRUE, VAL_FALSE };
@@ -145,7 +147,7 @@ struct rspamd_worker_bind_conf {
* Config params for rspamd worker
*/
struct rspamd_worker_conf {
- worker_t *worker; /**< pointer to worker type */
+ struct worker_s *worker; /**< pointer to worker type */
GQuark type; /**< type of worker */
struct rspamd_worker_bind_conf *bind_conf; /**< bind configuration */
guint16 count; /**< number of workers */
@@ -265,7 +267,8 @@ struct rspamd_config {
guint32 min_word_len; /**< minimum length of the word to be considered */
GList *classify_headers; /**< list of headers using for statistics */
- module_t *compiled_modules; /**< list of compiled C modules */
+ struct module_s **compiled_modules; /**< list of compiled C modules */
+ struct worker_s **compiled_workers; /**< list of compiled C modules */
};
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 46dd1b60f..ef2644dd9 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -29,6 +29,7 @@
#include "lua/lua_common.h"
#include "expression.h"
#include "composites.h"
+#include "libserver/worker_util.h"
struct rspamd_rcl_default_handler_data {
struct rspamd_rcl_struct_parser pd;
@@ -576,7 +577,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
qtype = g_quark_try_string (worker_type);
if (qtype != 0) {
wrk = rspamd_config_new_worker (cfg, NULL);
- wrk->worker = rspamd_get_worker_by_type (qtype);
+ wrk->worker = rspamd_get_worker_by_type (cfg, qtype);
if (wrk->worker == NULL) {
g_set_error (err,
CFG_RCL_ERROR,
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index c877be37d..96beb0621 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -873,7 +873,7 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
/* Init all compiled modules */
if (!reconfig) {
- for (pmod = cfg->compiled_modules; *pmod != NULL; pmod ++) {
+ for (pmod = cfg->compiled_modules; pmod != NULL && *pmod != NULL; pmod ++) {
mod = *pmod;
mod_ctx = g_slice_alloc0 (sizeof (struct module_ctx));
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 94ad5bd6c..4d62da514 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -25,6 +25,7 @@
#include "main.h"
#include "message.h"
#include "lua/lua_common.h"
+#include "worker_util.h"
/**
* Return worker's control structure by its type
@@ -32,12 +33,12 @@
* @return worker's control structure or NULL
*/
worker_t *
-rspamd_get_worker_by_type (GQuark type)
+rspamd_get_worker_by_type (struct rspamd_config *cfg, GQuark type)
{
worker_t **cur;
- cur = &workers[0];
- while (*cur) {
+ cur = cfg->compiled_workers;
+ while (cur && *cur) {
if (g_quark_from_string ((*cur)->name) == type) {
return *cur;
}
diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h
index f8cbccfa5..04109b9b0 100644
--- a/src/libserver/worker_util.h
+++ b/src/libserver/worker_util.h
@@ -26,13 +26,7 @@
#include "config.h"
#include "util.h"
#include "http.h"
-
-/**
- * Return worker's control structure by its type
- * @param type
- * @return worker's control structure or NULL
- */
-worker_t * rspamd_get_worker_by_type (GQuark type);
+#include "main.h"
#ifndef HAVE_SA_SIGINFO
typedef void (*rspamd_sig_handler_t) (gint);
@@ -98,4 +92,13 @@ void rspamd_controller_send_string (struct rspamd_http_connection_entry *entry,
void rspamd_controller_send_ucl (struct rspamd_http_connection_entry *entry,
ucl_object_t *obj);
+/**
+ * Return worker's control structure by its type
+ * @param type
+ * @return worker's control structure or NULL
+ */
+worker_t * rspamd_get_worker_by_type (struct rspamd_config *cfg, GQuark type);
+
+void rspamd_worker_stop_accept (struct rspamd_worker *worker);
+
#endif /* WORKER_UTIL_H_ */