mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-12 07:16:19 -05:00
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:
parent
41aa675a9b
commit
329050a9c2
223 changed files with 930 additions and 911 deletions
|
|
@ -48,7 +48,7 @@ void handleQuery(CacheStrapper *csp, RsPeerId pid,
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
time_t period = 11;
|
||||
rstime_t period = 11;
|
||||
RsPeerId pid1("0x0101");
|
||||
RsPeerId pid2("0x0102");
|
||||
RsPeerId pid3("0x0103");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include "dbase/findex.h"
|
||||
#include <iostream>
|
||||
|
||||
FileIndex *createBasicFileIndex(time_t age);
|
||||
FileIndex *createBasicFileIndex(rstime_t age);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -54,7 +54,7 @@ int main()
|
|||
}
|
||||
|
||||
|
||||
FileIndex *createBasicFileIndex(time_t age)
|
||||
FileIndex *createBasicFileIndex(rstime_t age)
|
||||
{
|
||||
FileIndex *fi = new FileIndex("A SILLY ID");
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
FileIndex *createBasicFileIndex(time_t age);
|
||||
FileIndex *createBasicFileIndex(rstime_t age);
|
||||
|
||||
int test1(FileIndex *fi);
|
||||
int test2(FileIndex *fi);
|
||||
|
|
@ -44,7 +44,7 @@ int main()
|
|||
int test1(FileIndex *fi)
|
||||
{
|
||||
/* in this test we are going to get the old directories - and update them */
|
||||
time_t stamp = 200;
|
||||
rstime_t stamp = 200;
|
||||
|
||||
DirEntry *olddir = NULL;
|
||||
FileEntry fe;
|
||||
|
|
@ -92,7 +92,7 @@ int test1(FileIndex *fi)
|
|||
int test2(FileIndex *fi)
|
||||
{
|
||||
/* in this test we are going to simulate that 2 directories have disappeared */
|
||||
time_t stamp = 200;
|
||||
rstime_t stamp = 200;
|
||||
|
||||
DirEntry *olddir = NULL;
|
||||
FileEntry fe;
|
||||
|
|
@ -154,7 +154,7 @@ int test2(FileIndex *fi)
|
|||
|
||||
|
||||
|
||||
FileIndex *createBasicFileIndex(time_t age)
|
||||
FileIndex *createBasicFileIndex(rstime_t age)
|
||||
{
|
||||
FileIndex *fi = new FileIndex("A SILLY ID");
|
||||
|
||||
|
|
|
|||
|
|
@ -338,10 +338,10 @@ void *do_server_test_thread(void *data)
|
|||
/************************* TEST 1 **********************
|
||||
* Check that the extra List has been processed.
|
||||
*/
|
||||
time_t start = time(NULL);
|
||||
rstime_t start = time(NULL);
|
||||
|
||||
FileInfo info, info2;
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
std::list<std::string>::iterator eit;
|
||||
for(eit = mFt->extraList.begin(); eit != mFt->extraList.end(); eit++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -368,10 +368,10 @@ void *do_server_test_thread(void *data)
|
|||
/************************* TEST 1 **********************
|
||||
* Check that the extra List has been processed.
|
||||
*/
|
||||
time_t start = time(NULL);
|
||||
rstime_t start = time(NULL);
|
||||
|
||||
FileInfo info, info2;
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
std::list<std::string>::iterator eit;
|
||||
for(eit = mFt->extraList.begin(); eit != mFt->extraList.end(); eit++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ INITTEST();
|
|||
void *do_server_test_thread(void *data)
|
||||
{
|
||||
TestData *mFt = (TestData *) data;
|
||||
time_t startTS = time(NULL);
|
||||
rstime_t startTS = time(NULL);
|
||||
|
||||
std::cerr << "do_server_test_thread() running";
|
||||
std::cerr << std::endl;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ GenExchangeTest::~GenExchangeTest()
|
|||
void GenExchangeTest::pollForToken(uint32_t token, const RsTokReqOptions &opts, bool fill)
|
||||
{
|
||||
double timeDelta = 0.2;
|
||||
time_t now = time(NULL);
|
||||
time_t stopw = now + mPollingTO;
|
||||
rstime_t now = time(NULL);
|
||||
rstime_t stopw = now + mPollingTO;
|
||||
|
||||
while(now < stopw)
|
||||
{
|
||||
|
|
@ -84,8 +84,8 @@ bool GenExchangeTest::pollForMsgAcknowledgement(uint32_t token,
|
|||
{
|
||||
double timeDelta = 0.2;
|
||||
|
||||
time_t now = time(NULL);
|
||||
time_t stopw = now + mPollingTO;
|
||||
rstime_t now = time(NULL);
|
||||
rstime_t stopw = now + mPollingTO;
|
||||
|
||||
while(now < stopw)
|
||||
{
|
||||
|
|
@ -123,8 +123,8 @@ bool GenExchangeTest::pollForGrpAcknowledgement(uint32_t token,
|
|||
RsGxsGroupId& grpId)
|
||||
{
|
||||
double timeDelta = 0.2;
|
||||
time_t now = time(NULL);
|
||||
time_t stopw = now + mPollingTO;
|
||||
rstime_t now = time(NULL);
|
||||
rstime_t stopw = now + mPollingTO;
|
||||
while(now < stopw)
|
||||
{
|
||||
#ifndef WINDOWS_SYS
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ std::list<uint32_t> testResetState[NUM_CONN_MAX];
|
|||
std::list<uint32_t> testResetTimes[NUM_CONN_MAX];
|
||||
|
||||
uint32_t testConnectAction[NUM_CONN_MAX] = { 0 };
|
||||
time_t testConnectPeriod[NUM_CONN_MAX] = { 0 };
|
||||
rstime_t testConnectPeriod[NUM_CONN_MAX] = { 0 };
|
||||
|
||||
uint32_t defTestConnectAction = TST_ACTION_FAILED;
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ testConnect::~testConnect()
|
|||
int testConnect::connect(struct sockaddr_in raddr)
|
||||
{
|
||||
int cidx = findWhichConnect(this);
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
testConnectState[cidx] |= TST_STATE_CONNECT;
|
||||
testConnectTimes[cidx].push_back(now);
|
||||
|
|
@ -162,7 +162,7 @@ int testConnect::stoplistening()
|
|||
int testConnect::reset()
|
||||
{
|
||||
int cidx = findWhichConnect(this);
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
// reset everything except listening.
|
||||
testResetState[cidx].push_back(testConnectState[cidx]);
|
||||
|
|
@ -235,8 +235,8 @@ int testConnect::tick()
|
|||
|
||||
if (testConnectState[cidx] & TST_STATE_CONNECT)
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
time_t cTime = testConnectTimes[cidx].back();
|
||||
rstime_t now = time(NULL);
|
||||
rstime_t cTime = testConnectTimes[cidx].back();
|
||||
if (now - cTime > testConnectPeriod[cidx])
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ std::string peerIds[NumOfPeers] =
|
|||
#define STUN_PORT 7777
|
||||
|
||||
std::string ownId = "OWNID-AAAA";
|
||||
time_t ownPublishTs;
|
||||
rstime_t ownPublishTs;
|
||||
|
||||
RsMutex frmMtx;
|
||||
std::list<std::string> searchIds;
|
||||
|
|
@ -85,7 +85,7 @@ void respondPublish()
|
|||
void respondSearch(p3DhtMgr *mgr, std::string id, uint32_t mode)
|
||||
{
|
||||
std::cerr << "Checking for Search Results" << std::endl;
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
bool doNotify = false;
|
||||
bool doOnline = false;
|
||||
std::string notifyId;
|
||||
|
|
@ -268,7 +268,7 @@ virtual void loadConfiguration()
|
|||
|
||||
int main()
|
||||
{
|
||||
time_t startTime = time(NULL);
|
||||
rstime_t startTime = time(NULL);
|
||||
/* setup system */
|
||||
initTestData();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ std::string peerIds[NumOfPeers] =
|
|||
"PEER10"};
|
||||
|
||||
std::string ownId = "AAAA";
|
||||
time_t ownPublishTs;
|
||||
rstime_t ownPublishTs;
|
||||
|
||||
RsMutex frmMtx;
|
||||
std::list<std::string> searchIds;
|
||||
|
|
@ -78,7 +78,7 @@ void respondPublish()
|
|||
void respondSearch(p3DhtMgr *mgr, std::string id, uint32_t mode)
|
||||
{
|
||||
std::cerr << "Checking for Search Results" << std::endl;
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
bool doNotify = false;
|
||||
bool doOnline = false;
|
||||
std::string notifyId;
|
||||
|
|
@ -205,7 +205,7 @@ virtual bool dhtSearch(std::string id, uint32_t mode)
|
|||
|
||||
int main()
|
||||
{
|
||||
time_t startTime = time(NULL);
|
||||
rstime_t startTime = time(NULL);
|
||||
bool haveOwnAddress = false;
|
||||
/* setup system */
|
||||
initTestData();
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ INITTEST();
|
|||
#define MAX_TIME_SHORT_TEST 10
|
||||
#define MAX_TIME_BASIC_TEST 60
|
||||
|
||||
int run_connect_test(time_t timeout);
|
||||
int run_connect_test(rstime_t timeout);
|
||||
|
||||
/*******************************************************
|
||||
*
|
||||
|
|
@ -133,7 +133,7 @@ int main(int argc, char **argv)
|
|||
REPORT("p3connmgr_connect_test() SINGLE PEER - NO Addresses");
|
||||
/* second test, add addresses for peer */
|
||||
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
pqiIpAddrSet peer1_tst2_addrs;
|
||||
pqiIpAddress paddr;
|
||||
|
|
@ -176,10 +176,10 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
/* Generic restart test */
|
||||
int run_connect_test(time_t timeout)
|
||||
int run_connect_test(rstime_t timeout)
|
||||
{
|
||||
/* tick */
|
||||
time_t start = time(NULL);
|
||||
rstime_t start = time(NULL);
|
||||
bool extAddr = false;
|
||||
|
||||
while ((start > time(NULL) - timeout) && (!extAddr))
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ INITTEST();
|
|||
#define RESTART_EXPECT_UPNP_ADDR 3
|
||||
#define RESTART_EXPECT_DHT_ADDR 4
|
||||
|
||||
int test_p3connmgr_restart_test(uint32_t expectState, time_t timeout);
|
||||
int test_p3connmgr_restart_test(uint32_t expectState, rstime_t timeout);
|
||||
|
||||
|
||||
#define RESET_VIA_LOCAL_ADDR 1
|
||||
|
|
@ -235,7 +235,7 @@ int force_reset(uint32_t method)
|
|||
}
|
||||
|
||||
/* Generic restart test */
|
||||
int test_p3connmgr_restart_test(uint32_t expectState, time_t timeout)
|
||||
int test_p3connmgr_restart_test(uint32_t expectState, rstime_t timeout)
|
||||
{
|
||||
/* force reset network */
|
||||
struct sockaddr_in tst_addr;
|
||||
|
|
@ -245,7 +245,7 @@ int test_p3connmgr_restart_test(uint32_t expectState, time_t timeout)
|
|||
mConnMgr->setLocalAddress(AuthSSL::getAuthSSL()->OwnId(), tst_addr);
|
||||
|
||||
/* tick */
|
||||
time_t start = time(NULL);
|
||||
rstime_t start = time(NULL);
|
||||
bool extAddr = false;
|
||||
|
||||
while ((start > time(NULL) - timeout) && (!extAddr))
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ bool test_addr_list()
|
|||
const uint32_t expectedListSize = 4;
|
||||
CHECK(list.mAddrs.size() == expectedListSize);
|
||||
|
||||
time_t min_time = time(NULL) - expectedListSize + 100;
|
||||
rstime_t min_time = time(NULL) - expectedListSize + 100;
|
||||
|
||||
/* expect the most recent ones to appear */
|
||||
std::list<pqiIpAddress>::iterator it;
|
||||
|
|
|
|||
|
|
@ -133,10 +133,10 @@ int main()
|
|||
{
|
||||
pqiQoS qos(nb_levels,alpha) ;
|
||||
|
||||
static const time_t duration = 60 ;
|
||||
static const rstime_t duration = 60 ;
|
||||
static const int average_packet_load = 10000 ;
|
||||
time_t start = time(NULL) ;
|
||||
time_t now ;
|
||||
rstime_t start = time(NULL) ;
|
||||
rstime_t now ;
|
||||
|
||||
while( (now = time(NULL)) < duration+start )
|
||||
{
|
||||
|
|
@ -175,7 +175,7 @@ int main()
|
|||
}
|
||||
|
||||
// print some info
|
||||
static time_t last = 0 ;
|
||||
static rstime_t last = 0 ;
|
||||
if(now > last)
|
||||
{
|
||||
qos.print() ;
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ testConnect::~testConnect()
|
|||
int testConnect::connect(struct sockaddr_in raddr)
|
||||
{
|
||||
int cidx = findWhichConnect(this);
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
testConnectState[cidx] |= TST_STATE_CONNECT;
|
||||
testConnectTimes[cidx].push_back(now);
|
||||
|
|
@ -148,7 +148,7 @@ int testConnect::stoplistening()
|
|||
int testConnect::reset()
|
||||
{
|
||||
int cidx = findWhichConnect(this);
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
// reset everything except listening.
|
||||
testResetState[cidx].push_back(testConnectState[cidx]);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include "serialiser/rsdistribitems.h"
|
||||
#include "serialiser/rschannelitems.h"
|
||||
#include "serialiser/rsforumitems.h"
|
||||
|
|
@ -46,7 +46,7 @@ INITTEST()
|
|||
RsSerialType* init_item(RsDistribGrp& grp)
|
||||
{
|
||||
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
/* create Keys */
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
* many deserialisation as possible.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
|
@ -74,8 +74,8 @@ int main()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
time_t startTs = time(NULL);
|
||||
time_t endTs = startTs + TEST_LENGTH;
|
||||
rstime_t startTs = time(NULL);
|
||||
rstime_t endTs = startTs + TEST_LENGTH;
|
||||
|
||||
srand(startTs);
|
||||
for(i = 0; i < dsize; i++)
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ int main(int argc, char **argv)
|
|||
bdnet_fcntl(0, F_SETFL, O_NONBLOCK);
|
||||
bdnet_fcntl(1,F_SETFL,O_NONBLOCK);
|
||||
|
||||
time_t lastRead = time(NULL);
|
||||
rstime_t lastRead = time(NULL);
|
||||
bool doneWrite = false;
|
||||
bool doneRead = false;
|
||||
bool blockread = false;
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ int main(int argc, char **argv)
|
|||
bdnet_fcntl(0, F_SETFL, O_NONBLOCK);
|
||||
bdnet_fcntl(1,F_SETFL,O_NONBLOCK);
|
||||
|
||||
time_t lastRead = time(NULL);
|
||||
rstime_t lastRead = time(NULL);
|
||||
bool doneWrite = false;
|
||||
bool doneRead = false;
|
||||
bool blockread = false;
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ int main(int argc, char **argv)
|
|||
bdnet_fcntl(0, F_SETFL, O_NONBLOCK);
|
||||
bdnet_fcntl(1,F_SETFL,O_NONBLOCK);
|
||||
|
||||
time_t lastRead = time(NULL);
|
||||
rstime_t lastRead = time(NULL);
|
||||
bool doneWrite = false;
|
||||
bool doneRead = false;
|
||||
bool blockread = false;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include <iostream>
|
||||
#include <memory.h>
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
#include "retrodb.h"
|
||||
#include "utest.h"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include <iostream>
|
||||
#include <memory.h>
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
#include "retrodb.h"
|
||||
#include "utest.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue