Skip to content

Commit

Permalink
use _USE_32BIT_TIME_T in win32 build
Browse files Browse the repository at this point in the history
Add i2pd.exe in .gitignore
  • Loading branch information
r4sas committed Feb 6, 2017
1 parent 35b5dcd commit d96dbe9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ netDb
/i2pd
/libi2pd.a
/libi2pdclient.a
i2pd.exe


# Autotools
Expand Down
16 changes: 11 additions & 5 deletions Timestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#include "I2PEndian.h"
#include "Timestamp.h"

#ifdef WIN32
#ifndef _WIN64
#define _USE_32BIT_TIME_T
#endif
#endif

namespace i2p
{
namespace util
Expand Down Expand Up @@ -33,28 +39,28 @@ namespace util
socket.send_to (boost::asio::buffer (buf, 48), ep);
int i = 0;
while (!socket.available() && i < 10) // 10 seconds max
{
{
std::this_thread::sleep_for (std::chrono::seconds(1));
i++;
}
}
if (socket.available ())
len = socket.receive_from (boost::asio::buffer (buf, 48), ep);
}
catch (std::exception& e)
{
LogPrint (eLogError, "NTP error: ", e.what ());
}
}
if (len >= 8)
{
auto ourTs = GetSecondsSinceEpoch ();
uint32_t ts = bufbe32toh (buf + 32);
if (ts > 2208988800U) ts -= 2208988800U; // 1/1/1970 from 1/1/1900
g_TimeOffset = ts - ourTs;
LogPrint (eLogInfo, address, " time offset from system time is ", g_TimeOffset, " seconds");
}
}
}
}
}
}
}
}

0 comments on commit d96dbe9

Please sign in to comment.