Browse Source

use _USE_32BIT_TIME_T in win32 build

Add i2pd.exe in .gitignore
pull/797/head
R4SAS 8 years ago
parent
commit
d96dbe9365
  1. 1
      .gitignore
  2. 16
      Timestamp.cpp

1
.gitignore vendored

@ -8,6 +8,7 @@ netDb
/i2pd /i2pd
/libi2pd.a /libi2pd.a
/libi2pdclient.a /libi2pdclient.a
i2pd.exe
# Autotools # Autotools

16
Timestamp.cpp

@ -5,6 +5,12 @@
#include "I2PEndian.h" #include "I2PEndian.h"
#include "Timestamp.h" #include "Timestamp.h"
#ifdef WIN32
#ifndef _WIN64
#define _USE_32BIT_TIME_T
#endif
#endif
namespace i2p namespace i2p
{ {
namespace util namespace util
@ -33,17 +39,17 @@ namespace util
socket.send_to (boost::asio::buffer (buf, 48), ep); socket.send_to (boost::asio::buffer (buf, 48), ep);
int i = 0; int i = 0;
while (!socket.available() && i < 10) // 10 seconds max while (!socket.available() && i < 10) // 10 seconds max
{ {
std::this_thread::sleep_for (std::chrono::seconds(1)); std::this_thread::sleep_for (std::chrono::seconds(1));
i++; i++;
} }
if (socket.available ()) if (socket.available ())
len = socket.receive_from (boost::asio::buffer (buf, 48), ep); len = socket.receive_from (boost::asio::buffer (buf, 48), ep);
} }
catch (std::exception& e) catch (std::exception& e)
{ {
LogPrint (eLogError, "NTP error: ", e.what ()); LogPrint (eLogError, "NTP error: ", e.what ());
} }
if (len >= 8) if (len >= 8)
{ {
auto ourTs = GetSecondsSinceEpoch (); auto ourTs = GetSecondsSinceEpoch ();
@ -51,10 +57,10 @@ namespace util
if (ts > 2208988800U) ts -= 2208988800U; // 1/1/1970 from 1/1/1900 if (ts > 2208988800U) ts -= 2208988800U; // 1/1/1970 from 1/1/1900
g_TimeOffset = ts - ourTs; g_TimeOffset = ts - ourTs;
LogPrint (eLogInfo, address, " time offset from system time is ", g_TimeOffset, " seconds"); LogPrint (eLogInfo, address, " time offset from system time is ", g_TimeOffset, " seconds");
} }
} }
} }
} }
} }
} }

Loading…
Cancel
Save