From: Sebastian Harl Date: Fri, 4 Jul 2014 18:35:26 +0000 (+0200) Subject: store: Consider objects too old if the new timestamp matches the old. X-Git-Tag: sysdb-0.3.0~88 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b1208c38f5098db7fb76ee760b29b57d89366807;p=sysdb.git store: Consider objects too old if the new timestamp matches the old. In theory, this doesn't make a big difference as either approach will let the result depend on the order of update operations. However, considering more cases as too old will allow to ignore more stuff and, thus, avoid some work. --- diff --git a/src/core/store.c b/src/core/store.c index 8b284e7..fc2a7f4 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -250,7 +250,7 @@ store_obj(sdb_llist_t *parent_list, int type, const char *name, old = STORE_OBJ(sdb_llist_search_by_name(parent_list, name)); if (old) { - if (old->last_update > last_update) { + if (old->last_update >= last_update) { sdb_log(SDB_LOG_DEBUG, "store: Cannot update %s '%s' - " "value too old (%"PRIscTIME" < %"PRIscTIME")", SDB_STORE_TYPE_TO_NAME(type), name, diff --git a/t/unit/core/store_test.c b/t/unit/core/store_test.c index 4e40743..0a022e4 100644 --- a/t/unit/core/store_test.c +++ b/t/unit/core/store_test.c @@ -59,13 +59,13 @@ START_TEST(test_store_host) sdb_time_t last_update; int expected; } golden_data[] = { + { "a", 1, 0 }, { "a", 2, 0 }, - { "a", 3, 0 }, { "a", 1, 1 }, - { "b", 2, 0 }, + { "b", 1, 0 }, { "b", 1, 1 }, { "A", 1, 1 }, /* case-insensitive */ - { "A", 4, 0 }, + { "A", 3, 0 }, }; struct { @@ -172,14 +172,14 @@ START_TEST(test_store_attr) sdb_time_t last_update; int expected; } golden_data[] = { - { "k", "k", "v", 1, -1 }, - { "k", "k", "v", 1, -1 }, /* retry to ensure the host is not created */ - { "l", "k1", "v1", 1, 0 }, - { "l", "k1", "v2", 2, 0 }, - { "l", "k1", "v3", 1, 1 }, - { "l", "k2", "v1", 1, 0 }, - { "m", "k", "v1", 2, 0 }, - { "m", "k", "v2", 1, 1 }, + { "k", "k", "v", 1, -1 }, + { "k", "k", "v", 1, -1 }, /* retry to ensure the host is not created */ + { "l", "k1", "v1", 1, 0 }, + { "l", "k1", "v2", 2, 0 }, + { "l", "k1", "v3", 2, 1 }, + { "l", "k2", "v1", 1, 0 }, + { "m", "k", "v1", 1, 0 }, + { "m", "k", "v2", 1, 1 }, }; size_t i; @@ -213,14 +213,14 @@ START_TEST(test_store_service) sdb_time_t last_update; int expected; } golden_data[] = { - { "k", "s", 1, -1 }, - { "k", "s", 1, -1 }, /* retry to ensure the host is not created */ - { "l", "s1", 1, 0 }, - { "l", "s1", 2, 0 }, - { "l", "s1", 1, 1 }, - { "l", "s2", 1, 0 }, - { "m", "s", 2, 0 }, - { "m", "s", 1, 1 }, + { "k", "s", 1, -1 }, + { "k", "s", 1, -1 }, /* retry to ensure the host is not created */ + { "l", "s1", 1, 0 }, + { "l", "s1", 2, 0 }, + { "l", "s1", 2, 1 }, + { "l", "s2", 1, 0 }, + { "m", "s", 1, 0 }, + { "m", "s", 1, 1 }, }; size_t i;