Code

store: Consider objects too old if the new timestamp matches the old.
authorSebastian Harl <sh@tokkee.org>
Fri, 4 Jul 2014 18:35:26 +0000 (20:35 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 4 Jul 2014 18:35:26 +0000 (20:35 +0200)
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.

src/core/store.c
t/unit/core/store_test.c

index 8b284e77378bba680ead5d0edc8854049305a955..fc2a7f472d6dbdc0fb7111c2096cbfde38741d6f 100644 (file)
@@ -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) {
 
        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,
                        sdb_log(SDB_LOG_DEBUG, "store: Cannot update %s '%s' - "
                                        "value too old (%"PRIscTIME" < %"PRIscTIME")",
                                        SDB_STORE_TYPE_TO_NAME(type), name,
index 4e40743d85ce60b28dcb965ac770b72935285927..0a022e430508276e80563c7b37fc2fb494f6e511 100644 (file)
@@ -59,13 +59,13 @@ START_TEST(test_store_host)
                sdb_time_t  last_update;
                int         expected;
        } golden_data[] = {
                sdb_time_t  last_update;
                int         expected;
        } golden_data[] = {
+               { "a", 1, 0 },
                { "a", 2, 0 },
                { "a", 2, 0 },
-               { "a", 3, 0 },
                { "a", 1, 1 },
                { "a", 1, 1 },
-               { "b", 2, 0 },
+               { "b", 1, 0 },
                { "b", 1, 1 },
                { "A", 1, 1 }, /* case-insensitive */
                { "b", 1, 1 },
                { "A", 1, 1 }, /* case-insensitive */
-               { "A", 4, 0 },
+               { "A", 3, 0 },
        };
 
        struct {
        };
 
        struct {
@@ -172,14 +172,14 @@ START_TEST(test_store_attr)
                sdb_time_t  last_update;
                int         expected;
        } golden_data[] = {
                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;
        };
 
        size_t i;
@@ -213,14 +213,14 @@ START_TEST(test_store_service)
                sdb_time_t  last_update;
                int         expected;
        } golden_data[] = {
                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;
        };
 
        size_t i;