aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-05 16:15:30 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-05 16:15:30 +0200
commit6de7ae95839aa61495731846585c8998e6b0837d (patch)
treec27c5bda2083d534fc6e224f4ab7228006e9874f
parent3a922c3c1acd08bc59ffec419aa555cbecb1f3da (diff)
downloadxK-6de7ae95839aa61495731846585c8998e6b0837d.tar.gz
xK-6de7ae95839aa61495731846585c8998e6b0837d.tar.xz
xK-6de7ae95839aa61495731846585c8998e6b0837d.zip
degesch: only apply relevant attributes on change
-rw-r--r--degesch.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/degesch.c b/degesch.c
index 95e324f..14f6476 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1869,22 +1869,31 @@ log_message_attributed (void *user_data, const char *quote, const char *fmt,
}
static void
+apply_attribute_change (struct config_item_ *item, int id)
+{
+ struct app_context *ctx = item->user_data;
+ free (ctx->attrs[id]);
+ ctx->attrs[id] = xstrdup (item->type == CONFIG_ITEM_NULL
+ ? ctx->attrs_defaults[id]
+ : item->value.string.str);
+}
+
+static void
on_config_attribute_change (struct config_item_ *item)
{
static const char *table[ATTR_COUNT] =
{
-#define XX(x, y, z) [ATTR_ ## x] = "attributes." y,
+#define XX(x, y, z) [ATTR_ ## x] = y,
ATTR_TABLE (XX)
#undef XX
};
- struct app_context *ctx = item->user_data;
- for (int id = 0; id < ATTR_COUNT; id++)
- {
- const char *user = get_config_string (ctx->config.root, table[id]);
- free (ctx->attrs[id]);
- ctx->attrs[id] = xstrdup (user ? user : ctx->attrs_defaults[id]);
- }
+ for (size_t i = 0; i < N_ELEMENTS (table); i++)
+ if (!strcmp (item->schema->name, table[i]))
+ {
+ apply_attribute_change (item, i);
+ return;
+ }
}
static void