From: Vsevolod Stakhov Date: Wed, 9 Jan 2013 15:07:32 +0000 (+0400) Subject: Store weight of symbol properly allowing dynamic conf code to modify a single pointer... X-Git-Tag: 0.5.4~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3918004b4161414bf0471dd1691b8c25000d02e1;p=thirdparty%2Frspamd.git Store weight of symbol properly allowing dynamic conf code to modify a single pointer in metrics section. --- diff --git a/src/cfg_file.h b/src/cfg_file.h index e3e24759e4..e87d10316c 100644 --- a/src/cfg_file.h +++ b/src/cfg_file.h @@ -144,7 +144,7 @@ struct module_opt { struct symbol_def { gchar *name; gchar *description; - gdouble weight; + gdouble *weight_ptr; }; /** diff --git a/src/cfg_xml.c b/src/cfg_xml.c index b7e5a7ab9b..ea42e1ae25 100644 --- a/src/cfg_xml.c +++ b/src/cfg_xml.c @@ -1097,7 +1097,7 @@ handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, } } - sym_def->weight = *value; + sym_def->weight_ptr = value; sym_def->name = memory_pool_strdup (cfg->cfg_pool, data); if (attrs != NULL) { diff --git a/src/webui.c b/src/webui.c index c7f7345125..a86f9abe6e 100644 --- a/src/webui.c +++ b/src/webui.c @@ -589,11 +589,11 @@ http_handle_symbols (struct evhttp_request *req, gpointer arg) sym = cur_sym->data; if (sym->description) { - evbuffer_add_printf (evb, "{\"symbol\":\"%s\",\"weight\":%.2f,\"description\":\"%s\"%s", sym->name, sym->weight, + evbuffer_add_printf (evb, "{\"symbol\":\"%s\",\"weight\":%.2f,\"description\":\"%s\"%s", sym->name, *sym->weight_ptr, sym->description, g_list_next (cur_sym) ? "}," : "}"); } else { - evbuffer_add_printf (evb, "{\"symbol\":\"%s\",\"weight\":%.2f%s", sym->name, sym->weight, + evbuffer_add_printf (evb, "{\"symbol\":\"%s\",\"weight\":%.2f%s", sym->name, *sym->weight_ptr, g_list_next (cur_sym) ? "}," : "}"); }