diff options
author | Max Kellermann <max@duempel.org> | 2014-11-25 14:00:32 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-11-25 14:00:32 +0100 |
commit | 016063c810281bd05c792dfe8643cc68b4c3cab2 (patch) | |
tree | 790b127710c514b963ba28ee5a49c29fae82f1c3 | |
parent | 38f19981b2bcaa6f08f1d1e81be66d217e8da9b8 (diff) | |
download | mpd-016063c810281bd05c792dfe8643cc68b4c3cab2.tar.gz mpd-016063c810281bd05c792dfe8643cc68b4c3cab2.tar.xz mpd-016063c810281bd05c792dfe8643cc68b4c3cab2.zip |
lib/nfs/FileReader: move code to CancelOrClose()
Diffstat (limited to '')
-rw-r--r-- | src/lib/nfs/FileReader.cxx | 10 | ||||
-rw-r--r-- | src/lib/nfs/FileReader.hxx | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/nfs/FileReader.cxx b/src/lib/nfs/FileReader.cxx index 79256492b..455165bbd 100644 --- a/src/lib/nfs/FileReader.cxx +++ b/src/lib/nfs/FileReader.cxx @@ -56,8 +56,18 @@ NfsFileReader::Close() return; } + /* this cancels State::MOUNT */ connection->RemoveLease(*this); + CancelOrClose(); +} + +void +NfsFileReader::CancelOrClose() +{ + assert(state != State::INITIAL && + state != State::DEFER); + if (state == State::IDLE) /* no async operation in progress: can close immediately */ diff --git a/src/lib/nfs/FileReader.hxx b/src/lib/nfs/FileReader.hxx index 424ff766d..1495a2832 100644 --- a/src/lib/nfs/FileReader.hxx +++ b/src/lib/nfs/FileReader.hxx @@ -76,6 +76,12 @@ protected: virtual void OnNfsFileError(Error &&error) = 0; private: + /** + * Cancel the current operation, if any. The NfsLease must be + * unregistered already. + */ + void CancelOrClose(); + void OpenCallback(nfsfh *_fh); void StatCallback(const struct stat *st); |