From 687ea53616a2e6adaba976d5a254f56376e4ab67 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Sep 2016 16:51:36 +0200 Subject: [PATCH] input/nfs: use class ScopeUnlock --- src/input/plugins/NfsInputPlugin.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx index ddacf317f..bb3eb8732 100644 --- a/src/input/plugins/NfsInputPlugin.cxx +++ b/src/input/plugins/NfsInputPlugin.cxx @@ -96,10 +96,13 @@ NfsInputStream::DoRead() size_t nbytes = std::min(std::min(remaining, 32768), buffer_space); - mutex.unlock(); Error error; - bool success = NfsFileReader::Read(next_offset, nbytes, error); - mutex.lock(); + bool success; + + { + const ScopeUnlock unlock(mutex); + success = NfsFileReader::Read(next_offset, nbytes, error); + } if (!success) { PostponeError(std::move(error)); @@ -135,9 +138,10 @@ NfsInputStream::DoResume() void NfsInputStream::DoSeek(offset_type new_offset) { - mutex.unlock(); - NfsFileReader::CancelRead(); - mutex.lock(); + { + const ScopeUnlock unlock(mutex); + NfsFileReader::CancelRead(); + } next_offset = offset = new_offset; SeekDone();