diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-07-05 01:56:00 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-07-05 02:16:43 +0200 |
commit | b1dd34a7ba1d7558763fcf1f1528d34fc1856829 (patch) | |
tree | 533d2ad1e83d424e0242dfb2207890a08619723f | |
parent | 9b41256ebf21a118b3a1a68b9bf2acfd75a7f5be (diff) | |
download | xK-b1dd34a7ba1d7558763fcf1f1528d34fc1856829.tar.gz xK-b1dd34a7ba1d7558763fcf1f1528d34fc1856829.tar.xz xK-b1dd34a7ba1d7558763fcf1f1528d34fc1856829.zip |
degesch: set "user_data" while loading config
It'd be quite wrong to call "on_change" on them without this.
-rw-r--r-- | common.c | 11 | ||||
-rw-r--r-- | degesch.c | 14 |
2 files changed, 10 insertions, 15 deletions
@@ -1865,11 +1865,9 @@ config_item_clone (struct config_item_ *self) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: maybe also make it possible to assign the "user_data" pointer - static void config_schema_fix_value - (struct config_schema *schema, struct config_item_ *object) + (struct config_schema *schema, struct config_item_ *object, void *user_data) { struct config_item_ *item = str_map_find (&object->value.object, schema->name); @@ -1912,17 +1910,18 @@ config_schema_fix_value item->type = schema->type; item->schema = schema; + item->user_data = user_data; if (schema->on_change) schema->on_change (item); } static void -config_schema_apply_to_object - (struct config_schema *schema_array, struct config_item_ *object) +config_schema_apply_to_object (struct config_schema *schema_array, + struct config_item_ *object, void *user_data) { hard_assert (object->type == CONFIG_ITEM_OBJECT); while (schema_array->name) - config_schema_fix_value (schema_array++, object); + config_schema_fix_value (schema_array++, object, user_data); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1576,17 +1576,13 @@ static struct config_schema g_config_attributes[] = static void load_config_behaviour (struct config_item_ *subtree, void *user_data) { - (void) user_data; - // TODO: assign user_data to all the subitems - config_schema_apply_to_object (g_config_behaviour, subtree); + config_schema_apply_to_object (g_config_behaviour, subtree, user_data); } static void load_config_attributes (struct config_item_ *subtree, void *user_data) { - (void) user_data; - // TODO: assign user_data to all the subitems - config_schema_apply_to_object (g_config_attributes, subtree); + config_schema_apply_to_object (g_config_attributes, subtree, user_data); } static void @@ -8398,9 +8394,6 @@ load_server_from_config (struct app_context *ctx, struct server *s = xmalloc (sizeof *s); server_init (s, &ctx->poller); - // TODO: assign user_data (s) to all the subitems - config_schema_apply_to_object (g_config_server, subtree); - s->ctx = ctx; s->name = xstrdup (name); str_map_set (&ctx->servers, s->name, s); @@ -8415,6 +8408,9 @@ load_server_from_config (struct app_context *ctx, buffer_add (ctx, buffer); buffer_activate (ctx, buffer); + // This fires any "on_change" callbacks + config_schema_apply_to_object (g_config_server, subtree, s); + // XXX: is this desirable in here? I think we should do it only when // actually creating a new server instead of every time we load them. struct error *e = NULL; |