Use safer rstime_t instead of time_t

Avoid problems to serialization on different platforms, without breaking
nested STL containers serialization.

The conversion have been made with sed, and checked with grep, plus
kdiff3 visual ispection, plus rutime tests, so it should be fine.
This commit is contained in:
Gioacchino Mazzurco 2018-10-07 01:34:05 +02:00
parent 41aa675a9b
commit 329050a9c2
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
223 changed files with 930 additions and 911 deletions

View file

@ -21,7 +21,7 @@
*******************************************************************************/
#include <list>
#include <string>
#include <time.h>
#include "util/rstime.h"
//#include "serialiser/rsdsdvitems.h"
#include "services/p3dsdv.h"
@ -105,8 +105,8 @@ int p3Dsdv::status()
int p3Dsdv::sendTables()
{
time_t now = time(NULL);
time_t tt, it;
rstime_t now = time(NULL);
rstime_t tt, it;
bool updateRequired = false;
{
RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/
@ -156,7 +156,7 @@ void p3Dsdv::advanceLocalSequenceNumbers()
{
RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/
time_t now = time(NULL);
rstime_t now = time(NULL);
std::map<std::string, RsDsdvTableEntry>::iterator it;
for(it = mTable.begin(); it != mTable.end(); ++it)
@ -317,7 +317,7 @@ int p3Dsdv::handleDSDV(RsDsdvRouteItem *dsdv)
/* iterate over the entries */
RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/
time_t now = time(NULL);
rstime_t now = time(NULL);
#ifdef DEBUG_DSDV
std::cerr << "p3Dsdv::handleDSDV() Received Pkt from: " << dsdv->PeerId();
@ -458,7 +458,7 @@ int p3Dsdv::selectStableRoutes()
/* iterate over the entries */
RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/
time_t now = time(NULL);
rstime_t now = time(NULL);
#ifdef DEBUG_DSDV
std::cerr << "p3Dsdv::selectStableRoutes()";
@ -489,7 +489,7 @@ int p3Dsdv::selectStableRoutes()
RsPeerId newestId;
uint32_t closest = RSDSDV_MAX_DISTANCE + 1;
RsPeerId closestId;
time_t closestAge = 0;
rstime_t closestAge = 0;
/* find newest sequence number */
for(rit = tit->second.mAllRoutes.begin();
@ -718,7 +718,7 @@ int p3Dsdv::addDsdvId(RsDsdvId *id, std::string realHash)
std::cerr << std::endl;
#endif
time_t now = time(NULL);
rstime_t now = time(NULL);
/* check for duplicate */
std::map<std::string, RsDsdvTableEntry>::iterator it;
@ -861,7 +861,7 @@ std::ostream &operator<<(std::ostream &out, const RsDsdvId &id)
std::ostream &operator<<(std::ostream &out, const RsDsdvRoute &route)
{
time_t now = time(NULL);
rstime_t now = time(NULL);
out << "< Seq: " << route.mSequence << " Dist: " << route.mDistance;
out << " NextHop: " << route.mNextHop;
out << " recvd: " << now-route.mReceived;

View file

@ -105,8 +105,8 @@ virtual int getDsdvEntry(const std::string &hash, RsDsdvTableEntry &entry);
std::map<std::string, RsDsdvTableEntry> mTable;
time_t mSentTablesTime;
time_t mSentIncrementTime;
rstime_t mSentTablesTime;
rstime_t mSentIncrementTime;
bool mSignificantChanges;

View file

@ -43,7 +43,7 @@
#include "util/rsdebug.h"
#include "util/rsstring.h"
#include <time.h>
#include "util/rstime.h"
const int pqiarchivezone = 9326;

View file

@ -57,8 +57,8 @@ class RsDsdvRoute
RsPeerId mNextHop;
uint32_t mSequence;
uint32_t mDistance;
time_t mReceived;
time_t mValidSince;
rstime_t mReceived;
rstime_t mValidSince;
};