From 8c23d507cbb0af5452d6d4e16b1750adfbb7d28d Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 28 Apr 2012 23:38:22 +0200 Subject: [PATCH 1/1] Conf: Introduced cf_set_journalling() --- ucw/conf-internal.h | 8 ++++---- ucw/conf-intr.c | 2 +- ucw/conf-journal.c | 8 ++++++++ ucw/conf.h | 7 ++++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ucw/conf-internal.h b/ucw/conf-internal.h index a47ab466..bab53837 100644 --- a/ucw/conf-internal.h +++ b/ucw/conf-internal.h @@ -42,19 +42,19 @@ struct dirty_section { struct cf_context { struct mempool *pool; int is_active; - int need_journal; int def_loaded; struct cf_parser_state *parser; uns everything_committed; // after the 1st load, this flag is set on uns postpone_commit; // used internally by cf_getopt() uns other_options; - clist conf_entries; + clist conf_entries; // files/strings to reload struct old_pools *pools; struct cf_journal_item *journal; - struct item_stack stack[MAX_STACK_SIZE]; + int need_journal; + struct item_stack stack[MAX_STACK_SIZE]; // interpreter stack uns stack_level; - uns initialized; struct cf_section sections; // root section + uns sections_initialized; dirtsec_t dirty; // dirty sections uns dirties; }; diff --git a/ucw/conf-intr.c b/ucw/conf-intr.c index 57192e92..f4226510 100644 --- a/ucw/conf-intr.c +++ b/ucw/conf-intr.c @@ -635,7 +635,7 @@ cf_modify_item(struct cf_item *item, enum cf_operation op, int number, char **pa void cf_init_stack(struct cf_context *cc) { - if (!cc->initialized++) { + if (!cc->sections_initialized++) { cc->sections.flags |= SEC_FLAG_UNKNOWN; cc->sections.size = 0; // size of allocated array used to be stored here cf_init_section(NULL, &cc->sections, NULL, 0); diff --git a/ucw/conf-journal.c b/ucw/conf-journal.c index 75af51ad..6412328a 100644 --- a/ucw/conf-journal.c +++ b/ucw/conf-journal.c @@ -28,6 +28,14 @@ struct cf_journal_item { byte copy[0]; }; +void +cf_set_journalling(int enable) +{ + struct cf_context *cc = cf_get_context(); + ASSERT(!cc->journal); + cc->need_journal = enable; +} + void cf_journal_block(void *ptr, uns len) { diff --git a/ucw/conf.h b/ucw/conf.h index 82bc852f..07d83e7b 100644 --- a/ucw/conf.h +++ b/ucw/conf.h @@ -366,7 +366,12 @@ char *cf_printf(const char *fmt, ...) FORMAT_CHECK(printf,1,2); /** printf() int * * For error recovery when <>. ***/ -extern uns cf_need_journal; /** Is the journal needed? If you do not reload configuration, you set this to 0 and gain a little more performance and free memory. **/ +/** + * By default, the configuration mechanism remembers all changes in a journal, + * so that the configuration can be rolled back or reloaded. This function + * can be used to disable journalling, which saves some memory. + **/ +void cf_set_journalling(int enable); /** * When a block of memory is about to be changed, put the old value * into journal with this function. You need to call it from a <> -- 2.39.2