aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Database.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Database.cpp b/src/Database.cpp
index cf72c6a..f2d0fe1 100644
--- a/src/Database.cpp
+++ b/src/Database.cpp
@@ -121,7 +121,8 @@ namespace odhtdb
ntp::NtpClient ntpClient("pool.ntp.org");
while(databaseCount > 0)
{
- for(int i = 0; i < ntpFetchTimestampRetries; ++i)
+ int fetchRetryCounter = 0;
+ while(fetchRetryCounter < ntpFetchTimestampRetries)
{
try
{
@@ -132,11 +133,15 @@ namespace odhtdb
}
catch(ntp::NtpClientException &e)
{
- Log::warn("Failed to sync clock with ntp server, reason: %s. Try #%d", e.what(), i);
+ Log::warn("Failed to sync clock with ntp server, reason: %s. Try #%d", e.what(), fetchRetryCounter);
this_thread::sleep_for(500ms);
}
+ ++fetchRetryCounter;
}
- // TODO: Also use timestamp fraction (milliseconds)
+
+ if(fetchRetryCounter == ntpFetchTimestampRetries)
+ throw ntp::NtpClientException("Failed to retrieve ntp timestamp after several retries");
+
this_thread::sleep_for(60s);
}
timestampSynced = false;