From 7ec707927db7e0f9b3e631b34346b9f56be50009 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 29 Dec 2016 11:37:18 +0100 Subject: [PATCH] lib/nfs/Blocking, neighbor/smbclient: pass std::chrono::duration to Cond::timed_wait() --- src/lib/nfs/Blocking.cxx | 2 ++ src/lib/nfs/Blocking.hxx | 5 +++-- src/neighbor/plugins/SmbclientNeighborPlugin.cxx | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/nfs/Blocking.cxx b/src/lib/nfs/Blocking.cxx index 7faa0549c..1599b786b 100644 --- a/src/lib/nfs/Blocking.cxx +++ b/src/lib/nfs/Blocking.cxx @@ -22,6 +22,8 @@ #include "Connection.hxx" #include "event/Call.hxx" +constexpr std::chrono::steady_clock::duration BlockingNfsOperation::timeout; + void BlockingNfsOperation::Run() { diff --git a/src/lib/nfs/Blocking.hxx b/src/lib/nfs/Blocking.hxx index 2c23ad057..ab9d07e2a 100644 --- a/src/lib/nfs/Blocking.hxx +++ b/src/lib/nfs/Blocking.hxx @@ -36,7 +36,8 @@ class NfsConnection; * thread, and method Run() waits for completion. */ class BlockingNfsOperation : protected NfsCallback, NfsLease { - static constexpr unsigned timeout_ms = 60000; + static constexpr std::chrono::steady_clock::duration timeout = + std::chrono::minutes(1); Mutex mutex; Cond cond; @@ -61,7 +62,7 @@ private: bool LockWaitFinished() { const ScopeLock protect(mutex); while (!finished) - if (!cond.timed_wait(mutex, timeout_ms)) + if (!cond.timed_wait(mutex, timeout)) return false; return true; diff --git a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx index ce076f2fd..95e4dd3fc 100644 --- a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx +++ b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx @@ -251,7 +251,7 @@ SmbclientNeighborExplorer::ThreadFunc() break; // TODO: sleep for how long? - cond.timed_wait(mutex, 10000); + cond.timed_wait(mutex, std::chrono::seconds(10)); } mutex.unlock();