From bbf330c6ca5d08dcf58d74cf5d55162e5fb9018c Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Sun, 23 Apr 2006 12:24:40 +0200 Subject: [PATCH] conf2: fixed journaling of list operations --- lib/conf2.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/conf2.c b/lib/conf2.c index e509345b..07513f5d 100644 --- a/lib/conf2.c +++ b/lib/conf2.c @@ -608,28 +608,29 @@ interpret_section(struct cf_section *sec, int number, byte **pars, int *processe } static void -add_to_list(void *list, struct cnode *node, enum operation op) +add_to_list(struct cnode *where, struct cnode *new_node, enum operation op) { - //cf_journal_block(list, sizeof(struct clist)); //FIXME: we should journal the nodes of the list instead switch (op) { - case OP_SET: - case OP_APPEND: - clist_add_tail(list, node); - break; - case OP_PREPEND: - clist_add_head(list, node); + case OP_EDIT: // edition has been done in-place break; case OP_REMOVE: - clist_remove(list); + cf_journal_block(&where->prev->next, sizeof(void*)); + cf_journal_block(&where->next->prev, sizeof(void*)); + clist_remove(where); break; - case OP_EDIT: // edition has been done in-place - break; - case OP_AFTER: // here the pointer list is actually a pointer to another node - clist_insert_after(node, list); + case OP_AFTER: // implementation dependend (prepend_head = after(list)), and where==list, see clists.h:74 + case OP_PREPEND: + cf_journal_block(&where->next->prev, sizeof(void*)); + cf_journal_block(&where->next, sizeof(void*)); + clist_insert_after(new_node, where); break; - case OP_BEFORE: - clist_insert_before(node, list); + case OP_BEFORE: // implementation dependend (append_tail = before(list)) + case OP_APPEND: + case OP_SET: + cf_journal_block(&where->prev->next, sizeof(void*)); + cf_journal_block(&where->prev, sizeof(void*)); + clist_insert_before(new_node, where); break; default: ASSERT(0); -- 2.39.2