xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 9a116b3da30d446fa88573eae41e1622b5826ecc

Fix possibly caching of slightly outdated data
When multiple changes occurred during the same second, resolution of 1
second and <= check might cause us to miss some updates. Checking
strictly for less than results in better accuracy at the expense of
possible useless recalculation or false invalidation. Accurate results
are preferred.
Author: xaizek
Author date (UTC): 2018-01-21 15:46
Committer name: xaizek
Committer date (UTC): 2018-01-21 15:49
Parent(s): 078e0c2f3f589af6cbe4b01d711367125fcb8cb2
Signing key: 99DC5E4DB05F6BE2
Tree: 64596886ff7bcf46a6635334b1e43c941798050f
File Lines added Lines deleted
src/status.c 6 2
tests/misc/dcache.c 7 1
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);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master