From 87e8328be601171f591c267d36c08910e3e7cce6 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Tue, 22 Sep 2015 06:48:56 -0700 Subject: [PATCH] Don't start NTP thread if there is NTP server active at localhost. --- src/ntp.cpp | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/ntp.cpp b/src/ntp.cpp index 2ce65e1..e8d0e4a 100644 --- a/src/ntp.cpp +++ b/src/ntp.cpp @@ -424,6 +424,16 @@ void ThreadNtpSamples(void* parg) { // Maximum offset is 2 hours. const int64_t nMaxOffset = 7200; + printf("Trying to find NTP server at localhost...\n"); + + std::string strLocalHost = "127.0.0.1"; + if (NtpGetTime(strLocalHost) == GetTime()) { + printf("There is NTP server active at localhost, we don't need NTP thread.\n"); + + nNtpOffset = 0; + return; + } + printf("ThreadNtpSamples started\n"); vnThreadsRunning[THREAD_NTP]++; -- 1.7.1