# HG changeset patch # User Paul Boddie # Date 1629566888 -7200 # Node ID 9205a25c62d617e09c9c524e07b3b21eaeea5b97 # Parent dea9c3ee5f60ea10ffd2c63817fa746975ed12b2 Introduced unsubscribe operations when closure notifications are received. diff -r dea9c3ee5f60 -r 9205a25c62d6 libfsclient/lib/src/file.cc --- a/libfsclient/lib/src/file.cc Sat Aug 21 19:26:33 2021 +0200 +++ b/libfsclient/lib/src/file.cc Sat Aug 21 19:28:08 2021 +0200 @@ -409,8 +409,14 @@ long file_notify_wait_file(file_t *file) { SpecificFileNotifier *notifier = get_task_notifier(); + long err = notifier->wait_file(file); - return notifier->wait_file(file); + /* Unsubscribe if a closure notification has been received. */ + + if (!err && (file->notifications & NOTIFY_PEER_CLOSED)) + file_notify_unsubscribe(file, NOTIFIER_TASK); + + return err; } /* Wait for notification events on files. */ @@ -418,8 +424,14 @@ long file_notify_wait_files(file_t **file) { GeneralFileNotifier *notifier = get_thread_notifier(); + long err = notifier->wait(file); - return notifier->wait(file); + /* Unsubscribe if a closure notification has been received. */ + + if (!err && ((*file)->notifications & NOTIFY_PEER_CLOSED)) + file_notify_unsubscribe(*file, NOTIFIER_THREAD); + + return err; }