summaryrefslogtreecommitdiff
path: root/zen/dir_watcher.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2017-01-08 18:21:23 +0100
committerDaniel Wilhelm <shieldwed@outlook.com>2017-01-08 18:21:23 +0100
commitfe660cdff59aa3a939479ed60172e5c0803552b2 (patch)
tree045cf295b79de10f75ed6362c5836db25c9fc63a /zen/dir_watcher.cpp
parent8.6 (diff)
downloadFreeFileSync-fe660cdff59aa3a939479ed60172e5c0803552b2.tar.gz
FreeFileSync-fe660cdff59aa3a939479ed60172e5c0803552b2.tar.bz2
FreeFileSync-fe660cdff59aa3a939479ed60172e5c0803552b2.zip
8.7
Diffstat (limited to 'zen/dir_watcher.cpp')
-rw-r--r--zen/dir_watcher.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/zen/dir_watcher.cpp b/zen/dir_watcher.cpp
index 12a6a9f4..98190bba 100644
--- a/zen/dir_watcher.cpp
+++ b/zen/dir_watcher.cpp
@@ -9,6 +9,7 @@
#include <set>
#include "thread.h"
#include "scope_guard.h"
+#include "basic_math.h"
#ifdef ZEN_WIN
#include "device_notify.h"
@@ -358,10 +359,11 @@ std::vector<DirWatcher::Entry> DirWatcher::getChanges(const std::function<void()
//wait until device removal is confirmed, to prevent locking hDir again by some new watch!
if (pimpl_->volRemoval->requestReceived())
{
- const std::chrono::steady_clock::time_point stopTime = std::chrono::steady_clock::now() + std::chrono::seconds(15);
+ const auto startTime = std::chrono::steady_clock::now();
//HandleVolumeRemoval::finished() not guaranteed! note: Windows gives unresponsive applications ca. 10 seconds until unmounting the usb stick in worst case
- while (!pimpl_->volRemoval->finished() && std::chrono::steady_clock::now() < stopTime)
+ while (!pimpl_->volRemoval->finished() &&
+ numeric::dist(std::chrono::steady_clock::now(), startTime) < std::chrono::seconds(15)) //handle potential chrono wrap-around!
{
processGuiMessages(); //DBT_DEVICEREMOVECOMPLETE message is sent here!
std::this_thread::sleep_for(std::chrono::milliseconds(50));
bgstack15