aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-09-14 23:36:38 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-09-14 23:36:38 +0100
commit2fa167601ae2194bbdf4484fe2ad8e3eee813163 (patch)
tree0b275bb60db9a7afbe72f586d8daa4e8e6c8d821 /src
parent5edc7624cee30676fc91be2759ca5a9bc31e54ee (diff)
downloadrspamd-2fa167601ae2194bbdf4484fe2ad8e3eee813163.tar.gz
rspamd-2fa167601ae2194bbdf4484fe2ad8e3eee813163.zip
Add workers handler function for rcl.
Diffstat (limited to 'src')
-rw-r--r--src/cfg_rcl.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/cfg_rcl.c b/src/cfg_rcl.c
index 243d1437e..c0d897d39 100644
--- a/src/cfg_rcl.c
+++ b/src/cfg_rcl.c
@@ -372,6 +372,41 @@ rspamd_rcl_metric_handler (struct config_file *cfg, rspamd_cl_object_t *obj,
return TRUE;
}
+static gboolean
+rspamd_rcl_worker_handler (struct config_file *cfg, rspamd_cl_object_t *obj,
+ gpointer ud, struct rspamd_rcl_section *section, GError **err)
+{
+ rspamd_cl_object_t *val, *lobj;
+ const gchar *worker_type;
+ GQuark qtype;
+ struct worker_conf *wrk;
+
+ lobj = obj->value.ov;
+
+ HASH_FIND_STR (lobj, "type", val);
+ if (val != NULL && rspamd_cl_obj_tostring_safe (val, &worker_type)) {
+ qtype = g_quark_try_string (worker_type);
+ if (qtype != 0) {
+ wrk = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct worker_conf));
+ wrk->worker = get_worker_by_type (qtype);
+ if (wrk->worker == NULL) {
+ g_set_error (err, CFG_RCL_ERROR, EINVAL, "unknown worker type: %s", worker_type);
+ return FALSE;
+ }
+ wrk->type = qtype;
+ if (wrk->worker->worker_init_func) {
+ wrk->ctx = wrk->worker->worker_init_func ();
+ }
+ }
+ }
+ else {
+ g_set_error (err, CFG_RCL_ERROR, EINVAL, "undefined worker type");
+ return FALSE;
+ }
+
+ return rspamd_rcl_section_parse_defaults (section, cfg, obj, wrk, err);
+}
+
/**
* Fake handler to parse default options only, uses struct cfg_file as pointer
* for default handlers
@@ -509,6 +544,18 @@ rspamd_rcl_config_init (void)
sub = rspamd_rcl_add_section (new, "metric", rspamd_rcl_metric_handler, RSPAMD_CL_OBJECT,
FALSE, TRUE);
+ /**
+ * Worker section
+ */
+ sub = rspamd_rcl_add_section (new, "worker", rspamd_rcl_worker_handler, RSPAMD_CL_OBJECT,
+ FALSE, TRUE);
+ rspamd_rcl_add_default_handler (sub, "count", rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct worker_conf, count), RSPAMD_CL_FLAG_INT_16);
+ rspamd_rcl_add_default_handler (sub, "max_files", rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct worker_conf, rlimit_nofile), RSPAMD_CL_FLAG_INT_32);
+ rspamd_rcl_add_default_handler (sub, "max_core", rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct worker_conf, rlimit_maxcore), RSPAMD_CL_FLAG_INT_32);
+
return new;
}