1.1 --- a/libfsclient/lib/src/file.cc Sat Aug 21 19:26:33 2021 +0200
1.2 +++ b/libfsclient/lib/src/file.cc Sat Aug 21 19:28:08 2021 +0200
1.3 @@ -409,8 +409,14 @@
1.4 long file_notify_wait_file(file_t *file)
1.5 {
1.6 SpecificFileNotifier *notifier = get_task_notifier();
1.7 + long err = notifier->wait_file(file);
1.8
1.9 - return notifier->wait_file(file);
1.10 + /* Unsubscribe if a closure notification has been received. */
1.11 +
1.12 + if (!err && (file->notifications & NOTIFY_PEER_CLOSED))
1.13 + file_notify_unsubscribe(file, NOTIFIER_TASK);
1.14 +
1.15 + return err;
1.16 }
1.17
1.18 /* Wait for notification events on files. */
1.19 @@ -418,8 +424,14 @@
1.20 long file_notify_wait_files(file_t **file)
1.21 {
1.22 GeneralFileNotifier *notifier = get_thread_notifier();
1.23 + long err = notifier->wait(file);
1.24
1.25 - return notifier->wait(file);
1.26 + /* Unsubscribe if a closure notification has been received. */
1.27 +
1.28 + if (!err && ((*file)->notifications & NOTIFY_PEER_CLOSED))
1.29 + file_notify_unsubscribe(*file, NOTIFIER_THREAD);
1.30 +
1.31 + return err;
1.32 }
1.33
1.34