diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2017-05-31 13:43:54 -0700 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2017-05-31 13:43:54 -0700 |
commit | 8d092c2be9083319e1c9e05dd5da1e9b7caf9fe6 (patch) | |
tree | 34c45386cc36968c365d60b26f1d12531bbbf521 /example | |
parent | 6b8dddbd8ec0673c043efcb1f4d45bb49103146d (diff) |
notify_store_retrieve(): fix race on unmount
update_fs_loop() is still running when the filesystem unmounts,
but it that case calls to fuse_lowlevel_notify_* will fail.
Fixes: #105.
Diffstat (limited to 'example')
-rw-r--r-- | example/notify_store_retrieve.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/example/notify_store_retrieve.c b/example/notify_store_retrieve.c index 0ed22bb..c7e2957 100644 --- a/example/notify_store_retrieve.c +++ b/example/notify_store_retrieve.c @@ -317,7 +317,11 @@ static void* update_fs_loop(void *data) { /* This shouldn't fail, but apparenly it sometimes does - see https://github.com/libfuse/libfuse/issues/105 */ ret = fuse_lowlevel_notify_store(se, FILE_INO, 0, &bufv, 0); - if (ret != 0) { + if (-ret == ENODEV) { + // File system was unmounted + break; + } + else if (ret != 0) { fprintf(stderr, "ERROR: fuse_lowlevel_notify_store() failed with %s (%d)\n", strerror(-ret), -ret); abort(); @@ -325,9 +329,12 @@ static void* update_fs_loop(void *data) { /* To make sure that everything worked correctly, ask the kernel to send us back the stored data */ - assert(fuse_lowlevel_notify_retrieve - (se, FILE_INO, MAX_STR_LEN, 0, - (void*) strdup(file_contents)) == 0); + ret = fuse_lowlevel_notify_retrieve(se, FILE_INO, MAX_STR_LEN, + 0, (void*) strdup(file_contents)); + if (-ret == ENODEV) { // File system was unmounted + break; + } + assert(ret == 0); if(retrieve_status == 0) retrieve_status = 1; } |