Don't start NTP thread if there is NTP server active at localhost.
authorCryptoManiac <balthazar.ad@gmail.com>
Tue, 22 Sep 2015 13:48:56 +0000 (06:48 -0700)
committerCryptoManiac <balthazar.ad@gmail.com>
Tue, 22 Sep 2015 13:48:56 +0000 (06:48 -0700)
src/ntp.cpp

index 2ce65e1..e8d0e4a 100644 (file)
@@ -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]++;