File src/status.c changed (mode: 100644) (index 0e31a2234..a874afd78) |
... |
... |
dcache_get_of(const dir_entry_t *entry, dcache_result_t *size, |
513 |
513 |
if(fsdata_get(dcache_size, full_path, &size_data, sizeof(size_data)) == 0) |
if(fsdata_get(dcache_size, full_path, &size_data, sizeof(size_data)) == 0) |
514 |
514 |
{ |
{ |
515 |
515 |
size->value = size_data.value; |
size->value = size_data.value; |
516 |
|
size->is_valid = (entry->mtime <= size_data.timestamp); |
|
|
516 |
|
/* We check strictly for less than to handle scenario when multiple changes |
|
517 |
|
* occurred during the same second. */ |
|
518 |
|
size->is_valid = (entry->mtime < size_data.timestamp); |
517 |
519 |
} |
} |
518 |
520 |
pthread_mutex_unlock(&dcache_size_mutex); |
pthread_mutex_unlock(&dcache_size_mutex); |
519 |
521 |
|
|
|
... |
... |
dcache_get_of(const dir_entry_t *entry, dcache_result_t *size, |
522 |
524 |
sizeof(nitems_data)) == 0) |
sizeof(nitems_data)) == 0) |
523 |
525 |
{ |
{ |
524 |
526 |
nitems->value = nitems_data.value; |
nitems->value = nitems_data.value; |
525 |
|
nitems->is_valid = (entry->mtime <= nitems_data.timestamp); |
|
|
527 |
|
/* We check strictly for less than to handle scenario when multiple changes |
|
528 |
|
* occurred during the same second. */ |
|
529 |
|
nitems->is_valid = (entry->mtime < nitems_data.timestamp); |
526 |
530 |
} |
} |
527 |
531 |
pthread_mutex_unlock(&dcache_nitems_mutex); |
pthread_mutex_unlock(&dcache_nitems_mutex); |
528 |
532 |
} |
} |
File tests/misc/dcache.c changed (mode: 100644) (index 3dea8e8c4..6e40aa72f) |
... |
... |
TEST(outdated_data_is_detected) |
56 |
56 |
|
|
57 |
57 |
dcache_set_at(TEST_DATA_PATH, 10, 11); |
dcache_set_at(TEST_DATA_PATH, 10, 11); |
58 |
58 |
|
|
59 |
|
entry.mtime = time(NULL) + 1; |
|
|
59 |
|
/* Entry was updated *while* it was being cached. */ |
|
60 |
|
entry.mtime = time(NULL); |
|
61 |
|
dcache_get_of(&entry, &size, &nitems); |
|
62 |
|
assert_false(size.is_valid); |
|
63 |
|
assert_false(nitems.is_valid); |
60 |
64 |
|
|
|
65 |
|
/* Entry was updated *after* it was cached. */ |
|
66 |
|
entry.mtime = time(NULL) + 1; |
61 |
67 |
dcache_get_of(&entry, &size, &nitems); |
dcache_get_of(&entry, &size, &nitems); |
62 |
68 |
assert_false(size.is_valid); |
assert_false(size.is_valid); |
63 |
69 |
assert_false(nitems.is_valid); |
assert_false(nitems.is_valid); |