diff options
author | Max Kellermann <max@duempel.org> | 2014-12-14 21:16:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-15 00:45:13 +0100 |
commit | a48704925d6c3e5c01057192403e55f3663b315c (patch) | |
tree | 551f94bfa11da645dc01e61bd38d746383436b87 /src/lib/nfs/Blocking.hxx | |
parent | 68d1abdb851a839fefc55b00eb49eb22a399595b (diff) | |
download | mpd-a48704925d6c3e5c01057192403e55f3663b315c.tar.gz mpd-a48704925d6c3e5c01057192403e55f3663b315c.tar.xz mpd-a48704925d6c3e5c01057192403e55f3663b315c.zip |
storage/nfs: add timeout
Diffstat (limited to '')
-rw-r--r-- | src/lib/nfs/Blocking.hxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/nfs/Blocking.hxx b/src/lib/nfs/Blocking.hxx index f8354822d..eb16dfb8c 100644 --- a/src/lib/nfs/Blocking.hxx +++ b/src/lib/nfs/Blocking.hxx @@ -35,6 +35,8 @@ class NfsConnection; * thread, and method Run() waits for completion. */ class BlockingNfsOperation : protected NfsCallback, NfsLease { + static constexpr unsigned timeout_ms = 60000; + Mutex mutex; Cond cond; @@ -52,10 +54,13 @@ public: bool Run(Error &error); private: - void LockWaitFinished() { + bool LockWaitFinished() { const ScopeLock protect(mutex); while (!finished) - cond.wait(mutex); + if (!cond.timed_wait(mutex, timeout_ms)) + return false; + + return true; } /** |