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

@ -40,16 +40,16 @@
//#define DEBUG_CHAT_LOBBIES 1 //#define DEBUG_CHAT_LOBBIES 1
static const int CONNECTION_CHALLENGE_MAX_COUNT = 20 ; // sends a connection challenge every 20 messages static const int CONNECTION_CHALLENGE_MAX_COUNT = 20 ; // sends a connection challenge every 20 messages
static const time_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age of a message to be used in a connection challenge static const rstime_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age of a message to be used in a connection challenge
static const int CONNECTION_CHALLENGE_MIN_DELAY = 15 ; // sends a connection at most every 15 seconds static const int CONNECTION_CHALLENGE_MIN_DELAY = 15 ; // sends a connection at most every 15 seconds
static const int LOBBY_CACHE_CLEANING_PERIOD = 10 ; // clean lobby caches every 10 secs (remove old messages) static const int LOBBY_CACHE_CLEANING_PERIOD = 10 ; // clean lobby caches every 10 secs (remove old messages)
static const time_t MAX_KEEP_MSG_RECORD = 1200 ; // keep msg record for 1200 secs max. static const rstime_t MAX_KEEP_MSG_RECORD = 1200 ; // keep msg record for 1200 secs max.
static const time_t MAX_KEEP_INACTIVE_NICKNAME = 180 ; // keep inactive nicknames for 3 mn max. static const rstime_t MAX_KEEP_INACTIVE_NICKNAME = 180 ; // keep inactive nicknames for 3 mn max.
static const time_t MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE = 120 ; // send keep alive packet every 2 minutes. static const rstime_t MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE = 120 ; // send keep alive packet every 2 minutes.
static const time_t MAX_KEEP_PUBLIC_LOBBY_RECORD = 60 ; // keep inactive lobbies records for 60 secs max. static const rstime_t MAX_KEEP_PUBLIC_LOBBY_RECORD = 60 ; // keep inactive lobbies records for 60 secs max.
static const time_t MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ = 20 ; // don't ask for lobby list more than once every 30 secs. static const rstime_t MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ = 20 ; // don't ask for lobby list more than once every 30 secs.
static const time_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly ask for available lobbies every 5 minutes, to allow auto-subscribe to work static const rstime_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly ask for available lobbies every 5 minutes, to allow auto-subscribe to work
static const uint32_t MAX_ALLOWED_LOBBIES_IN_LIST_WARNING = 50 ; static const uint32_t MAX_ALLOWED_LOBBIES_IN_LIST_WARNING = 50 ;
//static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number of messages from a given peer in a window for duration below //static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number of messages from a given peer in a window for duration below
@ -71,10 +71,10 @@ DistributedChatService::DistributedChatService(uint32_t serv_type,p3ServiceContr
void DistributedChatService::flush() void DistributedChatService::flush()
{ {
static time_t last_clean_time_lobby = 0 ; static rstime_t last_clean_time_lobby = 0 ;
static time_t last_req_chat_lobby_list = 0 ; static rstime_t last_req_chat_lobby_list = 0 ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(last_clean_time_lobby + LOBBY_CACHE_CLEANING_PERIOD < now) if(last_clean_time_lobby + LOBBY_CACHE_CLEANING_PERIOD < now)
{ {
@ -117,19 +117,19 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
if(cli == NULL) if(cli == NULL)
return true ; // the item is handled correctly if it's not a lobby item ;-) return true ; // the item is handled correctly if it's not a lobby item ;-)
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(now+100 > (time_t) cli->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep plus 100 seconds ! It's too old, and is going to make an echo! if(now+100 > (rstime_t) cli->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep plus 100 seconds ! It's too old, and is going to make an echo!
{ {
std::cerr << "Received severely outdated lobby event item (" << now - (time_t)cli->sendTime << " in the past)! Dropping it!" << std::endl; std::cerr << "Received severely outdated lobby event item (" << now - (rstime_t)cli->sendTime << " in the past)! Dropping it!" << std::endl;
std::cerr << "Message item is:" << std::endl; std::cerr << "Message item is:" << std::endl;
cli->print(std::cerr) ; cli->print(std::cerr) ;
std::cerr << std::endl; std::cerr << std::endl;
return false ; return false ;
} }
if(now+600 < (time_t) cli->sendTime) // the message is from the future. Drop it. more than 10 minutes if(now+600 < (rstime_t) cli->sendTime) // the message is from the future. Drop it. more than 10 minutes
{ {
std::cerr << "Received event item from the future (" << (time_t)cli->sendTime - now << " seconds in the future)! Dropping it!" << std::endl; std::cerr << "Received event item from the future (" << (rstime_t)cli->sendTime - now << " seconds in the future)! Dropping it!" << std::endl;
std::cerr << "Message item is:" << std::endl; std::cerr << "Message item is:" << std::endl;
cli->print(std::cerr) ; cli->print(std::cerr) ;
std::cerr << std::endl; std::cerr << std::endl;
@ -292,7 +292,7 @@ bool DistributedChatService::getVirtualPeerId(const ChatLobbyId& id,ChatLobbyVir
void DistributedChatService::locked_printDebugInfo() const void DistributedChatService::locked_printDebugInfo() const
{ {
std::cerr << "Recorded lobbies: " << std::endl; std::cerr << "Recorded lobbies: " << std::endl;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for( std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin()) ;it!=_chat_lobbys.end();++it) for( std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin()) ;it!=_chat_lobbys.end();++it)
{ {
@ -307,7 +307,7 @@ void DistributedChatService::locked_printDebugInfo() const
std::cerr << " Last activity\t: " << now - it->second.last_activity << " seconds ago." << std::endl; std::cerr << " Last activity\t: " << now - it->second.last_activity << " seconds ago." << std::endl;
std::cerr << " Cached messages\t: " << it->second.msg_cache.size() << std::endl; std::cerr << " Cached messages\t: " << it->second.msg_cache.size() << std::endl;
for(std::map<ChatLobbyMsgId,time_t>::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2) for(std::map<ChatLobbyMsgId,rstime_t>::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2)
std::cerr << " " << std::hex << it2->first << std::dec << " time=" << now - it2->second << " secs ago" << std::endl; std::cerr << " " << std::hex << it2->first << std::dec << " time=" << now - it2->second << " secs ago" << std::endl;
std::cerr << " Participating friends: " << std::endl; std::cerr << " Participating friends: " << std::endl;
@ -317,7 +317,7 @@ void DistributedChatService::locked_printDebugInfo() const
std::cerr << " Participating nick names: " << std::endl; std::cerr << " Participating nick names: " << std::endl;
for(std::map<RsGxsId,time_t>::const_iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();++it2) for(std::map<RsGxsId,rstime_t>::const_iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();++it2)
std::cerr << " " << it2->first << ": " << now - it2->second << " secs ago" << std::endl; std::cerr << " " << it2->first << ": " << now - it2->second << " secs ago" << std::endl;
} }
@ -339,7 +339,7 @@ void DistributedChatService::locked_printDebugInfo() const
bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObject *obj,const RsPeerId& peer_id,uint32_t lobby_count) bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObject *obj,const RsPeerId& peer_id,uint32_t lobby_count)
{ {
static std::map<std::string, std::list<time_t> > message_counts ; static std::map<std::string, std::list<rstime_t> > message_counts ;
std::ostringstream os ; std::ostringstream os ;
os << obj->lobby_id ; os << obj->lobby_id ;
@ -375,14 +375,14 @@ bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObjec
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << "lobby_count=" << lobby_count << std::endl; std::cerr << "lobby_count=" << lobby_count << std::endl;
std::cerr << "Got msg for peer " << pid << std::dec << ". Limit is " << max_cnt << ". List is " ; std::cerr << "Got msg for peer " << pid << std::dec << ". Limit is " << max_cnt << ". List is " ;
for(std::list<time_t>::const_iterator it(message_counts[pid].begin());it!=message_counts[pid].end();++it) for(std::list<rstime_t>::const_iterator it(message_counts[pid].begin());it!=message_counts[pid].end();++it)
std::cerr << *it << " " ; std::cerr << *it << " " ;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
std::list<time_t>& lst = message_counts[pid] ; std::list<rstime_t>& lst = message_counts[pid] ;
// Clean old messages time stamps from the list. // Clean old messages time stamps from the list.
// //
@ -501,7 +501,7 @@ void DistributedChatService::handleRecvChatLobbyList(RsChatLobbyListItem *item)
std::cerr << "Received chat lobby list from friend " << item->PeerId() << ", " << item->lobbies.size() << " elements." << std::endl; std::cerr << "Received chat lobby list from friend " << item->PeerId() << ", " << item->lobbies.size() << " elements." << std::endl;
#endif #endif
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
@ -677,7 +677,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << "Received ChatLobbyEvent item of type " << (int)(item->event_type) << ", and string=" << item->string1 << std::endl; std::cerr << "Received ChatLobbyEvent item of type " << (int)(item->event_type) << ", and string=" << item->string1 << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(rsReputations->overallReputationLevel(item->signature.keyId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) if(rsReputations->overallReputationLevel(item->signature.keyId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
{ {
@ -713,17 +713,17 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
} }
addTimeShiftStatistics((int)now - (int)item->sendTime) ; addTimeShiftStatistics((int)now - (int)item->sendTime) ;
if(now+100 > (time_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo! if(now+100 > (rstime_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo!
{ {
std::cerr << "Received severely outdated lobby event item (" << now - (time_t)item->sendTime << " in the past)! Dropping it!" << std::endl; std::cerr << "Received severely outdated lobby event item (" << now - (rstime_t)item->sendTime << " in the past)! Dropping it!" << std::endl;
std::cerr << "Message item is:" << std::endl; std::cerr << "Message item is:" << std::endl;
item->print(std::cerr) ; item->print(std::cerr) ;
std::cerr << std::endl; std::cerr << std::endl;
return ; return ;
} }
if(now+600 < (time_t) item->sendTime) // the message is from the future more than 10 minutes if(now+600 < (rstime_t) item->sendTime) // the message is from the future more than 10 minutes
{ {
std::cerr << "Received event item from the future (" << (time_t)item->sendTime - now << " seconds in the future)! Dropping it!" << std::endl; std::cerr << "Received event item from the future (" << (rstime_t)item->sendTime - now << " seconds in the future)! Dropping it!" << std::endl;
std::cerr << "Message item is:" << std::endl; std::cerr << "Message item is:" << std::endl;
item->print(std::cerr) ; item->print(std::cerr) ;
std::cerr << std::endl; std::cerr << std::endl;
@ -751,7 +751,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
if(it != _chat_lobbys.end()) if(it != _chat_lobbys.end())
{ {
std::map<RsGxsId,time_t>::iterator it2(it->second.gxs_ids.find(item->signature.keyId)) ; std::map<RsGxsId,rstime_t>::iterator it2(it->second.gxs_ids.find(item->signature.keyId)) ;
if(it2 != it->second.gxs_ids.end()) if(it2 != it->second.gxs_ids.end())
{ {
@ -815,7 +815,7 @@ void DistributedChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatL
visible_lobbies.push_back(it->second) ; visible_lobbies.push_back(it->second) ;
} }
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(now > MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ + last_visible_lobby_info_request_time) if(now > MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ + last_visible_lobby_info_request_time)
{ {
@ -843,7 +843,7 @@ void DistributedChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatL
// //
bool DistributedChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const RsPeerId& peer_id) bool DistributedChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const RsPeerId& peer_id)
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
locked_printDebugInfo() ; // debug locked_printDebugInfo() ; // debug
@ -874,7 +874,7 @@ bool DistributedChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,c
// Checks wether the msg is already recorded or not // Checks wether the msg is already recorded or not
std::map<ChatLobbyMsgId,time_t>::iterator it2(lobby.msg_cache.find(item->msg_id)) ; std::map<ChatLobbyMsgId,rstime_t>::iterator it2(lobby.msg_cache.find(item->msg_id)) ;
if(it2 != lobby.msg_cache.end()) // found! if(it2 != lobby.msg_cache.end()) // found!
{ {
@ -1097,7 +1097,7 @@ void DistributedChatService::handleConnectionChallenge(RsChatLobbyConnectChallen
std::cerr << " Peer Id = " << item->PeerId() << std::endl; std::cerr << " Peer Id = " << item->PeerId() << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
ChatLobbyId lobby_id ; ChatLobbyId lobby_id ;
const RsPeerId& ownId = rsPeers->getOwnId(); const RsPeerId& ownId = rsPeers->getOwnId();
@ -1106,7 +1106,7 @@ void DistributedChatService::handleConnectionChallenge(RsChatLobbyConnectChallen
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
for(std::map<ChatLobbyId,ChatLobbyEntry>::iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end() && !found;++it) for(std::map<ChatLobbyId,ChatLobbyEntry>::iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end() && !found;++it)
for(std::map<ChatLobbyMsgId,time_t>::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end() && !found;++it2) for(std::map<ChatLobbyMsgId,rstime_t>::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end() && !found;++it2)
if(it2->second + CONNECTION_CHALLENGE_MAX_MSG_AGE + 5 > now) // any msg not older than 5 seconds plus max challenge count is fine. if(it2->second + CONNECTION_CHALLENGE_MAX_MSG_AGE + 5 > now) // any msg not older than 5 seconds plus max challenge count is fine.
{ {
uint64_t code = makeConnexionChallengeCode(ownId,it->first,it2->first) ; uint64_t code = makeConnexionChallengeCode(ownId,it->first,it2->first) ;
@ -1156,10 +1156,10 @@ void DistributedChatService::sendConnectionChallenge(ChatLobbyId lobby_id)
return ; return ;
} }
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
ChatLobbyMsgId msg_id = 0 ; ChatLobbyMsgId msg_id = 0 ;
for(std::map<ChatLobbyMsgId,time_t>::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2) for(std::map<ChatLobbyMsgId,rstime_t>::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2)
if(it2->second + CONNECTION_CHALLENGE_MAX_MSG_AGE > now) // any msg not older than 20 seconds is fine. if(it2->second + CONNECTION_CHALLENGE_MAX_MSG_AGE > now) // any msg not older than 20 seconds is fine.
{ {
msg_id = it2->first ; msg_id = it2->first ;
@ -1431,7 +1431,7 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id,const
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Creating new Lobby entry." << std::endl; std::cerr << " Creating new Lobby entry." << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
ChatLobbyEntry entry ; ChatLobbyEntry entry ;
entry.participating_friends.insert(it->second.peer_id) ; entry.participating_friends.insert(it->second.peer_id) ;
@ -1555,7 +1555,7 @@ bool DistributedChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id,co
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Creating new lobby entry." << std::endl; std::cerr << " Creating new lobby entry." << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
ChatLobbyEntry entry ; ChatLobbyEntry entry ;
@ -1604,7 +1604,7 @@ ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_nam
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << " New (unique) ID: " << std::hex << lobby_id << std::dec << std::endl; std::cerr << " New (unique) ID: " << std::hex << lobby_id << std::dec << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
ChatLobbyEntry entry ; ChatLobbyEntry entry ;
entry.lobby_flags = lobby_flags ; entry.lobby_flags = lobby_flags ;
@ -1859,20 +1859,20 @@ void DistributedChatService::cleanLobbyCaches()
{ {
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
// 1 - clean cache of all lobbies and participating nicknames. // 1 - clean cache of all lobbies and participating nicknames.
// //
for(std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.begin();it!=_chat_lobbys.end();++it) for(std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.begin();it!=_chat_lobbys.end();++it)
{ {
for(std::map<ChatLobbyMsgId,time_t>::iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();) for(std::map<ChatLobbyMsgId,rstime_t>::iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();)
if(it2->second + MAX_KEEP_MSG_RECORD < now) if(it2->second + MAX_KEEP_MSG_RECORD < now)
{ {
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << " removing old msg 0x" << std::hex << it2->first << ", time=" << std::dec << now - it2->second << " secs ago" << std::endl; std::cerr << " removing old msg 0x" << std::hex << it2->first << ", time=" << std::dec << now - it2->second << " secs ago" << std::endl;
#endif #endif
std::map<ChatLobbyMsgId,time_t>::iterator tmp(it2) ; std::map<ChatLobbyMsgId,rstime_t>::iterator tmp(it2) ;
++tmp ; ++tmp ;
it->second.msg_cache.erase(it2) ; it->second.msg_cache.erase(it2) ;
it2 = tmp ; it2 = tmp ;
@ -1882,14 +1882,14 @@ void DistributedChatService::cleanLobbyCaches()
bool changed = false ; bool changed = false ;
for(std::map<RsGxsId,time_t>::iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();) for(std::map<RsGxsId,rstime_t>::iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();)
if(it2->second + MAX_KEEP_INACTIVE_NICKNAME < now) if(it2->second + MAX_KEEP_INACTIVE_NICKNAME < now)
{ {
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << " removing inactive nickname 0x" << std::hex << it2->first << ", time=" << std::dec << now - it2->second << " secs ago" << std::endl; std::cerr << " removing inactive nickname 0x" << std::hex << it2->first << ", time=" << std::dec << now - it2->second << " secs ago" << std::endl;
#endif #endif
std::map<RsGxsId,time_t>::iterator tmp(it2) ; std::map<RsGxsId,rstime_t>::iterator tmp(it2) ;
++tmp ; ++tmp ;
it->second.gxs_ids.erase(it2) ; it->second.gxs_ids.erase(it2) ;
it2 = tmp ; it2 = tmp ;

View File

@ -135,11 +135,11 @@ class DistributedChatService
class ChatLobbyEntry: public ChatLobbyInfo class ChatLobbyEntry: public ChatLobbyInfo
{ {
public: public:
std::map<ChatLobbyMsgId,time_t> msg_cache ; std::map<ChatLobbyMsgId,rstime_t> msg_cache ;
RsPeerId virtual_peer_id ; RsPeerId virtual_peer_id ;
int connexion_challenge_count ; int connexion_challenge_count ;
time_t last_connexion_challenge_time ; rstime_t last_connexion_challenge_time ;
time_t last_keep_alive_packet_time ; rstime_t last_keep_alive_packet_time ;
std::set<RsPeerId> previously_known_peers ; std::set<RsPeerId> previously_known_peers ;
}; };
@ -152,8 +152,8 @@ class DistributedChatService
// RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE // RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE
float _time_shift_average ; float _time_shift_average ;
time_t last_lobby_challenge_time ; // prevents bruteforce attack rstime_t last_lobby_challenge_time ; // prevents bruteforce attack
time_t last_visible_lobby_info_request_time ; // allows to ask for updates rstime_t last_visible_lobby_info_request_time ; // allows to ask for updates
bool _should_reset_lobby_counts ; bool _should_reset_lobby_counts ;
RsGxsId _default_identity; RsGxsId _default_identity;
std::map<ChatLobbyId,RsGxsId> _lobby_default_identity; std::map<ChatLobbyId,RsGxsId> _lobby_default_identity;

View File

@ -521,12 +521,12 @@ class MsgCounter
public: public:
MsgCounter() {} MsgCounter() {}
void clean(time_t max_time) void clean(rstime_t max_time)
{ {
while(!recv_times.empty() && recv_times.front() < max_time) while(!recv_times.empty() && recv_times.front() < max_time)
recv_times.pop_front() ; recv_times.pop_front() ;
} }
std::list<time_t> recv_times ; std::list<rstime_t> recv_times ;
}; };
void p3ChatService::handleIncomingItem(RsItem *item) void p3ChatService::handleIncomingItem(RsItem *item)

View File

@ -21,7 +21,7 @@
*******************************************************************************/ *******************************************************************************/
#include <stdexcept> #include <stdexcept>
#include <time.h> #include "util/rstime.h"
#include "serialiser/rsbaseserial.h" #include "serialiser/rsbaseserial.h"
#include "serialiser/rstlvbase.h" #include "serialiser/rstlvbase.h"

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <ctime> #include "util/rstime.h"
#include <vector> #include <vector>
#include <xapian.h> #include <xapian.h>
@ -261,7 +261,7 @@ private:
return dbDir; return dbDir;
} }
static std::string timetToXapianDate(const time_t& time) static std::string timetToXapianDate(const rstime_t& time)
{ {
char date[] = "YYYYMMDD\0"; char date[] = "YYYYMMDD\0";
std::strftime(date, 9, "%Y%m%d", std::gmtime(&time)); std::strftime(date, 9, "%Y%m%d", std::gmtime(&time));

View File

@ -80,7 +80,7 @@
PeerConnectStateBox::PeerConnectStateBox() PeerConnectStateBox::PeerConnectStateBox()
{ {
//mPeerId = id; //mPeerId = id;
time_t now = time(NULL); rstime_t now = time(NULL);
mState = CSB_START; mState = CSB_START;
mNetState = CSB_NETSTATE_UNKNOWN; mNetState = CSB_NETSTATE_UNKNOWN;
mStateTS = now; mStateTS = now;
@ -241,7 +241,7 @@ void PeerConnectStateBox::stateMsg(std::ostream &out, std::string msg, uint32_t
std::string PeerConnectStateBox::connectState() const std::string PeerConnectStateBox::connectState() const
{ {
std::string str = StateAsString(mState); std::string str = StateAsString(mState);
time_t now = time(NULL); rstime_t now = time(NULL);
std::string out; std::string out;
rs_sprintf(out, "%s(%lu/%lu) for %ld secs", str.c_str(), mNoAttempts, mNoFailedAttempts, now - mStateTS); rs_sprintf(out, "%s(%lu/%lu) for %ld secs", str.c_str(), mNoAttempts, mNoFailedAttempts, now - mStateTS);
if ( (mState == CSB_CONNECTED) || (mState == CSB_DIRECT_ATTEMPT) || if ( (mState == CSB_CONNECTED) || (mState == CSB_DIRECT_ATTEMPT) ||
@ -358,7 +358,7 @@ uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, uint32_t netmode, uint3
uint32_t PeerConnectStateBox::connectCb_direct() uint32_t PeerConnectStateBox::connectCb_direct()
{ {
uint32_t retval = 0; uint32_t retval = 0;
time_t now = time(NULL); rstime_t now = time(NULL);
switch(mState) switch(mState)
{ {
@ -497,7 +497,7 @@ uint32_t PeerConnectStateBox::connectCb_unreachable()
proxyPortMode = CSB_ACTION_DHT_PORT; proxyPortMode = CSB_ACTION_DHT_PORT;
} }
time_t now = time(NULL); rstime_t now = time(NULL);
switch(mState) switch(mState)
{ {
@ -782,7 +782,7 @@ uint32_t PeerConnectStateBox::updateCb(uint32_t update)
*/ */
/* DO Connect / Disconnect Updates ... very specific! */ /* DO Connect / Disconnect Updates ... very specific! */
time_t now = time(NULL); rstime_t now = time(NULL);
switch(update) switch(update)
{ {
case CSB_UPDATE_CONNECTED: case CSB_UPDATE_CONNECTED:
@ -1035,7 +1035,7 @@ bool PeerConnectStateBox::storeProxyPortChoice(uint32_t flags, bool useProxyPort
bool PeerConnectStateBox::getProxyPortChoice() bool PeerConnectStateBox::getProxyPortChoice()
{ {
#ifdef DEBUG_CONNECTBOX #ifdef DEBUG_CONNECTBOX
time_t now = time(NULL); rstime_t now = time(NULL);
std::cerr << "PeerConnectStateBox::getProxyPortChoice() Using ConnectLogic Info from: "; std::cerr << "PeerConnectStateBox::getProxyPortChoice() Using ConnectLogic Info from: ";
std::cerr << now-mProxyPortTS << " ago. Flags: " << mProxyPortFlags; std::cerr << now-mProxyPortTS << " ago. Flags: " << mProxyPortFlags;

View File

@ -72,7 +72,7 @@
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include "util/rstime.h"
#include <inttypes.h> #include <inttypes.h>
class PeerConnectStateBox class PeerConnectStateBox
@ -104,16 +104,16 @@ class PeerConnectStateBox
uint32_t mState; uint32_t mState;
uint32_t mNetState; uint32_t mNetState;
time_t mStateTS; rstime_t mStateTS;
uint32_t mNoAttempts; uint32_t mNoAttempts;
uint32_t mNoFailedAttempts; uint32_t mNoFailedAttempts;
time_t mNextAttemptTS; rstime_t mNextAttemptTS;
time_t mAttemptLength; rstime_t mAttemptLength;
// ProxyPort Storage. // ProxyPort Storage.
uint32_t mProxyPortFlags; uint32_t mProxyPortFlags;
bool mProxyPortChoice; bool mProxyPortChoice;
time_t mProxyPortTS; rstime_t mProxyPortTS;
}; };

View File

@ -52,7 +52,7 @@ class DhtPeerDetails
/* direct from the DHT! */ /* direct from the DHT! */
uint32_t mDhtState; // One of RSDHT_PEERDHT_[...] uint32_t mDhtState; // One of RSDHT_PEERDHT_[...]
time_t mDhtUpdateTS; rstime_t mDhtUpdateTS;
/* internal state */ /* internal state */
PeerConnectStateBox mConnectLogic; PeerConnectStateBox mConnectLogic;
@ -66,9 +66,9 @@ class DhtPeerDetails
struct sockaddr_in mPeerConnectAddr; struct sockaddr_in mPeerConnectAddr;
uint32_t mPeerConnectPoint; uint32_t mPeerConnectPoint;
time_t mPeerConnectUdpTS; rstime_t mPeerConnectUdpTS;
time_t mPeerConnectTS; rstime_t mPeerConnectTS;
time_t mPeerConnectClosedTS; rstime_t mPeerConnectClosedTS;
bool mExclusiveProxyLock; bool mExclusiveProxyLock;
@ -80,7 +80,7 @@ class DhtPeerDetails
uint32_t mPeerReqState; uint32_t mPeerReqState;
uint32_t mPeerReqMode; uint32_t mPeerReqMode;
bdId mPeerReqProxyId; bdId mPeerReqProxyId;
time_t mPeerReqTS; rstime_t mPeerReqTS;
/* Callback Info */ /* Callback Info */
std::string mPeerCbMsg; std::string mPeerCbMsg;
@ -88,7 +88,7 @@ class DhtPeerDetails
uint32_t mPeerCbPoint; uint32_t mPeerCbPoint;
bdId mPeerCbProxyId; bdId mPeerCbProxyId;
bdId mPeerCbDestId; bdId mPeerCbDestId;
time_t mPeerCbTS; rstime_t mPeerCbTS;
}; };
@ -331,7 +331,7 @@ private:
float mDhtReadRate; float mDhtReadRate;
float mDhtWriteRate; float mDhtWriteRate;
time_t mLastDataRateUpdate; rstime_t mLastDataRateUpdate;
/*********************************************************************************************** /***********************************************************************************************
@ -380,7 +380,7 @@ private:
RsPeerId mOwnRsId; RsPeerId mOwnRsId;
bdNodeId mOwnDhtId; bdNodeId mOwnDhtId;
time_t mMinuteTS; rstime_t mMinuteTS;
/* translation maps */ /* translation maps */
std::map<RsPeerId, bdNodeId> mTransToNodeId; std::map<RsPeerId, bdNodeId> mTransToNodeId;

View File

@ -204,7 +204,7 @@ void p3BitDht::updateDataRates()
RsStackMutex stack(dhtMtx); /********* LOCKED *********/ RsStackMutex stack(dhtMtx); /********* LOCKED *********/
time_t now = time(NULL); rstime_t now = time(NULL);
float period = now - mLastDataRateUpdate; float period = now - mLastDataRateUpdate;
#define RATE_FACTOR (0.75) #define RATE_FACTOR (0.75)
@ -380,7 +380,7 @@ RsDhtRelayProxy::RsDhtRelayProxy()
mCreateTS = 0; mCreateTS = 0;
//uint32_t mDataSize; //uint32_t mDataSize;
//time_t mLastBandwidthTS; //rstime_t mLastBandwidthTS;
} }

View File

@ -249,7 +249,7 @@ int p3BitDht::PeerCallback(const bdId *id, uint32_t status)
} }
time_t now = time(NULL); rstime_t now = time(NULL);
dpd->mDhtUpdateTS = now; dpd->mDhtUpdateTS = now;
return 1; return 1;
@ -510,7 +510,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
*/ */
bdId peerId; bdId peerId;
time_t now = time(NULL); rstime_t now = time(NULL);
switch(point) switch(point)
{ {
@ -1101,7 +1101,7 @@ int p3BitDht::tick()
minuteTick(); minuteTick();
#ifdef DEBUG_PEERNET_COMMON #ifdef DEBUG_PEERNET_COMMON
time_t now = time(NULL); rstime_t now = time(NULL);
std::cerr << "p3BitDht::tick() TIME: " << ctime(&now) << std::endl; std::cerr << "p3BitDht::tick() TIME: " << ctime(&now) << std::endl;
std::cerr.flush(); std::cerr.flush();
#endif #endif
@ -1114,7 +1114,7 @@ int p3BitDht::tick()
int p3BitDht::minuteTick() int p3BitDht::minuteTick()
{ {
time_t now = time(NULL); rstime_t now = time(NULL);
int deltaT = 0; int deltaT = 0;
{ {
@ -1164,7 +1164,7 @@ int p3BitDht::doActions()
std::cerr << "p3BitDht::doActions()" << std::endl; std::cerr << "p3BitDht::doActions()" << std::endl;
#endif #endif
time_t now = time(NULL); rstime_t now = time(NULL);
while(mActions.size() > 0) while(mActions.size() > 0)
{ {
@ -1727,7 +1727,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
time_t now = time(NULL); rstime_t now = time(NULL);
/* check if they are in our friend list */ /* check if they are in our friend list */
DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId->id), RSDHT_PEERTYPE_FRIEND); DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId->id), RSDHT_PEERTYPE_FRIEND);
@ -2171,7 +2171,7 @@ int p3BitDht::removeRelayConnection(const bdId *srcId, const bdId *destId)
void p3BitDht::monitorConnections() void p3BitDht::monitorConnections()
{ {
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
time_t now = time(NULL); rstime_t now = time(NULL);
std::map<bdNodeId, DhtPeerDetails>::iterator it; std::map<bdNodeId, DhtPeerDetails>::iterator it;

View File

@ -90,10 +90,10 @@ Classes
- std::string name - std::string name
- RsFileHash hash - RsFileHash hash
- uint64_t size - uint64_t size
- time_t Last modification time - rstime_t Last modification time
LocalFileInfo: public FileInfo LocalFileInfo: public FileInfo
- time_t Last data access time - rstime_t Last data access time
- uint64_t Total data uploaded - uint64_t Total data uploaded
- uint32_t ShareFlags - uint32_t ShareFlags

View File

@ -21,7 +21,7 @@
******************************************************************************/ ******************************************************************************/
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <time.h> #include "util/rstime.h"
#include "util/rsdir.h" #include "util/rsdir.h"
#include "util/rsprint.h" #include "util/rsprint.h"
#include "retroshare/rsexpr.h" #include "retroshare/rsexpr.h"
@ -356,7 +356,7 @@ bool InternalFileHierarchyStorage::updateHash(const DirectoryStorage::EntryIndex
return true; return true;
} }
bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const time_t modf_time) bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const rstime_t modf_time)
{ {
if(!checkIndex(file_index,FileStorageNode::TYPE_FILE)) if(!checkIndex(file_index,FileStorageNode::TYPE_FILE))
{ {
@ -427,7 +427,7 @@ DirectoryStorage::EntryIndex InternalFileHierarchyStorage::allocateNewIndex()
return mNodes.size()-1 ; return mNodes.size()-1 ;
} }
bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryIndex& indx,const std::string& dir_name,time_t most_recent_time,time_t dir_modtime,const std::vector<RsFileHash>& subdirs_hash,const std::vector<FileEntry>& subfiles_array) bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryIndex& indx,const std::string& dir_name,rstime_t most_recent_time,rstime_t dir_modtime,const std::vector<RsFileHash>& subdirs_hash,const std::vector<FileEntry>& subfiles_array)
{ {
if(!checkIndex(indx,FileStorageNode::TYPE_DIR)) if(!checkIndex(indx,FileStorageNode::TYPE_DIR))
{ {
@ -599,7 +599,7 @@ void InternalFileHierarchyStorage::getStatistics(SharedDirStats& stats) const
stats.total_shared_size = mTotalSize ; stats.total_shared_size = mTotalSize ;
} }
bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* m) const bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* m) const
{ {
if(!checkIndex(index,FileStorageNode::TYPE_DIR)) if(!checkIndex(index,FileStorageNode::TYPE_DIR))
{ {
@ -614,7 +614,7 @@ bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& ind
return true; return true;
} }
bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* m) bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* m)
{ {
if(!checkIndex(index,FileStorageNode::TYPE_DIR)) if(!checkIndex(index,FileStorageNode::TYPE_DIR))
{ {
@ -631,11 +631,11 @@ bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& ind
// Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method. // Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method.
time_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index,bool& unfinished_files_present) rstime_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index,bool& unfinished_files_present)
{ {
DirEntry& d(*static_cast<DirEntry*>(mNodes[dir_index])) ; DirEntry& d(*static_cast<DirEntry*>(mNodes[dir_index])) ;
time_t largest_modf_time = d.dir_modtime ; rstime_t largest_modf_time = d.dir_modtime ;
unfinished_files_present = false ; unfinished_files_present = false ;
for(uint32_t i=0;i<d.subfiles.size();++i) for(uint32_t i=0;i<d.subfiles.size();++i)
@ -732,7 +732,7 @@ public:
inline virtual const std::string& file_name() const { return mFe.file_name ; } inline virtual const std::string& file_name() const { return mFe.file_name ; }
inline virtual uint64_t file_size() const { return mFe.file_size ; } inline virtual uint64_t file_size() const { return mFe.file_size ; }
inline virtual const RsFileHash& file_hash() const { return mFe.file_hash ; } inline virtual const RsFileHash& file_hash() const { return mFe.file_hash ; }
inline virtual time_t file_modtime() const { return mFe.file_modtime ; } inline virtual rstime_t file_modtime() const { return mFe.file_modtime ; }
inline virtual std::string file_parent_path()const { return RsDirUtil::makePath(mDe.dir_parent_path, mDe.dir_name) ; } inline virtual std::string file_parent_path()const { return RsDirUtil::makePath(mDe.dir_parent_path, mDe.dir_name) ; }
inline virtual uint32_t file_popularity() const { NOT_IMPLEMENTED() ; return 0; } inline virtual uint32_t file_popularity() const { NOT_IMPLEMENTED() ; return 0; }

View File

@ -47,8 +47,8 @@ public:
{ {
public: public:
FileEntry() : file_size(0), file_modtime(0) {} FileEntry() : file_size(0), file_modtime(0) {}
FileEntry(const std::string& name,uint64_t size,time_t modtime) : file_name(name),file_size(size),file_modtime(modtime) {} FileEntry(const std::string& name,uint64_t size,rstime_t modtime) : file_name(name),file_size(size),file_modtime(modtime) {}
FileEntry(const std::string& name,uint64_t size,time_t modtime,const RsFileHash& hash) : file_name(name),file_size(size),file_modtime(modtime),file_hash(hash) {} FileEntry(const std::string& name,uint64_t size,rstime_t modtime,const RsFileHash& hash) : file_name(name),file_size(size),file_modtime(modtime),file_hash(hash) {}
virtual uint32_t type() const { return FileStorageNode::TYPE_FILE ; } virtual uint32_t type() const { return FileStorageNode::TYPE_FILE ; }
virtual ~FileEntry() {} virtual ~FileEntry() {}
@ -56,7 +56,7 @@ public:
// local stuff // local stuff
std::string file_name ; std::string file_name ;
uint64_t file_size ; uint64_t file_size ;
time_t file_modtime; rstime_t file_modtime;
RsFileHash file_hash ; RsFileHash file_hash ;
}; };
@ -76,9 +76,9 @@ public:
std::vector<DirectoryStorage::EntryIndex> subdirs ; std::vector<DirectoryStorage::EntryIndex> subdirs ;
std::vector<DirectoryStorage::EntryIndex> subfiles ; std::vector<DirectoryStorage::EntryIndex> subfiles ;
time_t dir_modtime; rstime_t dir_modtime;
time_t dir_most_recent_time;// recursive most recent modification time, including files and subdirs in the entire hierarchy below. rstime_t dir_most_recent_time;// recursive most recent modification time, including files and subdirs in the entire hierarchy below.
time_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info. rstime_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info.
}; };
// class stuff // class stuff
@ -95,18 +95,18 @@ public:
bool checkIndex(DirectoryStorage::EntryIndex indx,uint8_t type) const; bool checkIndex(DirectoryStorage::EntryIndex indx,uint8_t type) const;
bool updateSubFilesList(const DirectoryStorage::EntryIndex& indx,const std::map<std::string,DirectoryStorage::FileTS>& subfiles,std::map<std::string,DirectoryStorage::FileTS>& new_files); bool updateSubFilesList(const DirectoryStorage::EntryIndex& indx,const std::map<std::string,DirectoryStorage::FileTS>& subfiles,std::map<std::string,DirectoryStorage::FileTS>& new_files);
bool updateHash(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash); bool updateHash(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash);
bool updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const time_t modf_time); bool updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const rstime_t modf_time);
bool updateDirEntry(const DirectoryStorage::EntryIndex& indx, const std::string& dir_name, time_t most_recent_time, time_t dir_modtime, const std::vector<RsFileHash> &subdirs_hash, const std::vector<FileEntry> &subfiles_array); bool updateDirEntry(const DirectoryStorage::EntryIndex& indx, const std::string& dir_name, rstime_t most_recent_time, rstime_t dir_modtime, const std::vector<RsFileHash> &subdirs_hash, const std::vector<FileEntry> &subfiles_array);
// TS get/set functions. Take one of the class members as argument. // TS get/set functions. Take one of the class members as argument.
bool getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) const; bool getTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* ) const;
bool setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) ; bool setTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* ) ;
// Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method. // Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method.
// Also keeps the high level statistics up to date. // Also keeps the high level statistics up to date.
time_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index, bool &unfinished_files_present); rstime_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index, bool &unfinished_files_present);
// hash stuff // hash stuff

View File

@ -20,7 +20,7 @@
* * * *
******************************************************************************/ ******************************************************************************/
#include <set> #include <set>
#include <time.h> #include "util/rstime.h"
#include "serialiser/rstlvbinary.h" #include "serialiser/rstlvbinary.h"
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
#include "util/rsdir.h" #include "util/rsdir.h"
@ -71,7 +71,7 @@ DirectoryStorage::DirIterator ::operator bool() const { return **this != Directo
RsFileHash DirectoryStorage::FileIterator::hash() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_hash):RsFileHash(); } RsFileHash DirectoryStorage::FileIterator::hash() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_hash):RsFileHash(); }
uint64_t DirectoryStorage::FileIterator::size() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_size):0; } uint64_t DirectoryStorage::FileIterator::size() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_size):0; }
std::string DirectoryStorage::FileIterator::name() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_name):std::string(); } std::string DirectoryStorage::FileIterator::name() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_name):std::string(); }
time_t DirectoryStorage::FileIterator::modtime() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_modtime):0; } rstime_t DirectoryStorage::FileIterator::modtime() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_modtime):0; }
std::string DirectoryStorage::DirIterator::name() const { const InternalFileHierarchyStorage::DirEntry *d = mStorage->getDirEntry(**this) ; return d?(d->dir_name):std::string(); } std::string DirectoryStorage::DirIterator::name() const { const InternalFileHierarchyStorage::DirEntry *d = mStorage->getDirEntry(**this) ; return d?(d->dir_name):std::string(); }
@ -119,13 +119,13 @@ uint32_t DirectoryStorage::getEntryType(const EntryIndex& indx)
} }
} }
bool DirectoryStorage::getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); } bool DirectoryStorage::getDirectoryUpdateTime (EntryIndex index,rstime_t& update_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
bool DirectoryStorage::getDirectoryRecursModTime(EntryIndex index,time_t& rec_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); } bool DirectoryStorage::getDirectoryRecursModTime(EntryIndex index,rstime_t& rec_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
bool DirectoryStorage::getDirectoryLocalModTime (EntryIndex index,time_t& loc_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); } bool DirectoryStorage::getDirectoryLocalModTime (EntryIndex index,rstime_t& loc_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
bool DirectoryStorage::setDirectoryUpdateTime (EntryIndex index,time_t update_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); } bool DirectoryStorage::setDirectoryUpdateTime (EntryIndex index,rstime_t update_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
bool DirectoryStorage::setDirectoryRecursModTime(EntryIndex index,time_t rec_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); } bool DirectoryStorage::setDirectoryRecursModTime(EntryIndex index,rstime_t rec_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
bool DirectoryStorage::setDirectoryLocalModTime (EntryIndex index,time_t loc_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); } bool DirectoryStorage::setDirectoryLocalModTime (EntryIndex index,rstime_t loc_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
bool DirectoryStorage::updateSubDirectoryList(const EntryIndex& indx, const std::set<std::string> &subdirs, const RsFileHash& hash_salt) bool DirectoryStorage::updateSubDirectoryList(const EntryIndex& indx, const std::set<std::string> &subdirs, const RsFileHash& hash_salt)
{ {
@ -281,7 +281,7 @@ bool DirectoryStorage::getIndexFromDirHash(const RsFileHash& hash,EntryIndex& in
void DirectoryStorage::checkSave() void DirectoryStorage::checkSave()
{ {
time_t now = time(NULL); rstime_t now = time(NULL);
if(mChanged && mLastSavedTime + MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE < now) if(mChanged && mLastSavedTime + MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE < now)
{ {
@ -489,7 +489,7 @@ void LocalDirectoryStorage::updateTimeStamps()
bool unfinished_files_below ; bool unfinished_files_below ;
time_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0),unfinished_files_below) ; rstime_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0),unfinished_files_below) ;
mTSChanged = false ; mTSChanged = false ;
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE #ifdef DEBUG_LOCAL_DIRECTORY_STORAGE

View File

@ -27,6 +27,7 @@
#include "retroshare/rsids.h" #include "retroshare/rsids.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
#include "util/rstime.h"
#define NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; } #define NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; }
@ -52,13 +53,13 @@ class DirectoryStorage
// gets/sets the various time stamps: // gets/sets the various time stamps:
// //
bool getDirectoryRecursModTime(EntryIndex index,time_t& recurs_max_modf_TS) const ; // last modification time, computed recursively over all subfiles and directories bool getDirectoryRecursModTime(EntryIndex index,rstime_t& recurs_max_modf_TS) const ; // last modification time, computed recursively over all subfiles and directories
bool getDirectoryLocalModTime (EntryIndex index,time_t& motime_TS) const ; // last modification time for that index only bool getDirectoryLocalModTime (EntryIndex index,rstime_t& motime_TS) const ; // last modification time for that index only
bool getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const ; // last time the entry was updated. This is only used on the RemoteDirectoryStorage side. bool getDirectoryUpdateTime (EntryIndex index,rstime_t& update_TS) const ; // last time the entry was updated. This is only used on the RemoteDirectoryStorage side.
bool setDirectoryRecursModTime(EntryIndex index,time_t recurs_max_modf_TS) ; bool setDirectoryRecursModTime(EntryIndex index,rstime_t recurs_max_modf_TS) ;
bool setDirectoryLocalModTime (EntryIndex index,time_t modtime_TS) ; bool setDirectoryLocalModTime (EntryIndex index,rstime_t modtime_TS) ;
bool setDirectoryUpdateTime (EntryIndex index,time_t update_TS) ; bool setDirectoryUpdateTime (EntryIndex index,rstime_t update_TS) ;
uint32_t getEntryType(const EntryIndex& indx) ; // WARNING: returns DIR_TYPE_*, not the internal directory storage stuff. uint32_t getEntryType(const EntryIndex& indx) ; // WARNING: returns DIR_TYPE_*, not the internal directory storage stuff.
virtual bool extractData(const EntryIndex& indx,DirDetails& d); virtual bool extractData(const EntryIndex& indx,DirDetails& d);
@ -81,8 +82,8 @@ class DirectoryStorage
// info about the directory that is pointed by the iterator // info about the directory that is pointed by the iterator
std::string name() const ; std::string name() const ;
time_t last_modif_time() const ; // last time a file in this directory or in the directories below has been modified. rstime_t last_modif_time() const ; // last time a file in this directory or in the directories below has been modified.
time_t last_update_time() const ; // last time this directory was updated rstime_t last_update_time() const ; // last time this directory was updated
private: private:
EntryIndex mParentIndex ; // index of the parent dir. EntryIndex mParentIndex ; // index of the parent dir.
uint32_t mDirTabIndex ; // index in the vector of subdirs. uint32_t mDirTabIndex ; // index in the vector of subdirs.
@ -106,7 +107,7 @@ class DirectoryStorage
std::string name() const ; std::string name() const ;
uint64_t size() const ; uint64_t size() const ;
RsFileHash hash() const ; RsFileHash hash() const ;
time_t modtime() const ; rstime_t modtime() const ;
private: private:
EntryIndex mParentIndex ; // index of the parent dir. EntryIndex mParentIndex ; // index of the parent dir.
@ -117,7 +118,7 @@ class DirectoryStorage
struct FileTS struct FileTS
{ {
uint64_t size ; uint64_t size ;
time_t modtime; rstime_t modtime;
}; };
EntryIndex root() const ; // returns the index of the root directory entry. This is generally 0. EntryIndex root() const ; // returns the index of the root directory entry. This is generally 0.
@ -171,7 +172,7 @@ class DirectoryStorage
InternalFileHierarchyStorage *mFileHierarchy ; InternalFileHierarchyStorage *mFileHierarchy ;
time_t mLastSavedTime ; rstime_t mLastSavedTime ;
bool mChanged ; bool mChanged ;
std::string mFileName; std::string mFileName;
}; };
@ -198,7 +199,7 @@ public:
* returns the last time a sweep has been done over the directory in order to check update TS. * returns the last time a sweep has been done over the directory in order to check update TS.
* \return * \return
*/ */
time_t& lastSweepTime() { return mLastSweepTime ; } rstime_t& lastSweepTime() { return mLastSweepTime ; }
/*! /*!
* \brief searchHash * \brief searchHash
@ -212,7 +213,7 @@ public:
virtual int searchHash(const RsFileHash& hash, EntryIndex& results) const ; virtual int searchHash(const RsFileHash& hash, EntryIndex& results) const ;
private: private:
time_t mLastSweepTime ; rstime_t mLastSweepTime ;
}; };
class LocalDirectoryStorage: public DirectoryStorage class LocalDirectoryStorage: public DirectoryStorage

View File

@ -64,7 +64,7 @@ void LocalDirectoryUpdater::setEnabled(bool b)
void LocalDirectoryUpdater::data_tick() void LocalDirectoryUpdater::data_tick()
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if (mIsEnabled || mForceUpdate) if (mIsEnabled || mForceUpdate)
{ {
@ -190,14 +190,14 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
librs::util::FolderIterator dirIt(cumulated_path,mFollowSymLinks,false); // disallow symbolic links and files from the future. librs::util::FolderIterator dirIt(cumulated_path,mFollowSymLinks,false); // disallow symbolic links and files from the future.
time_t dir_local_mod_time ; rstime_t dir_local_mod_time ;
if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time)) if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time))
{ {
std::cerr << "(EE) Cannot get local mod time for dir index " << indx << std::endl; std::cerr << "(EE) Cannot get local mod time for dir index " << indx << std::endl;
return; return;
} }
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(mNeedsFullRecheck || dirIt.dir_modtime() > dir_local_mod_time) // the > is because we may have changed the virtual name, and therefore the TS wont match. if(mNeedsFullRecheck || dirIt.dir_modtime() > dir_local_mod_time) // the > is because we may have changed the virtual name, and therefore the TS wont match.
// we only want to detect when the directory has changed on the disk // we only want to detect when the directory has changed on the disk

View File

@ -27,6 +27,7 @@
// //
#include "file_sharing/hash_cache.h" #include "file_sharing/hash_cache.h"
#include "file_sharing/directory_storage.h" #include "file_sharing/directory_storage.h"
#include "util/rstime.h"
class LocalDirectoryUpdater: public HashStorageClient, public RsTickingThread class LocalDirectoryUpdater: public HashStorageClient, public RsTickingThread
{ {
@ -77,8 +78,8 @@ private:
RsFileHash mHashSalt ; RsFileHash mHashSalt ;
time_t mLastSweepTime; rstime_t mLastSweepTime;
time_t mLastTSUpdateTime; rstime_t mLastTSUpdateTime;
uint32_t mDelayBetweenDirectoryUpdates; uint32_t mDelayBetweenDirectoryUpdates;
bool mIsEnabled ; bool mIsEnabled ;

View File

@ -232,7 +232,7 @@ void HashStorage::data_tick()
job.client->hash_callback(job.client_param, job.full_path, hash, size); job.client->hash_callback(job.client_param, job.full_path, hash, size);
} }
bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t mod_time,RsFileHash& known_hash,HashStorageClient *c,uint32_t client_param) bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_t mod_time,RsFileHash& known_hash,HashStorageClient *c,uint32_t client_param)
{ {
// check if the hash is up to date w.r.t. cache. // check if the hash is up to date w.r.t. cache.
@ -243,7 +243,7 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t
std::string real_path = RsDirUtil::removeSymLinks(full_path) ; std::string real_path = RsDirUtil::removeSymLinks(full_path) ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
std::map<std::string,HashStorageInfo>::iterator it = mFiles.find(real_path) ; std::map<std::string,HashStorageInfo>::iterator it = mFiles.find(real_path) ;
// On windows we compare the time up to +/- 3600 seconds. This avoids re-hashing files in case of daylight saving change. // On windows we compare the time up to +/- 3600 seconds. This avoids re-hashing files in case of daylight saving change.
@ -318,8 +318,8 @@ void HashStorage::clean()
{ {
RS_STACK_MUTEX(mHashMtx) ; RS_STACK_MUTEX(mHashMtx) ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
time_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds rstime_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds
#ifdef HASHSTORAGE_DEBUG #ifdef HASHSTORAGE_DEBUG
std::cerr << "Cleaning hash cache." << std::endl ; std::cerr << "Cleaning hash cache." << std::endl ;

View File

@ -26,6 +26,7 @@
#include <map> #include <map>
#include "util/rsthreads.h" #include "util/rsthreads.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
#include "util/rstime.h"
/*! /*!
* \brief The HashStorageClient class * \brief The HashStorageClient class
@ -65,7 +66,7 @@ public:
* *
* \return true if the supplied hash info is up to date. * \return true if the supplied hash info is up to date.
*/ */
bool requestHash(const std::string& full_path, uint64_t size, time_t mod_time, RsFileHash& known_hash, HashStorageClient *c, uint32_t client_param) ; bool requestHash(const std::string& full_path, uint64_t size, rstime_t mod_time, RsFileHash& known_hash, HashStorageClient *c, uint32_t client_param) ;
struct HashStorageInfo struct HashStorageInfo
{ {
@ -120,7 +121,7 @@ private:
uint64_t size ; uint64_t size ;
HashStorageClient *client; HashStorageClient *client;
uint32_t client_param ; uint32_t client_param ;
time_t ts; rstime_t ts;
}; };
// current work // current work
@ -136,7 +137,7 @@ private:
uint64_t mTotalSizeToHash ; uint64_t mTotalSizeToHash ;
uint64_t mTotalHashedSize ; uint64_t mTotalHashedSize ;
uint64_t mTotalFilesToHash ; uint64_t mTotalFilesToHash ;
time_t mLastSaveTime ; rstime_t mLastSaveTime ;
// The following is used to estimate hashing speed. // The following is used to estimate hashing speed.

View File

@ -171,7 +171,7 @@ int p3FileDatabase::tick()
tickRecv() ; tickRecv() ;
tickSend() ; tickSend() ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
// cleanup // cleanup
// - remove/delete shared file lists for people who are not friend anymore // - remove/delete shared file lists for people who are not friend anymore
@ -183,7 +183,7 @@ int p3FileDatabase::tick()
mLastCleanupTime = now ; mLastCleanupTime = now ;
} }
static time_t last_print_time = 0; static rstime_t last_print_time = 0;
if(last_print_time + 20 < now) if(last_print_time + 20 < now)
{ {
@ -604,15 +604,15 @@ void p3FileDatabase::cleanup()
for(std::list<RsPeerId>::const_iterator it(friend_lst.begin());it!=friend_lst.end();++it) for(std::list<RsPeerId>::const_iterator it(friend_lst.begin());it!=friend_lst.end();++it)
friend_set.insert(*it) ; friend_set.insert(*it) ;
} }
time_t now = time(NULL); rstime_t now = time(NULL);
for(uint32_t i=0;i<mRemoteDirectories.size();++i) for(uint32_t i=0;i<mRemoteDirectories.size();++i)
if(mRemoteDirectories[i] != NULL) if(mRemoteDirectories[i] != NULL)
{ {
time_t recurs_mod_time ; rstime_t recurs_mod_time ;
mRemoteDirectories[i]->getDirectoryRecursModTime(0,recurs_mod_time) ; mRemoteDirectories[i]->getDirectoryRecursModTime(0,recurs_mod_time) ;
time_t last_contact = 0 ; rstime_t last_contact = 0 ;
RsPeerDetails pd ; RsPeerDetails pd ;
if(rsPeers->getPeerDetails(mRemoteDirectories[i]->peerId(),pd)) if(rsPeers->getPeerDetails(mRemoteDirectories[i]->peerId(),pd))
last_contact = pd.lastConnect ; last_contact = pd.lastConnect ;
@ -976,7 +976,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn
{ {
// update the cache of extra files if last requested too long ago // update the cache of extra files if last requested too long ago
time_t now = time(NULL); rstime_t now = time(NULL);
if(mLastExtraFilesCacheUpdate + DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES <= now) if(mLastExtraFilesCacheUpdate + DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES <= now)
{ {
@ -1627,7 +1627,7 @@ void p3FileDatabase::handleDirSyncRequest(RsFileListsSyncRequestItem *item)
} }
else else
{ {
time_t local_recurs_max_time ; rstime_t local_recurs_max_time ;
mLocalSharedDirs->getDirectoryRecursModTime(entry_index,local_recurs_max_time) ; mLocalSharedDirs->getDirectoryRecursModTime(entry_index,local_recurs_max_time) ;
if(item->last_known_recurs_modf_TS != local_recurs_max_time) // normally, should be "<", but since we provided the TS it should be equal, so != is more robust. if(item->last_known_recurs_modf_TS != local_recurs_max_time) // normally, should be "<", but since we provided the TS it should be equal, so != is more robust.
@ -1792,7 +1792,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem)
sitem = item ; sitem = item ;
} }
time_t now = time(NULL); rstime_t now = time(NULL);
// check the hash. If anything goes wrong (in the chunking for instance) the hash will not match // check the hash. If anything goes wrong (in the chunking for instance) the hash will not match
@ -1899,7 +1899,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem)
void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *rds,DirectoryStorage::EntryIndex e,int depth) void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *rds,DirectoryStorage::EntryIndex e,int depth)
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
//std::string indent(2*depth,' ') ; //std::string indent(2*depth,' ') ;
@ -1912,7 +1912,7 @@ void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *r
P3FILELISTS_DEBUG() << "currently at entry index " << e << std::endl; P3FILELISTS_DEBUG() << "currently at entry index " << e << std::endl;
#endif #endif
time_t local_update_TS; rstime_t local_update_TS;
if(!rds->getDirectoryUpdateTime(e,local_update_TS)) if(!rds->getDirectoryUpdateTime(e,local_update_TS))
{ {
@ -1959,9 +1959,9 @@ p3FileDatabase::DirSyncRequestId p3FileDatabase::makeDirSyncReqId(const RsPeerId
bool p3FileDatabase::locked_generateAndSendSyncRequest(RemoteDirectoryStorage *rds,const DirectoryStorage::EntryIndex& e) bool p3FileDatabase::locked_generateAndSendSyncRequest(RemoteDirectoryStorage *rds,const DirectoryStorage::EntryIndex& e)
{ {
RsFileHash entry_hash ; RsFileHash entry_hash ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
time_t max_known_recurs_modf_time ; rstime_t max_known_recurs_modf_time ;
if(!rds->getDirectoryRecursModTime(e,max_known_recurs_modf_time)) if(!rds->getDirectoryRecursModTime(e,max_known_recurs_modf_time))
{ {
@ -2118,7 +2118,7 @@ void p3FileDatabase::checkSendBannedFilesInfo()
P3FILELISTS_DEBUG() << " Checking banned files information: " << std::endl; P3FILELISTS_DEBUG() << " Checking banned files information: " << std::endl;
#endif #endif
time_t now = time(NULL); rstime_t now = time(NULL);
std::list<RsPeerId> online_friends ; std::list<RsPeerId> online_friends ;
rsPeers->getOnlineList(online_friends); rsPeers->getOnlineList(online_friends);

View File

@ -48,7 +48,7 @@
#include "ft/ftextralist.h" #include "ft/ftextralist.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
#include "services/p3service.h" #include "services/p3service.h"
#include "util/rstime.h"
#include "file_sharing/hash_cache.h" #include "file_sharing/hash_cache.h"
#include "file_sharing/directory_storage.h" #include "file_sharing/directory_storage.h"
@ -71,7 +71,7 @@ struct PeerBannedFilesEntry
{ {
std::set<RsFileHash> mBannedHashOfHash; std::set<RsFileHash> mBannedHashOfHash;
uint32_t mSessionId ; // used for when a friend sends multiple packets in separate items. uint32_t mSessionId ; // used for when a friend sends multiple packets in separate items.
time_t mLastSent; rstime_t mLastSent;
}; };
class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, public RsSharedFileService class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, public RsSharedFileService
@ -246,11 +246,11 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
struct DirSyncRequestData struct DirSyncRequestData
{ {
RsPeerId peer_id ; RsPeerId peer_id ;
time_t request_TS ; rstime_t request_TS ;
uint32_t flags ; uint32_t flags ;
}; };
time_t mLastRemoteDirSweepTS ; // TS for friend list update rstime_t mLastRemoteDirSweepTS ; // TS for friend list update
std::map<DirSyncRequestId,DirSyncRequestData> mPendingSyncRequests ; // pending requests, waiting for an answer std::map<DirSyncRequestId,DirSyncRequestData> mPendingSyncRequests ; // pending requests, waiting for an answer
std::map<DirSyncRequestId,RsFileListsSyncResponseItem *> mPartialResponseItems; std::map<DirSyncRequestId,RsFileListsSyncResponseItem *> mPartialResponseItems;
@ -265,8 +265,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
mutable RsMutex mFLSMtx ; mutable RsMutex mFLSMtx ;
uint32_t mUpdateFlags ; uint32_t mUpdateFlags ;
std::string mFileSharingDir ; std::string mFileSharingDir ;
time_t mLastCleanupTime; rstime_t mLastCleanupTime;
time_t mLastDataRecvTS ; rstime_t mLastDataRecvTS ;
// File filtering. Not explicitly related to shared files, but has its place here // File filtering. Not explicitly related to shared files, but has its place here
// //
@ -275,10 +275,10 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
std::map<RsPeerId,PeerBannedFilesEntry> mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f)) std::map<RsPeerId,PeerBannedFilesEntry> mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f))
std::set<RsFileHash> mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends. std::set<RsFileHash> mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends.
mutable std::vector<FileInfo> mExtraFilesCache; // cache for extra files, to avoid requesting them too often. mutable std::vector<FileInfo> mExtraFilesCache; // cache for extra files, to avoid requesting them too often.
mutable time_t mLastExtraFilesCacheUpdate ; mutable rstime_t mLastExtraFilesCacheUpdate ;
bool mTrustFriendNodesForBannedFiles ; bool mTrustFriendNodesForBannedFiles ;
bool mBannedFileListNeedsUpdate; bool mBannedFileListNeedsUpdate;
time_t mLastPrimaryBanListChangeTimeStamp; rstime_t mLastPrimaryBanListChangeTimeStamp;
void locked_sendBanInfo(const RsPeerId& pid); void locked_sendBanInfo(const RsPeerId& pid);
void handleBannedFilesInfo(RsFileListsBannedHashesItem *item); void handleBannedFilesInfo(RsFileListsBannedHashesItem *item);

View File

@ -54,7 +54,7 @@ template<> void RsTypeSerializer::serial_process(RsGenericSerializer::SerializeJ
{ {
RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,entry.filename ,"entry.file_name") ; RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,entry.filename ,"entry.file_name") ;
RsTypeSerializer::serial_process<uint64_t>(j,ctx, entry.size ,"entry.size") ; RsTypeSerializer::serial_process<uint64_t>(j,ctx, entry.size ,"entry.size") ;
RsTypeSerializer::serial_process<time_t> (j,ctx, entry.ban_time_stamp,"entry.ban_time_stamp") ; RsTypeSerializer::serial_process<rstime_t> (j,ctx, entry.ban_time_stamp,"entry.ban_time_stamp") ;
} }
RsItem *RsFileListsSerialiser::create_item(uint16_t service,uint8_t type) const RsItem *RsFileListsSerialiser::create_item(uint16_t service,uint8_t type) const
{ {

View File

@ -31,7 +31,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
#include "ftchunkmap.h" #include "ftchunkmap.h"
#include <time.h> #include "util/rstime.h"
static const uint32_t SOURCE_CHUNK_MAP_UPDATE_PERIOD = 60 ; //! TTL for chunkmap info static const uint32_t SOURCE_CHUNK_MAP_UPDATE_PERIOD = 60 ; //! TTL for chunkmap info
static const uint32_t INACTIVE_CHUNK_TIME_LAPSE = 3600 ; //! TTL for an inactive chunk static const uint32_t INACTIVE_CHUNK_TIME_LAPSE = 3600 ; //! TTL for an inactive chunk
@ -264,7 +264,7 @@ bool ChunkMap::reAskPendingChunk( const RsPeerId& peer_id,
if(_map[i] == FileChunksInfo::CHUNK_OUTSTANDING) if(_map[i] == FileChunksInfo::CHUNK_OUTSTANDING)
return false ; return false ;
time_t now = time(NULL); rstime_t now = time(NULL);
for(std::map<uint32_t,ChunkDownloadInfo>::iterator it(_slices_to_download.begin());it!=_slices_to_download.end();++it) for(std::map<uint32_t,ChunkDownloadInfo>::iterator it(_slices_to_download.begin());it!=_slices_to_download.end();++it)
for(std::map<ftChunk::OffsetInFile,ChunkDownloadInfo::SliceRequestInfo >::iterator it2(it->second._slices.begin());it2!=it->second._slices.end();++it2) for(std::map<ftChunk::OffsetInFile,ChunkDownloadInfo::SliceRequestInfo >::iterator it2(it->second._slices.begin());it2!=it->second._slices.end();++it2)
@ -400,7 +400,7 @@ bool ChunkMap::getDataChunk(const RsPeerId& peer_id,uint32_t size_hint,ftChunk&
void ChunkMap::removeInactiveChunks(std::vector<ftChunk::OffsetInFile>& to_remove) void ChunkMap::removeInactiveChunks(std::vector<ftChunk::OffsetInFile>& to_remove)
{ {
to_remove.clear() ; to_remove.clear() ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::map<ChunkNumber,ChunkDownloadInfo>::iterator it(_slices_to_download.begin());it!=_slices_to_download.end();) for(std::map<ChunkNumber,ChunkDownloadInfo>::iterator it(_slices_to_download.begin());it!=_slices_to_download.end();)
if(now - it->second._last_data_received > (int)INACTIVE_CHUNK_TIME_LAPSE) if(now - it->second._last_data_received > (int)INACTIVE_CHUNK_TIME_LAPSE)
@ -573,7 +573,7 @@ uint32_t ChunkMap::getAvailableChunk(const RsPeerId& peer_id,bool& map_is_too_ol
// useful to get a new map that will also be full, but because we need to be careful not to mislead information, // useful to get a new map that will also be full, but because we need to be careful not to mislead information,
// we still keep asking. // we still keep asking.
// //
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if((!peer_chunks->is_full) && ((int)now - (int)peer_chunks->TS > (int)SOURCE_CHUNK_MAP_UPDATE_PERIOD)) if((!peer_chunks->is_full) && ((int)now - (int)peer_chunks->TS > (int)SOURCE_CHUNK_MAP_UPDATE_PERIOD))
{ {

View File

@ -63,7 +63,7 @@ class ftChunk
uint64_t offset; // current offset of the slice uint64_t offset; // current offset of the slice
uint64_t size; // size remaining to download uint64_t size; // size remaining to download
OffsetInFile id ; // id of the chunk. Equal to the starting offset of the chunk OffsetInFile id ; // id of the chunk. Equal to the starting offset of the chunk
time_t ts; // time of last data received rstime_t ts; // time of last data received
int *ref_cnt; // shared counter of number of sub-blocks. Used when a slice gets split. int *ref_cnt; // shared counter of number of sub-blocks. Used when a slice gets split.
RsPeerId peer_id ; RsPeerId peer_id ;
}; };
@ -98,20 +98,20 @@ struct ChunkDownloadInfo
struct SliceRequestInfo struct SliceRequestInfo
{ {
uint32_t size ; // size of the slice uint32_t size ; // size of the slice
time_t request_time ; // last request time rstime_t request_time ; // last request time
std::set<RsPeerId> peers ; // peers the slice was requested to. Normally only one, except at the end of the file. std::set<RsPeerId> peers ; // peers the slice was requested to. Normally only one, except at the end of the file.
}; };
std::map<ftChunk::OffsetInFile,SliceRequestInfo> _slices ; std::map<ftChunk::OffsetInFile,SliceRequestInfo> _slices ;
uint32_t _remains ; uint32_t _remains ;
time_t _last_data_received ; rstime_t _last_data_received ;
}; };
class SourceChunksInfo class SourceChunksInfo
{ {
public: public:
CompressedChunkMap cmap ; //! map of what the peer has/doens't have CompressedChunkMap cmap ; //! map of what the peer has/doens't have
time_t TS ; //! last update time for this info rstime_t TS ; //! last update time for this info
bool is_full ; //! is the map full ? In such a case, re-asking for it is unnecessary. bool is_full ; //! is the map full ? In such a case, re-asking for it is unnecessary.
// Returns true if the offset is starting in a mapped chunk. // Returns true if the offset is starting in a mapped chunk.

View File

@ -61,7 +61,7 @@
#include "rsitems/rsconfigitems.h" #include "rsitems/rsconfigitems.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> /* for (u)sleep() */ #include <unistd.h> /* for (u)sleep() */
#include <time.h> #include "util/rstime.h"
/****** /******
* #define CONTROL_DEBUG 1 * #define CONTROL_DEBUG 1
@ -226,7 +226,7 @@ void ftController::data_tick()
doPending = (mFtActive) && (!mFtPendingDone); doPending = (mFtActive) && (!mFtPendingDone);
} }
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(now > last_save_time + SAVE_TRANSFERS_DELAY) if(now > last_save_time + SAVE_TRANSFERS_DELAY)
{ {
IndicateConfigChanged() ; IndicateConfigChanged() ;
@ -421,11 +421,11 @@ void ftController::checkDownloadQueue()
// Check for inactive transfers, and queued transfers with online sources. // Check for inactive transfers, and queued transfers with online sources.
// //
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::map<RsFileHash,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end() ;++it) for(std::map<RsFileHash,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end() ;++it)
if( it->second->mState != ftFileControl::QUEUED && (it->second->mState == ftFileControl::PAUSED if( it->second->mState != ftFileControl::QUEUED && (it->second->mState == ftFileControl::PAUSED
|| now > it->second->mTransfer->lastActvTimeStamp() + (time_t)MAX_TIME_INACTIVE_REQUEUED)) || now > it->second->mTransfer->lastActvTimeStamp() + (rstime_t)MAX_TIME_INACTIVE_REQUEUED))
{ {
inactive_transfers.push_back(it->second) ; inactive_transfers.push_back(it->second) ;
} }

View File

@ -83,7 +83,7 @@ class ftFileControl
RsFileHash mHash; RsFileHash mHash;
uint64_t mSize; uint64_t mSize;
TransferRequestFlags mFlags; TransferRequestFlags mFlags;
time_t mCreateTime; rstime_t mCreateTime;
uint32_t mQueuePriority ; uint32_t mQueuePriority ;
uint32_t mQueuePosition ; uint32_t mQueuePosition ;
}; };
@ -226,8 +226,8 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C
bool setPeerState(ftTransferModule *tm, const RsPeerId& id, bool setPeerState(ftTransferModule *tm, const RsPeerId& id,
uint32_t maxrate, bool online); uint32_t maxrate, bool online);
time_t last_save_time ; rstime_t last_save_time ;
time_t last_clean_time ; rstime_t last_clean_time ;
/* pointers to other components */ /* pointers to other components */
ftSearch *mSearch; ftSearch *mSearch;

View File

@ -34,7 +34,7 @@
#include "util/rsdir.h" #include "util/rsdir.h"
#include "util/rsmemory.h" #include "util/rsmemory.h"
#include <retroshare/rsturtle.h> #include <retroshare/rsturtle.h>
#include <time.h> #include "util/rstime.h"
/* For Thread Behaviour */ /* For Thread Behaviour */
const uint32_t DMULTIPLEX_MIN = 10; /* 10 msec sleep */ const uint32_t DMULTIPLEX_MIN = 10; /* 10 msec sleep */
@ -452,7 +452,7 @@ bool ftDataMultiplex::recvSingleChunkCRC(const RsPeerId& peerId, const RsFileHas
// remove this chunk from the request list as well. // remove this chunk from the request list as well.
Sha1CacheEntry& sha1cache(_cached_sha1maps[hash]) ; Sha1CacheEntry& sha1cache(_cached_sha1maps[hash]) ;
std::map<uint32_t,std::pair<time_t,ChunkCheckSumSourceList> >::iterator it2(sha1cache._to_ask.find(chunk_number)) ; std::map<uint32_t,std::pair<rstime_t,ChunkCheckSumSourceList> >::iterator it2(sha1cache._to_ask.find(chunk_number)) ;
if(it2 != sha1cache._to_ask.end()) if(it2 != sha1cache._to_ask.end())
sha1cache._to_ask.erase(it2) ; sha1cache._to_ask.erase(it2) ;
@ -943,7 +943,7 @@ bool ftDataMultiplex::sendSingleChunkCRCRequests(const RsFileHash& hash, const s
for(uint32_t i=0;i<to_ask.size();++i) for(uint32_t i=0;i<to_ask.size();++i)
{ {
std::pair<time_t,ChunkCheckSumSourceList>& list(ce._to_ask[to_ask[i]]) ; std::pair<rstime_t,ChunkCheckSumSourceList>& list(ce._to_ask[to_ask[i]]) ;
list.first = 0 ; // set last request time to 0 list.first = 0 ; // set last request time to 0
} }
return true ; return true ;
@ -953,7 +953,7 @@ void ftDataMultiplex::handlePendingCrcRequests()
{ {
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
uint32_t n=0 ; uint32_t n=0 ;
// Go through the list of currently handled hashes. For each of them, // Go through the list of currently handled hashes. For each of them,
@ -966,7 +966,7 @@ void ftDataMultiplex::handlePendingCrcRequests()
// //
for(std::map<RsFileHash,Sha1CacheEntry>::iterator it(_cached_sha1maps.begin());it!=_cached_sha1maps.end();++it) for(std::map<RsFileHash,Sha1CacheEntry>::iterator it(_cached_sha1maps.begin());it!=_cached_sha1maps.end();++it)
for(std::map<uint32_t,std::pair<time_t,ChunkCheckSumSourceList> >::iterator it2(it->second._to_ask.begin());it2!=it->second._to_ask.end();++it2) for(std::map<uint32_t,std::pair<rstime_t,ChunkCheckSumSourceList> >::iterator it2(it->second._to_ask.begin());it2!=it->second._to_ask.end();++it2)
if(it2->second.first + MAX_CHECKING_CHUNK_WAIT_DELAY < now) // is the last request old enough? if(it2->second.first + MAX_CHECKING_CHUNK_WAIT_DELAY < now) // is the last request old enough?
{ {
#ifdef MPLEX_DEBUG #ifdef MPLEX_DEBUG
@ -986,14 +986,14 @@ void ftDataMultiplex::handlePendingCrcRequests()
// //
RsPeerId best_source ; RsPeerId best_source ;
time_t oldest_timestamp = now ; rstime_t oldest_timestamp = now ;
for(uint32_t i=0;i<sources.size();++i) for(uint32_t i=0;i<sources.size();++i)
{ {
#ifdef MPLEX_DEBUG #ifdef MPLEX_DEBUG
std::cerr << "ftDataMultiplex::handlePendingCrcRequests(): Examining source " << sources[i] << std::endl; std::cerr << "ftDataMultiplex::handlePendingCrcRequests(): Examining source " << sources[i] << std::endl;
#endif #endif
std::map<RsPeerId,time_t>::const_iterator it3(it2->second.second.find(sources[i])) ; std::map<RsPeerId,rstime_t>::const_iterator it3(it2->second.second.find(sources[i])) ;
if(it3 == it2->second.second.end()) // source not found. So this one is surely the oldest one to have been requested. if(it3 == it2->second.second.end()) // source not found. So this one is surely the oldest one to have been requested.
{ {
@ -1044,7 +1044,7 @@ void ftDataMultiplex::deleteUnusedServers()
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
//scan the uploads list in ftdatamultiplex and delete the items which time out //scan the uploads list in ftdatamultiplex and delete the items which time out
time_t now = time(NULL); rstime_t now = time(NULL);
for(std::map<RsFileHash, ftFileProvider *>::iterator sit(mServers.begin());sit != mServers.end();) for(std::map<RsFileHash, ftFileProvider *>::iterator sit(mServers.begin());sit != mServers.end();)
if(sit->second->purgeOldPeers(now,10)) if(sit->second->purgeOldPeers(now,10))

View File

@ -74,15 +74,15 @@ class ftRequest
void *mData; void *mData;
}; };
typedef std::map<RsPeerId,time_t> ChunkCheckSumSourceList ; typedef std::map<RsPeerId,rstime_t> ChunkCheckSumSourceList ;
class Sha1CacheEntry class Sha1CacheEntry
{ {
public: public:
Sha1Map _map ; // Map of available sha1 sums for every chunk. Sha1Map _map ; // Map of available sha1 sums for every chunk.
time_t last_activity ; // This is used for removing unused entries. rstime_t last_activity ; // This is used for removing unused entries.
std::vector<uint32_t> _received ; // received chunk ids. To bedispatched. std::vector<uint32_t> _received ; // received chunk ids. To bedispatched.
std::map<uint32_t,std::pair<time_t,ChunkCheckSumSourceList> > _to_ask ; // Chunks to ask to sources. std::map<uint32_t,std::pair<rstime_t,ChunkCheckSumSourceList> > _to_ask ; // Chunks to ask to sources.
}; };
class ftDataMultiplex: public ftDataRecv, public RsQueueThread class ftDataMultiplex: public ftDataRecv, public RsQueueThread

View File

@ -32,7 +32,7 @@
#include "util/rstime.h" #include "util/rstime.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> /* for (u)sleep() */ #include <unistd.h> /* for (u)sleep() */
#include <time.h> #include "util/rstime.h"
/****** /******
* #define DEBUG_ELIST 1 * #define DEBUG_ELIST 1
@ -49,7 +49,7 @@ ftExtraList::ftExtraList()
void ftExtraList::data_tick() void ftExtraList::data_tick()
{ {
bool todo = false; bool todo = false;
time_t now = time(NULL); rstime_t now = time(NULL);
{ {
RsStackMutex stack(extMutex); RsStackMutex stack(extMutex);
@ -229,12 +229,12 @@ bool ftExtraList::cleanupOldFiles()
RS_STACK_MUTEX(extMutex); RS_STACK_MUTEX(extMutex);
time_t now = time(NULL); rstime_t now = time(NULL);
std::list<RsFileHash> toRemove; std::list<RsFileHash> toRemove;
for( std::map<RsFileHash, FileDetails>::iterator it = mFiles.begin(); it != mFiles.end(); ++it) /* check timestamps */ for( std::map<RsFileHash, FileDetails>::iterator it = mFiles.begin(); it != mFiles.end(); ++it) /* check timestamps */
if ((time_t)it->second.info.age < now) if ((rstime_t)it->second.info.age < now)
toRemove.push_back(it->first); toRemove.push_back(it->first);
if (toRemove.size() > 0) if (toRemove.size() > 0)
@ -450,7 +450,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
time_t ts = time(NULL); rstime_t ts = time(NULL);
std::list<RsItem *>::iterator it; std::list<RsItem *>::iterator it;
@ -475,7 +475,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
fclose(fd); fclose(fd);
fd = NULL ; fd = NULL ;
if (ts > (time_t)fi->file.age) if (ts > (rstime_t)fi->file.age)
{ {
/* to old */ /* to old */
cleanupEntry(fi->file.path, TransferRequestFlags(fi->flags)); cleanupEntry(fi->file.path, TransferRequestFlags(fi->flags));

View File

@ -58,6 +58,7 @@
#include "util/rsthreads.h" #include "util/rsthreads.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
#include "pqi/p3cfgmgr.h" #include "pqi/p3cfgmgr.h"
#include "util/rstime.h"
class FileDetails class FileDetails
{ {
@ -177,7 +178,7 @@ private:
std::map<RsFileHash, FileDetails> mFiles; std::map<RsFileHash, FileDetails> mFiles;
std::map<RsFileHash, RsFileHash> mHashOfHash; /* sha1(hash) map so as to answer requests to encrypted transfers */ std::map<RsFileHash, RsFileHash> mHashOfHash; /* sha1(hash) map so as to answer requests to encrypted transfers */
time_t cleanup ; rstime_t cleanup ;
}; };

View File

@ -27,7 +27,7 @@
#include "ftfilecreator.h" #include "ftfilecreator.h"
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include "util/rstime.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <util/rsdiscspace.h> #include <util/rsdiscspace.h>
#include <util/rsdir.h> #include <util/rsdir.h>
@ -63,7 +63,7 @@ ftFileCreator::ftFileCreator(const std::string& path, uint64_t size, const RsFil
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
_creation_time = now ; _creation_time = now ;
struct stat64 buf; struct stat64 buf;
@ -143,12 +143,12 @@ bool ftFileCreator::getFileData(const RsPeerId& peer_id,uint64_t offset, uint32_
return false ; return false ;
} }
time_t ftFileCreator::creationTimeStamp() rstime_t ftFileCreator::creationTimeStamp()
{ {
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
return _creation_time ; return _creation_time ;
} }
time_t ftFileCreator::lastRecvTimeStamp() rstime_t ftFileCreator::lastRecvTimeStamp()
{ {
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
return _last_recv_time_t ; return _last_recv_time_t ;
@ -520,7 +520,7 @@ bool ftFileCreator::getMissingChunk(const RsPeerId& peer_id,uint32_t size_hint,u
locked_printChunkMap(); locked_printChunkMap();
#endif #endif
source_chunk_map_needed = false ; source_chunk_map_needed = false ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
// 0 - is there a faulting chunk that would need to be asked again ? // 0 - is there a faulting chunk that would need to be asked again ?

View File

@ -103,8 +103,8 @@ class ftFileCreator: public ftFileProvider
void getSourcesList(uint32_t chunk_number,std::vector<RsPeerId>& sources) ; void getSourcesList(uint32_t chunk_number,std::vector<RsPeerId>& sources) ;
// Returns resets the time stamp of the last data receive. // Returns resets the time stamp of the last data receive.
time_t lastRecvTimeStamp() ; rstime_t lastRecvTimeStamp() ;
time_t creationTimeStamp() ; rstime_t creationTimeStamp() ;
// actually store data in the file, and update chunks info // actually store data in the file, and update chunks info
// //
@ -144,8 +144,8 @@ class ftFileCreator: public ftFileProvider
ChunkMap chunkMap ; ChunkMap chunkMap ;
time_t _last_recv_time_t ; /// last time stamp when data was received. Used for queue control. rstime_t _last_recv_time_t ; /// last time stamp when data was received. Used for queue control.
time_t _creation_time ; /// time at which the file creator was created. Used to spot long-inactive transfers. rstime_t _creation_time ; /// time at which the file creator was created. Used to spot long-inactive transfers.
}; };
#endif // FT_FILE_CREATOR_HEADER #endif // FT_FILE_CREATOR_HEADER

View File

@ -29,7 +29,7 @@
#include "util/rsdir.h" #include "util/rsdir.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include "util/rstime.h"
/******** /********
* #define DEBUG_FT_FILE_PROVIDER 1 * #define DEBUG_FT_FILE_PROVIDER 1
@ -41,7 +41,7 @@
#include <iomanip> #include <iomanip>
#endif #endif
static const time_t UPLOAD_CHUNK_MAPS_TIME = 20 ; // time to ask for a new chunkmap from uploaders in seconds. static const rstime_t UPLOAD_CHUNK_MAPS_TIME = 20 ; // time to ask for a new chunkmap from uploaders in seconds.
ftFileProvider::ftFileProvider(const std::string& path, uint64_t size, const RsFileHash& hash) ftFileProvider::ftFileProvider(const std::string& path, uint64_t size, const RsFileHash& hash)
: mSize(size), hash(hash), file_name(path), fd(NULL), ftcMutex("ftFileProvider") : mSize(size), hash(hash), file_name(path), fd(NULL), ftcMutex("ftFileProvider")
@ -122,7 +122,7 @@ bool ftFileProvider::FileDetails(FileInfo &info)
return true; return true;
} }
bool ftFileProvider::purgeOldPeers(time_t now,uint32_t max_duration) bool ftFileProvider::purgeOldPeers(rstime_t now,uint32_t max_duration)
{ {
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
@ -232,7 +232,7 @@ bool ftFileProvider::getFileData(const RsPeerId& peer_id,uint64_t offset, uint32
// This creates the peer info, and updates it. // This creates the peer info, and updates it.
// //
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
uploading_peers[peer_id].updateStatus(offset,data_size,now) ; uploading_peers[peer_id].updateStatus(offset,data_size,now) ;
#ifdef DEBUG_TRANSFERS #ifdef DEBUG_TRANSFERS
@ -254,7 +254,7 @@ bool ftFileProvider::getFileData(const RsPeerId& peer_id,uint64_t offset, uint32
return 1; return 1;
} }
void ftFileProvider::PeerUploadInfo::updateStatus(uint64_t offset,uint32_t data_size,time_t now) void ftFileProvider::PeerUploadInfo::updateStatus(uint64_t offset,uint32_t data_size,rstime_t now)
{ {
lastTS = now ; lastTS = now ;
long int diff = (long int)now - (long int)lastTS_t ; // in bytes/s. Average over multiple samples long int diff = (long int)now - (long int)lastTS_t ; // in bytes/s. Average over multiple samples
@ -293,7 +293,7 @@ void ftFileProvider::getClientMap(const RsPeerId& peer_id,CompressedChunkMap& cm
PeerUploadInfo& pui(uploading_peers[peer_id]) ; PeerUploadInfo& pui(uploading_peers[peer_id]) ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(now - pui.client_chunk_map_stamp > UPLOAD_CHUNK_MAPS_TIME) if(now - pui.client_chunk_map_stamp > UPLOAD_CHUNK_MAPS_TIME)
{ {

View File

@ -65,7 +65,7 @@ class ftFileProvider
// Removes inactive peers from the client list. Returns true if all peers have been removed. // Removes inactive peers from the client list. Returns true if all peers have been removed.
// //
bool purgeOldPeers(time_t now,uint32_t max_duration) ; bool purgeOldPeers(rstime_t now,uint32_t max_duration) ;
const RsFileHash& fileHash() const { return hash ; } const RsFileHash& fileHash() const { return hash ; }
const std::string& fileName() const { return file_name ; } const std::string& fileName() const { return file_name ; }
@ -88,12 +88,12 @@ class ftFileProvider
PeerUploadInfo() PeerUploadInfo()
: req_loc(0),req_size(1), lastTS_t(0), lastTS(0),transfer_rate(0), total_size(0), client_chunk_map_stamp(0) {} : req_loc(0),req_size(1), lastTS_t(0), lastTS(0),transfer_rate(0), total_size(0), client_chunk_map_stamp(0) {}
void updateStatus(uint64_t offset,uint32_t data_size,time_t now) ; void updateStatus(uint64_t offset,uint32_t data_size,rstime_t now) ;
uint64_t req_loc; uint64_t req_loc;
uint32_t req_size; uint32_t req_size;
time_t lastTS_t; // used for estimating transfer rate. rstime_t lastTS_t; // used for estimating transfer rate.
time_t lastTS; // last update time (for purging) rstime_t lastTS; // last update time (for purging)
// these two are used for speed estimation // these two are used for speed estimation
float transfer_rate ; float transfer_rate ;
@ -101,7 +101,7 @@ class ftFileProvider
// Info about what the downloading peer already has // Info about what the downloading peer already has
CompressedChunkMap client_chunk_map ; CompressedChunkMap client_chunk_map ;
time_t client_chunk_map_stamp ; rstime_t client_chunk_map_stamp ;
}; };
// Contains statistics (speed, peer name, etc.) of all uploading peers for that file. // Contains statistics (speed, peer name, etc.) of all uploading peers for that file.

View File

@ -52,7 +52,7 @@
#include "util/rsprint.h" #include "util/rsprint.h"
#include <iostream> #include <iostream>
#include <time.h> #include "util/rstime.h"
/*** /***
* #define SERVER_DEBUG 1 * #define SERVER_DEBUG 1
@ -62,8 +62,8 @@
#define FTSERVER_DEBUG() std::cerr << time(NULL) << " : FILE_SERVER : " << __FUNCTION__ << " : " #define FTSERVER_DEBUG() std::cerr << time(NULL) << " : FILE_SERVER : " << __FUNCTION__ << " : "
#define FTSERVER_ERROR() std::cerr << "(EE) FILE_SERVER ERROR : " #define FTSERVER_ERROR() std::cerr << "(EE) FILE_SERVER ERROR : "
static const time_t FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD = 5 ; // low priority tasks handling every 5 seconds static const rstime_t FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD = 5 ; // low priority tasks handling every 5 seconds
static const time_t FILE_TRANSFER_MAX_DELAY_BEFORE_DROP_USAGE_RECORD = 10 ; // keep usage records for 10 secs at most. static const rstime_t FILE_TRANSFER_MAX_DELAY_BEFORE_DROP_USAGE_RECORD = 10 ; // keep usage records for 10 secs at most.
/* Setup */ /* Setup */
ftServer::ftServer(p3PeerMgr *pm, p3ServiceControl *sc) ftServer::ftServer(p3PeerMgr *pm, p3ServiceControl *sc)
@ -1625,8 +1625,8 @@ int ftServer::tick()
if(handleIncoming()) if(handleIncoming())
moreToTick = true; moreToTick = true;
static time_t last_law_priority_tasks_handling_time = 0 ; static rstime_t last_law_priority_tasks_handling_time = 0 ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(last_law_priority_tasks_handling_time + FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD < now) if(last_law_priority_tasks_handling_time + FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD < now)
{ {
@ -1666,10 +1666,10 @@ bool ftServer::checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash)
// Find the latest records for this pid. // Find the latest records for this pid.
std::map<RsFileHash,time_t>& tmap(mUploadLimitMap[pid]) ; std::map<RsFileHash,rstime_t>& tmap(mUploadLimitMap[pid]) ;
std::map<RsFileHash,time_t>::iterator it ; std::map<RsFileHash,rstime_t>::iterator it ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
// If the limit has been decresed, we arbitrarily drop some ongoing slots. // If the limit has been decresed, we arbitrarily drop some ongoing slots.
@ -1694,7 +1694,7 @@ bool ftServer::checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash)
for(it = tmap.begin();it!=tmap.end() && cleaned<2;) for(it = tmap.begin();it!=tmap.end() && cleaned<2;)
if(it->second + FILE_TRANSFER_MAX_DELAY_BEFORE_DROP_USAGE_RECORD < now) if(it->second + FILE_TRANSFER_MAX_DELAY_BEFORE_DROP_USAGE_RECORD < now)
{ {
std::map<RsFileHash,time_t>::iterator tmp(it) ; std::map<RsFileHash,rstime_t>::iterator tmp(it) ;
++tmp; ++tmp;
tmap.erase(it) ; tmap.erase(it) ;
it = tmp; it = tmp;
@ -1859,7 +1859,7 @@ bool ftServer::addConfiguration(p3ConfigMgr *cfgmgr)
bool ftServer::turtleSearchRequest( bool ftServer::turtleSearchRequest(
const std::string& matchString, const std::string& matchString,
const std::function<void (const std::list<TurtleFileInfo>& results)>& multiCallback, const std::function<void (const std::list<TurtleFileInfo>& results)>& multiCallback,
std::time_t maxWait ) rstime_t maxWait )
{ {
if(matchString.empty()) if(matchString.empty())
{ {

View File

@ -149,7 +149,7 @@ public:
virtual bool turtleSearchRequest( virtual bool turtleSearchRequest(
const std::string& matchString, const std::string& matchString,
const std::function<void (const std::list<TurtleFileInfo>& results)>& multiCallback, const std::function<void (const std::list<TurtleFileInfo>& results)>& multiCallback,
std::time_t maxWait = 300 ); rstime_t maxWait = 300 );
virtual TurtleSearchRequestId turtleSearch(const std::string& string_to_match) ; virtual TurtleSearchRequestId turtleSearch(const std::string& string_to_match) ;
virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ; virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ;
@ -326,7 +326,7 @@ private:
std::map<RsFileHash,RsFileHash> mEncryptedHashes ; // This map is such that sha1(it->second) = it->first std::map<RsFileHash,RsFileHash> mEncryptedHashes ; // This map is such that sha1(it->second) = it->first
std::map<RsPeerId,RsFileHash> mEncryptedPeerIds ; // This map holds the hash to be used with each peer id std::map<RsPeerId,RsFileHash> mEncryptedPeerIds ; // This map holds the hash to be used with each peer id
std::map<RsPeerId,std::map<RsFileHash,time_t> > mUploadLimitMap ; std::map<RsPeerId,std::map<RsFileHash,rstime_t> > mUploadLimitMap ;
/** Store search callbacks with timeout*/ /** Store search callbacks with timeout*/
std::map< std::map<

View File

@ -23,7 +23,7 @@
* #define FT_DEBUG 1 * #define FT_DEBUG 1
*****/ *****/
#include <time.h> #include "util/rstime.h"
#include "retroshare/rsturtle.h" #include "retroshare/rsturtle.h"
#include "fttransfermodule.h" #include "fttransfermodule.h"
@ -285,7 +285,7 @@ void ftTransferModule::resetActvTimeStamp()
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/ RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
_last_activity_time_stamp = time(NULL); _last_activity_time_stamp = time(NULL);
} }
time_t ftTransferModule::lastActvTimeStamp() rstime_t ftTransferModule::lastActvTimeStamp()
{ {
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/ RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
return _last_activity_time_stamp ; return _last_activity_time_stamp ;
@ -693,7 +693,7 @@ void ftTransferModule::adjustSpeed()
bool ftTransferModule::locked_tickPeerTransfer(peerInfo &info) bool ftTransferModule::locked_tickPeerTransfer(peerInfo &info)
{ {
/* how long has it been? */ /* how long has it been? */
time_t ts = time(NULL); rstime_t ts = time(NULL);
int ageRecv = ts - info.recvTS; int ageRecv = ts - info.recvTS;
int ageReq = ts - info.lastTS; int ageReq = ts - info.lastTS;
@ -865,7 +865,7 @@ bool ftTransferModule::locked_recvPeerData(peerInfo &info, uint64_t offset, uint
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
time_t ts = time(NULL); rstime_t ts = time(NULL);
info.recvTS = ts; info.recvTS = ts;
info.nResets = 0; info.nResets = 0;
info.state = PQIPEER_DOWNLOADING; info.state = PQIPEER_DOWNLOADING;

View File

@ -76,15 +76,15 @@ public:
double desiredRate; double desiredRate;
double actualRate; double actualRate;
time_t lastTS; /* last Request */ rstime_t lastTS; /* last Request */
time_t recvTS; /* last Recv */ rstime_t recvTS; /* last Recv */
uint32_t lastTransfers; /* data recvd in last second */ uint32_t lastTransfers; /* data recvd in last second */
uint32_t nResets; /* count to disable non-existant files */ uint32_t nResets; /* count to disable non-existant files */
/* rrt rate control */ /* rrt rate control */
uint32_t rtt; /* last rtt */ uint32_t rtt; /* last rtt */
bool rttActive; /* have we initialised an rtt measurement */ bool rttActive; /* have we initialised an rtt measurement */
time_t rttStart; /* ts of request */ rstime_t rttStart; /* ts of request */
uint64_t rttOffset; /* end of request */ uint64_t rttOffset; /* end of request */
float mRateIncrease; /* current rate */ float mRateIncrease; /* current rate */
}; };
@ -156,7 +156,7 @@ public:
void setDownloadPriority(DwlSpeed p) { mPriority =p ; } void setDownloadPriority(DwlSpeed p) { mPriority =p ; }
// read/reset the last time the transfer module was active (either wrote data, or was solicitaded by clients) // read/reset the last time the transfer module was active (either wrote data, or was solicitaded by clients)
time_t lastActvTimeStamp() ; rstime_t lastActvTimeStamp() ;
void resetActvTimeStamp() ; void resetActvTimeStamp() ;
private: private:
@ -185,7 +185,7 @@ private:
double desiredRate; double desiredRate;
double actualRate; double actualRate;
time_t _last_activity_time_stamp ; rstime_t _last_activity_time_stamp ;
ftFileStatus mFileStatus; //used for pause/resume file transfer ftFileStatus mFileStatus; //used for pause/resume file transfer

View File

@ -50,7 +50,7 @@ class GRouterCacheInfo
{ {
public: public:
GRouterCacheInfoFlags flags ; GRouterCacheInfoFlags flags ;
time_t last_activity ; rstime_t last_activity ;
}; };
class GRouterCache class GRouterCache

View File

@ -144,10 +144,10 @@ void RsGRouterRoutingInfoItem::serial_process(RsGenericSerializer::SerializeJob
RsTypeSerializer::serial_process (j,ctx,peerId,"peerId") ; RsTypeSerializer::serial_process (j,ctx,peerId,"peerId") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,data_status,"data_status") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,data_status,"data_status") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_status,"tunnel_status") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_status,"tunnel_status") ;
RsTypeSerializer::serial_process<time_t> (j,ctx,received_time_TS,"received_time_TS") ; RsTypeSerializer::serial_process<rstime_t> (j,ctx,received_time_TS,"received_time_TS") ;
RsTypeSerializer::serial_process<time_t> (j,ctx,last_sent_TS,"last_sent_TS") ; RsTypeSerializer::serial_process<rstime_t> (j,ctx,last_sent_TS,"last_sent_TS") ;
RsTypeSerializer::serial_process<time_t> (j,ctx,last_tunnel_request_TS,"last_tunnel_request_TS") ; RsTypeSerializer::serial_process<rstime_t> (j,ctx,last_tunnel_request_TS,"last_tunnel_request_TS") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,sending_attempts,"sending_attempts") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,sending_attempts,"sending_attempts") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,client_id,"client_id") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,client_id,"client_id") ;
@ -215,7 +215,7 @@ void RsGRouterMatrixTrackItem::serial_process(RsGenericSerializer::SerializeJob
{ {
RsTypeSerializer::serial_process(j,ctx,provider_id,"provider_id") ; RsTypeSerializer::serial_process(j,ctx,provider_id,"provider_id") ;
RsTypeSerializer::serial_process(j,ctx,message_id,"message_id") ; RsTypeSerializer::serial_process(j,ctx,message_id,"message_id") ;
RsTypeSerializer::serial_process<time_t>(j,ctx,time_stamp,"time_stamp") ; RsTypeSerializer::serial_process<rstime_t>(j,ctx,time_stamp,"time_stamp") ;
} }
void RsGRouterMatrixCluesItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) void RsGRouterMatrixCluesItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
@ -228,7 +228,7 @@ template<> void RsTypeSerializer::serial_process(RsGenericSerializer::SerializeJ
{ {
RsTypeSerializer::serial_process<uint32_t>(j,ctx,s.friend_id,name+":friend_id") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,s.friend_id,name+":friend_id") ;
RsTypeSerializer::serial_process<float> (j,ctx,s.weight,name+":weight") ; RsTypeSerializer::serial_process<float> (j,ctx,s.weight,name+":weight") ;
RsTypeSerializer::serial_process<time_t> (j,ctx,s.time_stamp,name+":time_stamp") ; RsTypeSerializer::serial_process<rstime_t> (j,ctx,s.time_stamp,name+":time_stamp") ;
} }
RsGRouterGenericDataItem *RsGRouterGenericDataItem::duplicate() const RsGRouterGenericDataItem *RsGRouterGenericDataItem::duplicate() const

View File

@ -224,7 +224,7 @@ class RsGRouterMatrixTrackItem: public RsGRouterItem
// //
RsGxsMessageId message_id ; RsGxsMessageId message_id ;
RsPeerId provider_id ; RsPeerId provider_id ;
time_t time_stamp ; rstime_t time_stamp ;
}; };
class RsGRouterMatrixFriendListItem: public RsGRouterItem class RsGRouterMatrixFriendListItem: public RsGRouterItem
{ {

View File

@ -36,7 +36,7 @@ GRouterMatrix::GRouterMatrix()
bool GRouterMatrix::addTrackingInfo(const RsGxsMessageId& mid,const RsPeerId& source_friend) bool GRouterMatrix::addTrackingInfo(const RsGxsMessageId& mid,const RsPeerId& source_friend)
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
RoutingTrackEntry rte ; RoutingTrackEntry rte ;
@ -57,7 +57,7 @@ bool GRouterMatrix::cleanUp()
#ifdef ROUTING_MATRIX_DEBUG #ifdef ROUTING_MATRIX_DEBUG
std::cerr << "GRouterMatrix::cleanup()" << std::endl; std::cerr << "GRouterMatrix::cleanup()" << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::map<RsGxsMessageId,RoutingTrackEntry>::iterator it(_tracking_clues.begin());it!=_tracking_clues.end();) for(std::map<RsGxsMessageId,RoutingTrackEntry>::iterator it(_tracking_clues.begin());it!=_tracking_clues.end();)
if(it->second.time_stamp + RS_GROUTER_MAX_KEEP_TRACKING_CLUES < now) if(it->second.time_stamp + RS_GROUTER_MAX_KEEP_TRACKING_CLUES < now)
@ -84,7 +84,7 @@ bool GRouterMatrix::addRoutingClue(const GRouterKeyId& key_id,const RsPeerId& so
// 2 - get the Key map, and add the routing clue. // 2 - get the Key map, and add the routing clue.
// //
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
RoutingMatrixHitEntry rc ; RoutingMatrixHitEntry rc ;
rc.weight = weight ; rc.weight = weight ;
@ -179,7 +179,7 @@ void GRouterMatrix::debugDump() const
std::cerr << " Proba needs up: " << _proba_need_updating << std::endl; std::cerr << " Proba needs up: " << _proba_need_updating << std::endl;
std::cerr << " Known keys: " << _time_combined_hits.size() << std::endl; std::cerr << " Known keys: " << _time_combined_hits.size() << std::endl;
std::cerr << " Routing events: " << std::endl; std::cerr << " Routing events: " << std::endl;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::map<GRouterKeyId, std::list<RoutingMatrixHitEntry> >::const_iterator it(_routing_clues.begin());it!=_routing_clues.end();++it) for(std::map<GRouterKeyId, std::list<RoutingMatrixHitEntry> >::const_iterator it(_routing_clues.begin());it!=_routing_clues.end();++it)
{ {
@ -209,7 +209,7 @@ bool GRouterMatrix::computeRoutingProbabilities(const GRouterKeyId& key_id, cons
{ {
// Routing probabilities are computed according to routing clues // Routing probabilities are computed according to routing clues
// //
// For a given key, each friend has a known set of routing clues (time_t, weight) // For a given key, each friend has a known set of routing clues (rstime_t, weight)
// We combine these to compute a static weight for each friend/key pair. // We combine these to compute a static weight for each friend/key pair.
// This is performed in updateRoutingProbabilities() // This is performed in updateRoutingProbabilities()
// //
@ -271,7 +271,7 @@ bool GRouterMatrix::updateRoutingProbabilities()
if(!_proba_need_updating) if(!_proba_need_updating)
return false ; return false ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::map<GRouterKeyId, std::list<RoutingMatrixHitEntry> >::const_iterator it(_routing_clues.begin());it!=_routing_clues.end();++it) for(std::map<GRouterKeyId, std::list<RoutingMatrixHitEntry> >::const_iterator it(_routing_clues.begin());it!=_routing_clues.end();++it)
{ {

View File

@ -39,13 +39,13 @@ struct RoutingMatrixHitEntry
{ {
uint32_t friend_id ; // not the full key. Gets too big otherwise! uint32_t friend_id ; // not the full key. Gets too big otherwise!
float weight ; float weight ;
time_t time_stamp ; rstime_t time_stamp ;
}; };
struct RoutingTrackEntry struct RoutingTrackEntry
{ {
RsPeerId friend_id ; // not the full key. Gets too big otherwise! RsPeerId friend_id ; // not the full key. Gets too big otherwise!
time_t time_stamp ; rstime_t time_stamp ;
}; };
class GRouterMatrix class GRouterMatrix

View File

@ -22,7 +22,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include <time.h> #include "util/rstime.h"
#include <list> #include <list>
#include "pgp/rscertificate.h" #include "pgp/rscertificate.h"
#include "turtle/p3turtle.h" #include "turtle/p3turtle.h"
@ -56,9 +56,9 @@ static const uint32_t MAX_INACTIVE_DATA_PIPE_DELAY = 300 ; // cl
static const uint32_t GROUTER_MAX_DUPLICATION_FACTOR = 10 ; // max number of duplicates for a given message to keep in the network static const uint32_t GROUTER_MAX_DUPLICATION_FACTOR = 10 ; // max number of duplicates for a given message to keep in the network
static const uint32_t GROUTER_MAX_BRANCHING_FACTOR = 3 ; // max number of branches, for locally forwarding items static const uint32_t GROUTER_MAX_BRANCHING_FACTOR = 3 ; // max number of branches, for locally forwarding items
static const time_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything static const rstime_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything
static const time_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation. static const rstime_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation.
static const time_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 60*10 ; // Check for key advertising every 10 minutes static const rstime_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 60*10 ; // Check for key advertising every 10 minutes
static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME = 2*86400 ; // Cached items are kept for 48 hours at most. static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME = 2*86400 ; // Cached items are kept for 48 hours at most.
static const uint32_t RS_GROUTER_DATA_STATUS_UNKNOWN = 0x0000 ; // unknown. Unused. static const uint32_t RS_GROUTER_DATA_STATUS_UNKNOWN = 0x0000 ; // unknown. Unused.
@ -79,7 +79,7 @@ class FriendTrialRecord
{ {
public: public:
RsPeerId friend_id ; // id of the friend RsPeerId friend_id ; // id of the friend
time_t time_stamp ; // time of the last tried rstime_t time_stamp ; // time of the last tried
float probability ; // probability at which the item was selected float probability ; // probability at which the item was selected
uint32_t nb_friends ; // number of friends at the time of sending the item uint32_t nb_friends ; // number of friends at the time of sending the item
@ -108,9 +108,9 @@ public:
uint32_t data_status ; // pending, waiting, etc. uint32_t data_status ; // pending, waiting, etc.
uint32_t tunnel_status ; // status of tunnel handling. uint32_t tunnel_status ; // status of tunnel handling.
time_t received_time_TS ; // time at which the item was originally received rstime_t received_time_TS ; // time at which the item was originally received
time_t last_sent_TS ; // last time the item was sent rstime_t last_sent_TS ; // last time the item was sent
time_t last_tunnel_request_TS ; // last time tunnels have been asked for this item. rstime_t last_tunnel_request_TS ; // last time tunnels have been asked for this item.
uint32_t sending_attempts ; // number of times tunnels have been asked for this peer without success uint32_t sending_attempts ; // number of times tunnels have been asked for this peer without success
GRouterServiceId client_id ; // service ID of the client. Only valid when origin==OwnId GRouterServiceId client_id ; // service ID of the client. Only valid when origin==OwnId
@ -125,7 +125,7 @@ public:
// non serialised data // non serialised data
time_t data_transaction_TS ; rstime_t data_transaction_TS ;
static const uint32_t ROUTING_FLAGS_ALLOW_TUNNELS = 0x0001; static const uint32_t ROUTING_FLAGS_ALLOW_TUNNELS = 0x0001;
static const uint32_t ROUTING_FLAGS_ALLOW_FRIENDS = 0x0002; static const uint32_t ROUTING_FLAGS_ALLOW_FRIENDS = 0x0002;

View File

@ -218,7 +218,7 @@ p3GRouter::p3GRouter(p3ServiceControl *sc, RsGixs *is)
int p3GRouter::tick() int p3GRouter::tick()
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
// Sort incoming service data // Sort incoming service data
// //
@ -555,7 +555,7 @@ void GRouterTunnelInfo::addVirtualPeer(const TurtleVirtualPeerId& vpid)
virtual_peers.insert(vpid) ; virtual_peers.insert(vpid) ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(first_tunnel_ok_TS == 0) first_tunnel_ok_TS = now ; if(first_tunnel_ok_TS == 0) first_tunnel_ok_TS = now ;
last_tunnel_ok_TS = now ; last_tunnel_ok_TS = now ;
@ -760,7 +760,7 @@ void p3GRouter::handleTunnels()
} }
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
std::vector<std::pair<int,GRouterRoutingInfo*> > priority_list ; std::vector<std::pair<int,GRouterRoutingInfo*> > priority_list ;
for(std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it=_pending_messages.begin();it!=_pending_messages.end();++it) for(std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it=_pending_messages.begin();it!=_pending_messages.end();++it)
@ -893,7 +893,7 @@ void p3GRouter::routePendingObjects()
// Which tunnels are available is handled by handleTunnels() // Which tunnels are available is handled by handleTunnels()
// //
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
RS_STACK_MUTEX(grMtx) ; RS_STACK_MUTEX(grMtx) ;
#ifdef GROUTER_DEBUG #ifdef GROUTER_DEBUG
@ -1220,7 +1220,7 @@ void p3GRouter::locked_collectAvailableFriends(const GRouterKeyId& gxs_id,const
void p3GRouter::locked_collectAvailableTunnels(const TurtleFileHash& hash,uint32_t total_duplication,std::map<RsPeerId,uint32_t>& tunnel_peers_and_duplication_factors) void p3GRouter::locked_collectAvailableTunnels(const TurtleFileHash& hash,uint32_t total_duplication,std::map<RsPeerId,uint32_t>& tunnel_peers_and_duplication_factors)
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
// Now go through available virtual peers. Select the ones that are interesting, and set them as potential destinations. // Now go through available virtual peers. Select the ones that are interesting, and set them as potential destinations.
@ -1304,7 +1304,7 @@ bool p3GRouter::locked_sendTransactionData(const RsPeerId& pid,const RsGRouterTr
void p3GRouter::autoWash() void p3GRouter::autoWash()
{ {
bool items_deleted = false ; bool items_deleted = false ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
std::map<GRouterMsgPropagationId,std::pair<GRouterClientService *,RsGxsId> > failed_msgs ; std::map<GRouterMsgPropagationId,std::pair<GRouterClientService *,RsGxsId> > failed_msgs ;
@ -2158,7 +2158,7 @@ bool p3GRouter::sendData(const RsGxsId& destination,const GRouterServiceId& clie
// //
GRouterRoutingInfo info ; GRouterRoutingInfo info ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
info.data_item = data_item ; info.data_item = data_item ;
info.receipt_item = NULL ; info.receipt_item = NULL ;
@ -2368,7 +2368,7 @@ void p3GRouter::debugDump()
{ {
RS_STACK_MUTEX(grMtx) ; RS_STACK_MUTEX(grMtx) ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
grouter_debug() << "Full dump of Global Router state: " << std::endl; grouter_debug() << "Full dump of Global Router state: " << std::endl;
grouter_debug() << " Owned keys : " << std::endl; grouter_debug() << " Owned keys : " << std::endl;

View File

@ -68,8 +68,8 @@ public:
std::set<TurtleVirtualPeerId> virtual_peers ; std::set<TurtleVirtualPeerId> virtual_peers ;
time_t first_tunnel_ok_TS ; // timestamp when 1st tunnel was received. rstime_t first_tunnel_ok_TS ; // timestamp when 1st tunnel was received.
time_t last_tunnel_ok_TS ; // timestamp when last tunnel was received. rstime_t last_tunnel_ok_TS ; // timestamp when last tunnel was received.
}; };
class GRouterDataInfo class GRouterDataInfo
{ {
@ -87,7 +87,7 @@ public:
RsGRouterAbstractMsgItem *addDataChunk(RsGRouterTransactionChunkItem *chunk_item) ; RsGRouterAbstractMsgItem *addDataChunk(RsGRouterTransactionChunkItem *chunk_item) ;
RsGRouterTransactionChunkItem *incoming_data_buffer ; RsGRouterTransactionChunkItem *incoming_data_buffer ;
time_t last_activity_TS ; rstime_t last_activity_TS ;
}; };
class p3GRouter: public RsGRouter, public RsTurtleClientService, public p3Service, public p3Config class p3GRouter: public RsGRouter, public RsTurtleClientService, public p3Service, public p3Config
@ -346,10 +346,10 @@ private:
bool _changed ; bool _changed ;
bool _debug_enabled ; bool _debug_enabled ;
time_t _last_autowash_time ; rstime_t _last_autowash_time ;
time_t _last_matrix_update_time ; rstime_t _last_matrix_update_time ;
time_t _last_debug_output_time ; rstime_t _last_debug_output_time ;
time_t _last_config_changed ; rstime_t _last_config_changed ;
uint64_t _random_salt ; uint64_t _random_salt ;
}; };

View File

@ -53,7 +53,7 @@ class gxp::Paper
std::string serialnumber; std::string serialnumber;
std::string url; std::string url;
std::list<std::string> authors; std::list<std::string> authors;
time_t date; rstime_t date;
uint32_t startpage; uint32_t startpage;
uint32_t endpage; uint32_t endpage;
std::string language; std::string language;

View File

@ -73,7 +73,7 @@ class gixp::profile
gxip::keyref mKeyId; gxip::keyref mKeyId;
std::string mName; std::string mName;
time_t mTimestamp; /* superseded by newer timestamps */ rstime_t mTimestamp; /* superseded by newer timestamps */
uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgid, gpgsigned), REVOCATION?? */ uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgid, gpgsigned), REVOCATION?? */
gpp::permissions mPermissions; gpp::permissions mPermissions;

View File

@ -157,7 +157,7 @@ class gdp::interface
/* query for available groups & messages */ /* query for available groups & messages */
int listgroups(std::list<gdb::id> &grpIds); int listgroups(std::list<gdb::id> &grpIds);
/* response from listmsgs: -1 = invalid parameters, 0 = incomplete list, 1 = all known msgs */ /* response from listmsgs: -1 = invalid parameters, 0 = incomplete list, 1 = all known msgs */
int listmsgs(const gdp::id grpId, std::list<gdb::id> &msgIds, const time_t from, const time_t to, const int maxmsgs); int listmsgs(const gdp::id grpId, std::list<gdb::id> &msgIds, const rstime_t from, const rstime_t to, const int maxmsgs);
/* response from requestMsg: YES (available immediately), RETRIEVING (known to exist), /* response from requestMsg: YES (available immediately), RETRIEVING (known to exist),
* IN_REQUEST (might exist), NOT_AVAILABLE (still might exist) * IN_REQUEST (might exist), NOT_AVAILABLE (still might exist)
@ -239,8 +239,8 @@ class gnp::exchange: public gdp::interface
/*** IMPLEMENTATION DETAILS ****/ /*** IMPLEMENTATION DETAILS ****/
/* Get/Send Messages */ /* Get/Send Messages */
getAvailableMsgs(gdp::id grpId, time_t from, time_t to); /* request over the network */ getAvailableMsgs(gdp::id grpId, rstime_t from, rstime_t to); /* request over the network */
sendAvailableMsgs(std::string peerId, gdp::id grpId, time_t from, time_t to); /* send to peers */ sendAvailableMsgs(std::string peerId, gdp::id grpId, rstime_t from, rstime_t to); /* send to peers */
requestMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds); requestMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds);
sendMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds); /* send to peer, obviously permissions have been checked first */ sendMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds); /* send to peer, obviously permissions have been checked first */
@ -284,7 +284,7 @@ class gixp::profile
gxip::keyref mKeyId; gxip::keyref mKeyId;
std::string mPseudonym; std::string mPseudonym;
time_t mTimestamp; /* superseded by newer timestamps */ rstime_t mTimestamp; /* superseded by newer timestamps */
uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgname, gpgsigned), REVOCATION?? */ uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgname, gpgsigned), REVOCATION?? */
gpp::permissions mPermissions; gpp::permissions mPermissions;

View File

@ -954,7 +954,7 @@ void RsDataService::locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta)
void RsDataService::locked_clearGrpMetaCache(const RsGxsGroupId& gid) void RsDataService::locked_clearGrpMetaCache(const RsGxsGroupId& gid)
{ {
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
auto it = mGrpMetaDataCache.find(gid) ; auto it = mGrpMetaDataCache.find(gid) ;
// We dont actually delete the item, because it might be used by a calling client. // We dont actually delete the item, because it might be used by a calling client.

View File

@ -345,7 +345,7 @@ private:
void locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta); void locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta);
std::map<RsGxsGroupId,RsGxsGrpMetaData*> mGrpMetaDataCache ; std::map<RsGxsGroupId,RsGxsGrpMetaData*> mGrpMetaDataCache ;
std::list<std::pair<time_t,RsGxsGrpMetaData*> > mOldCachedItems ; std::list<std::pair<rstime_t,RsGxsGrpMetaData*> > mOldCachedItems ;
bool mGrpMetaDataCache_ContainsAllDatabase ; bool mGrpMetaDataCache_ContainsAllDatabase ;
}; };

View File

@ -88,7 +88,7 @@ struct RsGroupNetworkStats
uint32_t mMaxVisibleCount; uint32_t mMaxVisibleCount;
bool mGrpAutoSync; bool mGrpAutoSync;
bool mAllowMsgSync; bool mAllowMsgSync;
time_t mLastGroupModificationTS; rstime_t mLastGroupModificationTS;
}; };
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult; typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;

View File

@ -124,7 +124,7 @@ RsGenExchange::~RsGenExchange()
mGrpsToPublish.clear(); mGrpsToPublish.clear();
} }
bool RsGenExchange::getGroupServerUpdateTS(const RsGxsGroupId& gid, time_t& grp_server_update_TS, time_t& msg_server_update_TS) bool RsGenExchange::getGroupServerUpdateTS(const RsGxsGroupId& gid, rstime_t& grp_server_update_TS, rstime_t& msg_server_update_TS)
{ {
return mNetService->getGroupServerUpdateTS(gid,grp_server_update_TS,msg_server_update_TS) ; return mNetService->getGroupServerUpdateTS(gid,grp_server_update_TS,msg_server_update_TS) ;
} }
@ -169,7 +169,7 @@ void RsGenExchange::tick()
// implemented service tick function // implemented service tick function
service_tick(); service_tick();
time_t now = time(NULL); rstime_t now = time(NULL);
if((mLastClean + MSG_CLEANUP_PERIOD < now) || mCleaning) if((mLastClean + MSG_CLEANUP_PERIOD < now) || mCleaning)
{ {
@ -259,7 +259,7 @@ bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta)
uint32_t st = mNetService->getKeepAge(meta.mGroupId); uint32_t st = mNetService->getKeepAge(meta.mGroupId);
time_t storageTimeLimit = meta.mPublishTs + st; rstime_t storageTimeLimit = meta.mPublishTs + st;
return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || st == 0 || storageTimeLimit >= time(NULL); return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || st == 0 || storageTimeLimit >= time(NULL);
} }
@ -2140,7 +2140,7 @@ void RsGenExchange::publishMsgs()
RS_STACK_MUTEX(mGenMtx) ; RS_STACK_MUTEX(mGenMtx) ;
time_t now = time(NULL); rstime_t now = time(NULL);
// stick back msgs pending signature // stick back msgs pending signature
typedef std::map<uint32_t, GxsPendingItem<RsGxsMsgItem*, uint32_t> > PendSignMap; typedef std::map<uint32_t, GxsPendingItem<RsGxsMsgItem*, uint32_t> > PendSignMap;
@ -2561,7 +2561,7 @@ void RsGenExchange::publishGrps()
GxsGrpPendingSign& ggps = *vit; GxsGrpPendingSign& ggps = *vit;
/* do intial checks to see if this entry has expired */ /* do intial checks to see if this entry has expired */
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
uint32_t token = ggps.mToken; uint32_t token = ggps.mToken;
@ -2869,7 +2869,7 @@ void RsGenExchange::processRecvdMessages()
{ {
RS_STACK_MUTEX(mGenMtx) ; RS_STACK_MUTEX(mGenMtx) ;
time_t now = time(NULL); rstime_t now = time(NULL);
if(mMsgPendingValidate.empty()) if(mMsgPendingValidate.empty())
return ; return ;

View File

@ -23,7 +23,7 @@
#define RSGENEXCHANGE_H #define RSGENEXCHANGE_H
#include <queue> #include <queue>
#include <ctime> #include "util/rstime.h"
#include "rsgxs.h" #include "rsgxs.h"
#include "rsgds.h" #include "rsgds.h"
@ -39,7 +39,7 @@ template<class GxsItem, typename Identity = std::string>
class GxsPendingItem class GxsPendingItem
{ {
public: public:
GxsPendingItem(GxsItem item, Identity id,time_t ts) : GxsPendingItem(GxsItem item, Identity id,rstime_t ts) :
mItem(item), mId(id), mFirstTryTS(ts) mItem(item), mId(id), mFirstTryTS(ts)
{} {}
@ -50,7 +50,7 @@ public:
GxsItem mItem; GxsItem mItem;
Identity mId; Identity mId;
time_t mFirstTryTS; rstime_t mFirstTryTS;
}; };
class GxsGrpPendingSign class GxsGrpPendingSign
@ -61,7 +61,7 @@ public:
mItem(item), mHaveKeys(false), mIsUpdate(false) mItem(item), mHaveKeys(false), mIsUpdate(false)
{} {}
time_t mLastAttemptTS, mStartTS; rstime_t mLastAttemptTS, mStartTS;
uint32_t mToken; uint32_t mToken;
RsGxsGrpItem* mItem; RsGxsGrpItem* mItem;
bool mHaveKeys; // mKeys->first == true if key present bool mHaveKeys; // mKeys->first == true if key present
@ -669,7 +669,7 @@ public:
* when needed. Typical use case is forums and circles. * when needed. Typical use case is forums and circles.
* @param gid GroupId the TS is which is requested * @param gid GroupId the TS is which is requested
*/ */
bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ; bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) ;
/*! /*!
* \brief getDefaultStoragePeriod. All times in seconds. * \brief getDefaultStoragePeriod. All times in seconds.
@ -905,12 +905,12 @@ private:
NxsMsgPendingVect mMsgPendingValidate; NxsMsgPendingVect mMsgPendingValidate;
bool mCleaning; bool mCleaning;
time_t mLastClean; rstime_t mLastClean;
RsGxsMessageCleanUp* mMsgCleanUp; RsGxsMessageCleanUp* mMsgCleanUp;
bool mChecking, mCheckStarted; bool mChecking, mCheckStarted;
time_t mLastCheck; rstime_t mLastCheck;
RsGxsIntegrityCheck* mIntegrityCheck; RsGxsIntegrityCheck* mIntegrityCheck;
protected: protected:

View File

@ -221,7 +221,7 @@ class RsGcxs
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) = 0; virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) = 0;
virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0; virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) =0;
}; };
@ -234,7 +234,7 @@ public:
:RsGenExchange(gds,ns,serviceSerialiser,mServType, gixs, authenPolicy) { return; } :RsGenExchange(gds,ns,serviceSerialiser,mServType, gixs, authenPolicy) { return; }
virtual ~RsGxsCircleExchange() { return; } virtual ~RsGxsCircleExchange() { return; }
virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS)
{ {
return RsGenExchange::getGroupServerUpdateTS(RsGxsGroupId(gid),grp_server_update_TS,msg_server_update_TS) ; return RsGenExchange::getGroupServerUpdateTS(RsGxsGroupId(gid),grp_server_update_TS,msg_server_update_TS) ;
} }

View File

@ -24,9 +24,9 @@
#include <string> #include <string>
#include <retroshare/rstypes.h> #include "retroshare/rstypes.h"
#include "serialiser/rstlvkeys.h" #include "serialiser/rstlvkeys.h"
#include "util/rstime.h"
#include "rsitems/rsgxsitems.h" #include "rsitems/rsgxsitems.h"
struct RsGroupMetaData; struct RsGroupMetaData;
@ -110,7 +110,7 @@ public:
RsTlvKeySignatureSet signSet; RsTlvKeySignatureSet signSet;
std::string mMsgName; std::string mMsgName;
time_t mPublishTs; rstime_t mPublishTs;
uint32_t mMsgFlags; // used by some services (e.g. by forums to store message moderation flags) uint32_t mMsgFlags; // used by some services (e.g. by forums to store message moderation flags)
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG. // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
@ -119,7 +119,7 @@ public:
std::string mServiceString; std::string mServiceString;
uint32_t mMsgStatus; uint32_t mMsgStatus;
uint32_t mMsgSize; uint32_t mMsgSize;
time_t mChildTs; rstime_t mChildTs;
uint32_t recvTS; uint32_t recvTS;
RsFileHash mHash; RsFileHash mHash;
bool validated; bool validated;

View File

@ -20,7 +20,7 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include <time.h> #include "util/rstime.h"
#include "rsgxsutil.h" #include "rsgxsutil.h"
#include "rsgxsdataaccess.h" #include "rsgxsdataaccess.h"
@ -317,7 +317,7 @@ RsTokenService::GxsRequestStatus RsGxsDataAccess::requestStatus(uint32_t token)
RsTokenService::GxsRequestStatus status; RsTokenService::GxsRequestStatus status;
uint32_t reqtype; uint32_t reqtype;
uint32_t anstype; uint32_t anstype;
time_t ts; rstime_t ts;
{ {
RS_STACK_MUTEX(mDataMutex); RS_STACK_MUTEX(mDataMutex);
@ -717,7 +717,7 @@ GxsRequest* RsGxsDataAccess::locked_retrieveRequest(const uint32_t& token)
void RsGxsDataAccess::processRequests() void RsGxsDataAccess::processRequests()
{ {
std::list<uint32_t> toClear; std::list<uint32_t> toClear;
time_t now = time(NULL); rstime_t now = time(NULL);
std::map<uint32_t, GxsRequest*>::iterator it; std::map<uint32_t, GxsRequest*>::iterator it;
{ {
@ -1124,8 +1124,8 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
std::vector<RsGxsMsgMetaData*>::const_iterator vit = metaV.begin(); std::vector<RsGxsMsgMetaData*>::const_iterator vit = metaV.begin();
// RUN THROUGH ALL MSGS... in map origId -> TS. // RUN THROUGH ALL MSGS... in map origId -> TS.
std::map<RsGxsMessageId, std::pair<RsGxsMessageId, time_t> > origMsgTs; std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> > origMsgTs;
std::map<RsGxsMessageId, std::pair<RsGxsMessageId, time_t> >::iterator oit; std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> >::iterator oit;
for(; vit != metaV.end(); ++vit) for(; vit != metaV.end(); ++vit)
{ {
@ -1402,8 +1402,8 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
if (onlyChildMsgs || onlyThreadMsgs) if (onlyChildMsgs || onlyThreadMsgs)
{ {
// RUN THROUGH ALL MSGS... in map origId -> TS. // RUN THROUGH ALL MSGS... in map origId -> TS.
std::map<RsGxsMessageId, std::pair<RsGxsMessageId, time_t> > origMsgTs; std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> > origMsgTs;
std::map<RsGxsMessageId, std::pair<RsGxsMessageId, time_t> >::iterator oit; std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> >::iterator oit;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
{ {
@ -1472,7 +1472,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
{ {
/* first guess is potentially better than Orig (can't be worse!) */ /* first guess is potentially better than Orig (can't be worse!) */
time_t latestTs = 0; rstime_t latestTs = 0;
RsGxsMessageId latestMsgId; RsGxsMessageId latestMsgId;
RsGxsMsgMetaData* latestMeta=NULL; RsGxsMsgMetaData* latestMeta=NULL;
@ -1760,7 +1760,7 @@ void RsGxsDataAccess::filterGrpList(std::list<RsGxsGroupId> &grpIds, const RsTok
bool RsGxsDataAccess::checkRequestStatus( bool RsGxsDataAccess::checkRequestStatus(
uint32_t token, GxsRequestStatus& status, uint32_t& reqtype, uint32_t token, GxsRequestStatus& status, uint32_t& reqtype,
uint32_t& anstype, time_t& ts ) uint32_t& anstype, rstime_t& ts )
{ {
RS_STACK_MUTEX(mDataMutex); RS_STACK_MUTEX(mDataMutex);

View File

@ -314,7 +314,7 @@ private:
* @return false if token does not exist, true otherwise * @return false if token does not exist, true otherwise
*/ */
bool checkRequestStatus( uint32_t token, GxsRequestStatus &status, bool checkRequestStatus( uint32_t token, GxsRequestStatus &status,
uint32_t &reqtype, uint32_t &anstype, time_t &ts); uint32_t &reqtype, uint32_t &anstype, rstime_t &ts);
// special ones for testing (not in final design) // special ones for testing (not in final design)
/*! /*!

View File

@ -327,7 +327,7 @@ static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_CHANNELS ;
class nullstream: public std::ostream {}; class nullstream: public std::ostream {};
static std::string nice_time_stamp(time_t now,time_t TS) static std::string nice_time_stamp(rstime_t now,rstime_t TS)
{ {
if(TS == 0) if(TS == 0)
return "Never" ; return "Never" ;
@ -448,8 +448,8 @@ int RsGxsNetService::tick()
if(should_notify) if(should_notify)
processObserverNotifications() ; processObserverNotifications() ;
time_t now = time(NULL); rstime_t now = time(NULL);
time_t elapsed = mSYNC_PERIOD + mSyncTs; rstime_t elapsed = mSYNC_PERIOD + mSyncTs;
if((elapsed) < now) if((elapsed) < now)
{ {
@ -525,20 +525,20 @@ void RsGxsNetService::rejectMessage(const RsGxsMessageId& msg_id)
void RsGxsNetService::cleanRejectedMessages() void RsGxsNetService::cleanRejectedMessages()
{ {
RS_STACK_MUTEX(mNxsMutex) ; RS_STACK_MUTEX(mNxsMutex) ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
#ifdef NXS_NET_DEBUG_0 #ifdef NXS_NET_DEBUG_0
GXSNETDEBUG___ << "Cleaning rejected messages." << std::endl; GXSNETDEBUG___ << "Cleaning rejected messages." << std::endl;
#endif #endif
for(std::map<RsGxsMessageId,time_t>::iterator it(mRejectedMessages.begin());it!=mRejectedMessages.end();) for(std::map<RsGxsMessageId,rstime_t>::iterator it(mRejectedMessages.begin());it!=mRejectedMessages.end();)
if(it->second + REJECTED_MESSAGE_RETRY_DELAY < now) if(it->second + REJECTED_MESSAGE_RETRY_DELAY < now)
{ {
#ifdef NXS_NET_DEBUG_0 #ifdef NXS_NET_DEBUG_0
GXSNETDEBUG___ << " message id " << it->first << " should be re-tried. removing from list..." << std::endl; GXSNETDEBUG___ << " message id " << it->first << " should be re-tried. removing from list..." << std::endl;
#endif #endif
std::map<RsGxsMessageId,time_t>::iterator tmp = it ; std::map<RsGxsMessageId,rstime_t>::iterator tmp = it ;
++tmp ; ++tmp ;
mRejectedMessages.erase(it) ; mRejectedMessages.erase(it) ;
it=tmp ; it=tmp ;
@ -854,7 +854,7 @@ void RsGxsNetService::syncGrpStatistics()
// Go through group statistics and groups without information are re-requested to random peers selected // Go through group statistics and groups without information are re-requested to random peers selected
// among the ones who provided the group info. // among the ones who provided the group info.
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(auto it(grpMeta.begin());it!=grpMeta.end();++it) for(auto it(grpMeta.begin());it!=grpMeta.end();++it)
{ {
@ -1591,7 +1591,7 @@ bool RsGxsNetService::loadList(std::list<RsItem *> &load)
// The delete is done in StoreHere, if necessary // The delete is done in StoreHere, if necessary
std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mServerGrpConfigMap, mGrpServerUpdate)); std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mServerGrpConfigMap, mGrpServerUpdate));
time_t now = time(NULL); rstime_t now = time(NULL);
// We reset group statistics here. This is the best place since we know at this point which are all unsubscribed groups. // We reset group statistics here. This is the best place since we know at this point which are all unsubscribed groups.
@ -2018,7 +2018,7 @@ void RsGxsNetService::debugDump()
{ {
#ifdef NXS_NET_DEBUG_0 #ifdef NXS_NET_DEBUG_0
RS_STACK_MUTEX(mNxsMutex) ; RS_STACK_MUTEX(mNxsMutex) ;
//time_t now = time(NULL) ; //rstime_t now = time(NULL) ;
GXSNETDEBUG___<< "RsGxsNetService::debugDump():" << std::endl; GXSNETDEBUG___<< "RsGxsNetService::debugDump():" << std::endl;
@ -2160,8 +2160,8 @@ void RsGxsNetService::updateServerSyncTS()
// ask to the GxsNetService of circles what the server TS is for that circle. If more recent, we update the serverTS of the // ask to the GxsNetService of circles what the server TS is for that circle. If more recent, we update the serverTS of the
// local group // local group
time_t circle_group_server_ts ; rstime_t circle_group_server_ts ;
time_t circle_msg_server_ts ; rstime_t circle_msg_server_ts ;
// This call needs to be off-mutex, because of self-restricted circles. // This call needs to be off-mutex, because of self-restricted circles.
// Normally we should update as a function of MsgServerUpdateTS and the mRecvTS of the circle, not the global grpServerTS. // Normally we should update as a function of MsgServerUpdateTS and the mRecvTS of the circle, not the global grpServerTS.
@ -2653,7 +2653,7 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << " type = msgs." << std::endl; GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << " type = msgs." << std::endl;
#endif #endif
RsGxsGroupId grpId; RsGxsGroupId grpId;
//time_t now = time(NULL) ; //rstime_t now = time(NULL) ;
while(tr->mItems.size() > 0) while(tr->mItems.size() > 0)
{ {
@ -3106,7 +3106,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
} }
} }
void RsGxsNetService::locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,time_t tm,uint32_t n_messages) void RsGxsNetService::locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,rstime_t tm,uint32_t n_messages)
{ {
RsGxsMsgUpdate& up(mClientMsgUpdateMap[pid]); RsGxsMsgUpdate& up(mClientMsgUpdateMap[pid]);
@ -4380,7 +4380,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
uint32_t transN = locked_getTransactionId(); uint32_t transN = locked_getTransactionId();
RsGxsCircleId should_encrypt_to_this_circle_id ; RsGxsCircleId should_encrypt_to_this_circle_id ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
uint32_t max_send_delay = locked_getGrpConfig(item->grpId).msg_req_delay; // we should use "sync" but there's only one variable used in the GUI: the req one. uint32_t max_send_delay = locked_getGrpConfig(item->grpId).msg_req_delay; // we should use "sync" but there's only one variable used in the GUI: the req one.
@ -5024,7 +5024,7 @@ void RsGxsNetService::handleRecvPublishKeys(RsNxsGroupPublishKeyItem *item)
} }
} }
bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& group_server_update_TS, time_t& msg_server_update_TS) bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& group_server_update_TS, rstime_t& msg_server_update_TS)
{ {
RS_STACK_MUTEX(mNxsMutex) ; RS_STACK_MUTEX(mNxsMutex) ;
@ -5112,7 +5112,7 @@ TurtleRequestId RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id
{ {
RS_STACK_MUTEX(mNxsMutex) ; RS_STACK_MUTEX(mNxsMutex) ;
time_t now = time(NULL); rstime_t now = time(NULL);
auto it = mSearchedGroups.find(group_id) ; auto it = mSearchedGroups.find(group_id) ;
if(mSearchedGroups.end() != it && (it->second.ts + MIN_DELAY_BETWEEN_GROUP_SEARCH > now)) if(mSearchedGroups.end() != it && (it->second.ts + MIN_DELAY_BETWEEN_GROUP_SEARCH > now))
@ -5309,7 +5309,7 @@ bool RsGxsNetService::search( const std::string& substring,
if((rit = uQ.find("signFlags")) != uQ.end()) if((rit = uQ.find("signFlags")) != uQ.end())
s.mSignFlags = std::stoul(rit->second); s.mSignFlags = std::stoul(rit->second);
if((rit = uQ.find("publishTs")) != uQ.end()) if((rit = uQ.find("publishTs")) != uQ.end())
s.mPublishTs = static_cast<time_t>(std::stoll(rit->second)); s.mPublishTs = static_cast<rstime_t>(std::stoll(rit->second));
if((rit = uQ.find("authorId")) != uQ.end()) if((rit = uQ.find("authorId")) != uQ.end())
s.mAuthorId = RsGxsId(rit->second); s.mAuthorId = RsGxsId(rit->second);

View File

@ -52,14 +52,14 @@ class RsGroupNetworkStatsRecord
std::set<RsPeerId> suppliers ; std::set<RsPeerId> suppliers ;
uint32_t max_visible_count ; uint32_t max_visible_count ;
time_t update_TS ; rstime_t update_TS ;
}; };
struct GroupRequestRecord struct GroupRequestRecord
{ {
GroupRequestRecord(): ts(0), request_id(0) {} GroupRequestRecord(): ts(0), request_id(0) {}
time_t ts ; rstime_t ts ;
TurtleRequestId request_id; TurtleRequestId request_id;
}; };
@ -188,7 +188,7 @@ public:
virtual void rejectMessage(const RsGxsMessageId& msg_id) ; virtual void rejectMessage(const RsGxsMessageId& msg_id) ;
virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ; virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) ;
virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ; virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ;
virtual bool removeGroups(const std::list<RsGxsGroupId>& groups); virtual bool removeGroups(const std::list<RsGxsGroupId>& groups);
virtual bool isDistantPeer(const RsPeerId& pid); virtual bool isDistantPeer(const RsPeerId& pid);
@ -507,7 +507,7 @@ private:
* stamp the group info from that particular peer at the given time. * stamp the group info from that particular peer at the given time.
*/ */
void locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,time_t tm,uint32_t n_messages) ; void locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,rstime_t tm,uint32_t n_messages) ;
/*! /*!
* encrypts/decrypts the transaction for the destination circle id. * encrypts/decrypts the transaction for the destination circle id.
@ -602,7 +602,7 @@ private:
RsGxsServerGrpUpdate mGrpServerUpdate; RsGxsServerGrpUpdate mGrpServerUpdate;
RsServiceInfo mServiceInfo; RsServiceInfo mServiceInfo;
std::map<RsGxsMessageId,time_t> mRejectedMessages; std::map<RsGxsMessageId,rstime_t> mRejectedMessages;
std::vector<RsNxsGrp*> mNewGroupsToNotify ; std::vector<RsNxsGrp*> mNewGroupsToNotify ;
std::vector<RsNxsMsg*> mNewMessagesToNotify ; std::vector<RsNxsMsg*> mNewMessagesToNotify ;
@ -620,7 +620,7 @@ private:
std::map<Sha1CheckSum, RsNxsGrp*> mGroupHashCache; std::map<Sha1CheckSum, RsNxsGrp*> mGroupHashCache;
std::map<TurtleRequestId,RsGxsGroupId> mSearchRequests; std::map<TurtleRequestId,RsGxsGroupId> mSearchRequests;
std::map<RsGxsGroupId,GroupRequestRecord> mSearchedGroups ; std::map<RsGxsGroupId,GroupRequestRecord> mSearchedGroups ;
time_t mLastCacheReloadTS ; rstime_t mLastCacheReloadTS ;
}; };
#endif // RSGXSNETSERVICE_H #endif // RSGXSNETSERVICE_H

View File

@ -732,7 +732,7 @@ void RsGxsNetTunnelService::data_tick()
mPendingTurtleItems.pop_front(); mPendingTurtleItems.pop_front();
} }
time_t now = time(NULL); rstime_t now = time(NULL);
// cleanup // cleanup

View File

@ -270,8 +270,8 @@ private:
friend class RsGxsTunnelRandomBiasItem ; friend class RsGxsTunnelRandomBiasItem ;
friend class StoreHere ; friend class StoreHere ;
time_t mLastKeepAlive ; rstime_t mLastKeepAlive ;
time_t mLastAutoWash ; rstime_t mLastAutoWash ;
time_t mLastDump ; rstime_t mLastDump ;
}; };

View File

@ -24,11 +24,11 @@
#include "pqi/p3servicecontrol.h" #include "pqi/p3servicecontrol.h"
#include "pgp/pgpauxutils.h" #include "pgp/pgpauxutils.h"
const time_t AuthorPending::EXPIRY_PERIOD_OFFSET = 30; // 30 seconds const rstime_t AuthorPending::EXPIRY_PERIOD_OFFSET = 30; // 30 seconds
const int AuthorPending::MSG_PEND = 1; const int AuthorPending::MSG_PEND = 1;
const int AuthorPending::GRP_PEND = 2; const int AuthorPending::GRP_PEND = 2;
AuthorPending::AuthorPending(RsGixsReputation* rep, time_t timeStamp) : mRep(rep), mTimeStamp(timeStamp) {} AuthorPending::AuthorPending(RsGixsReputation* rep, rstime_t timeStamp) : mRep(rep), mTimeStamp(timeStamp) {}
AuthorPending::~AuthorPending() {} AuthorPending::~AuthorPending() {}
@ -197,7 +197,7 @@ void RsNxsNetMgrImpl::getOnlineList(const uint32_t serviceId, std::set<RsPeerId>
mServiceCtrl->getPeersConnected(serviceId, ssl_peers); mServiceCtrl->getPeersConnected(serviceId, ssl_peers);
} }
const time_t GrpCircleVetting::EXPIRY_PERIOD_OFFSET = 5; // 10 seconds const rstime_t GrpCircleVetting::EXPIRY_PERIOD_OFFSET = 5; // 10 seconds
const int GrpCircleVetting::GRP_ID_PEND = 1; const int GrpCircleVetting::GRP_ID_PEND = 1;
const int GrpCircleVetting::GRP_ITEM_PEND = 2; const int GrpCircleVetting::GRP_ITEM_PEND = 2;
const int GrpCircleVetting::MSG_ID_SEND_PEND = 3; const int GrpCircleVetting::MSG_ID_SEND_PEND = 3;

View File

@ -114,9 +114,9 @@ public:
static const int MSG_PEND; static const int MSG_PEND;
static const int GRP_PEND; static const int GRP_PEND;
static const time_t EXPIRY_PERIOD_OFFSET; static const rstime_t EXPIRY_PERIOD_OFFSET;
AuthorPending(RsGixsReputation* rep, time_t timeStamp); AuthorPending(RsGixsReputation* rep, rstime_t timeStamp);
virtual ~AuthorPending(); virtual ~AuthorPending();
virtual int getType() const = 0 ; virtual int getType() const = 0 ;
@ -144,7 +144,7 @@ protected:
private: private:
RsGixsReputation* mRep; RsGixsReputation* mRep;
time_t mTimeStamp; rstime_t mTimeStamp;
}; };
class MsgAuthEntry class MsgAuthEntry
@ -237,7 +237,7 @@ class GrpCircleVetting
{ {
public: public:
static const time_t EXPIRY_PERIOD_OFFSET; static const rstime_t EXPIRY_PERIOD_OFFSET;
static const int GRP_ID_PEND; static const int GRP_ID_PEND;
static const int GRP_ITEM_PEND; static const int GRP_ITEM_PEND;
static const int MSG_ID_SEND_PEND; static const int MSG_ID_SEND_PEND;
@ -255,7 +255,7 @@ protected:
RsGcxs* const mCircles; RsGcxs* const mCircles;
PgpAuxUtils *mPgpUtils; PgpAuxUtils *mPgpUtils;
time_t mTimeStamp; rstime_t mTimeStamp;
}; };
class GrpCircleIdRequestVetting : public GrpCircleVetting class GrpCircleIdRequestVetting : public GrpCircleVetting

View File

@ -21,7 +21,7 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include <time.h> #include "util/rstime.h"
#include "rsgxsutil.h" #include "rsgxsutil.h"
#include "retroshare/rsgxsflags.h" #include "retroshare/rsgxsflags.h"
@ -57,7 +57,7 @@ bool RsGxsMessageCleanUp::clean()
{ {
uint32_t i = 1; uint32_t i = 1;
time_t now = time(NULL); rstime_t now = time(NULL);
#ifdef DEBUG_GXSUTIL #ifdef DEBUG_GXSUTIL
uint16_t service_type = mGenExchangeClient->serviceType() ; uint16_t service_type = mGenExchangeClient->serviceType() ;

View File

@ -28,7 +28,7 @@
#include <set> #include <set>
#include <string> #include <string>
#include <time.h> #include "util/rstime.h"
#include <stdlib.h> #include <stdlib.h>
#include <list> #include <list>
#include <map> #include <map>
@ -220,7 +220,7 @@ public:
* \param tm time stamp computed * \param tm time stamp computed
* \return false if the group is not found, true otherwise * \return false if the group is not found, true otherwise
*/ */
virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0; virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) =0;
/*! /*!
* \brief stampMsgServerUpdateTS * \brief stampMsgServerUpdateTS

View File

@ -482,7 +482,7 @@ void p3GxsTrans::service_tick()
{ {
GxsTokenQueue::checkRequests(); GxsTokenQueue::checkRequests();
time_t now = time(NULL); rstime_t now = time(NULL);
bool changed = false ; bool changed = false ;
if(mLastMsgCleanup + MAX_DELAY_BETWEEN_CLEANUPS < now) if(mLastMsgCleanup + MAX_DELAY_BETWEEN_CLEANUPS < now)

View File

@ -175,7 +175,7 @@ private:
*/ */
static const uint32_t MAX_DELAY_BETWEEN_CLEANUPS ; // every 20 mins. Could be less. static const uint32_t MAX_DELAY_BETWEEN_CLEANUPS ; // every 20 mins. Could be less.
time_t mLastMsgCleanup ; rstime_t mLastMsgCleanup ;
/// Define how the backend should handle authentication based on signatures /// Define how the backend should handle authentication based on signatures
static uint32_t AuthenPolicy(); static uint32_t AuthenPolicy();
@ -272,8 +272,8 @@ private:
/** @return true if has passed more then interval seconds between timeStamp /** @return true if has passed more then interval seconds between timeStamp
* and ref. @param ref by default now is taked as reference. */ * and ref. @param ref by default now is taked as reference. */
bool static inline olderThen(time_t timeStamp, int32_t interval, bool static inline olderThen(rstime_t timeStamp, int32_t interval,
time_t ref = time(NULL)) rstime_t ref = time(NULL))
{ return (timeStamp + interval) < ref; } { return (timeStamp + interval) < ref; }

View File

@ -101,8 +101,8 @@ int p3GxsTunnelService::tick()
{ {
#ifdef DEBUG_GXS_TUNNEL #ifdef DEBUG_GXS_TUNNEL
time_t now = time(NULL); rstime_t now = time(NULL);
static time_t last_dump = 0; static rstime_t last_dump = 0;
if(now > last_dump + INTERVAL_BETWEEN_DEBUG_DUMP ) if(now > last_dump + INTERVAL_BETWEEN_DEBUG_DUMP )
{ {
@ -171,7 +171,7 @@ void p3GxsTunnelService::flush()
{ {
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::map<uint64_t, GxsTunnelData>::iterator it = pendingGxsTunnelDataItems.begin();it != pendingGxsTunnelDataItems.end();++it) for(std::map<uint64_t, GxsTunnelData>::iterator it = pendingGxsTunnelDataItems.begin();it != pendingGxsTunnelDataItems.end();++it)
if(now > RS_GXS_TUNNEL_DELAY_BETWEEN_RESEND + it->second.last_sending_attempt) if(now > RS_GXS_TUNNEL_DELAY_BETWEEN_RESEND + it->second.last_sending_attempt)
@ -194,7 +194,7 @@ void p3GxsTunnelService::flush()
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::iterator it(_gxs_tunnel_contacts.begin());it!=_gxs_tunnel_contacts.end();) for(std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::iterator it(_gxs_tunnel_contacts.begin());it!=_gxs_tunnel_contacts.end();)
{ {
@ -256,13 +256,13 @@ void p3GxsTunnelService::flush()
// clean old received data prints. // clean old received data prints.
for(std::map<uint64_t,time_t>::iterator it2=it->second.received_data_prints.begin();it2!=it->second.received_data_prints.end();) for(std::map<uint64_t,rstime_t>::iterator it2=it->second.received_data_prints.begin();it2!=it->second.received_data_prints.end();)
if(now > it2->second + RS_GXS_TUNNEL_DATA_PRINT_STORAGE_DELAY) if(now > it2->second + RS_GXS_TUNNEL_DATA_PRINT_STORAGE_DELAY)
{ {
#ifdef DEBUG_GXS_TUNNEL #ifdef DEBUG_GXS_TUNNEL
std::cerr << "(II) erasing old data print for message #" << it2->first << " in tunnel " << it->first << std::endl; std::cerr << "(II) erasing old data print for message #" << it2->first << " in tunnel " << it->first << std::endl;
#endif #endif
std::map<uint64_t,time_t>::iterator tmp(it2) ; std::map<uint64_t,rstime_t>::iterator tmp(it2) ;
++tmp ; ++tmp ;
it->second.received_data_prints.erase(it2) ; it->second.received_data_prints.erase(it2) ;
it2 = tmp ; it2 = tmp ;
@ -1445,7 +1445,7 @@ void p3GxsTunnelService::startClientGxsTunnelConnection(const RsGxsId& to_gxs_id
GxsTunnelPeerInfo info ; GxsTunnelPeerInfo info ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
info.last_contact = now ; info.last_contact = now ;
info.last_keep_alive_sent = now ; info.last_keep_alive_sent = now ;
@ -1639,7 +1639,7 @@ void p3GxsTunnelService::debug_dump()
{ {
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
std::cerr << "p3GxsTunnelService::debug_dump()" << std::endl; std::cerr << "p3GxsTunnelService::debug_dump()" << std::endl;
std::cerr << " Registered client services: " << std::endl; std::cerr << " Registered client services: " << std::endl;

View File

@ -157,8 +157,8 @@ private:
total_received = 0 ; total_received = 0 ;
} }
time_t last_contact ; // used to keep track of working connexion rstime_t last_contact ; // used to keep track of working connexion
time_t last_keep_alive_sent ; // last time we sent a keep alive packet. rstime_t last_keep_alive_sent ; // last time we sent a keep alive packet.
unsigned char aes_key[GXS_TUNNEL_AES_KEY_SIZE] ; unsigned char aes_key[GXS_TUNNEL_AES_KEY_SIZE] ;
@ -169,7 +169,7 @@ private:
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server. RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
TurtleFileHash hash ; // hash that is last used. This is necessary for handling tunnel establishment TurtleFileHash hash ; // hash that is last used. This is necessary for handling tunnel establishment
std::set<uint32_t> client_services ;// services that used this tunnel std::set<uint32_t> client_services ;// services that used this tunnel
std::map<uint64_t,time_t> received_data_prints ; // list of recently received messages, to avoid duplicates. Kept for 20 mins at most. std::map<uint64_t,rstime_t> received_data_prints ; // list of recently received messages, to avoid duplicates. Kept for 20 mins at most.
uint32_t total_sent ; uint32_t total_sent ;
uint32_t total_received ; uint32_t total_received ;
}; };
@ -191,7 +191,7 @@ private:
struct GxsTunnelData struct GxsTunnelData
{ {
RsGxsTunnelDataItem *data_item ; RsGxsTunnelDataItem *data_item ;
time_t last_sending_attempt ; rstime_t last_sending_attempt ;
}; };
// This maps contains the current peers to talk to with distant chat. // This maps contains the current peers to talk to with distant chat.

View File

@ -21,7 +21,7 @@
*******************************************************************************/ *******************************************************************************/
#include <stdexcept> #include <stdexcept>
#include <time.h> #include "util/rstime.h"
#include "serialiser/rsbaseserial.h" #include "serialiser/rsbaseserial.h"
#include "serialiser/rstlvbase.h" #include "serialiser/rstlvbase.h"
#include "serialiser/rstypeserializer.h" #include "serialiser/rstypeserializer.h"

View File

@ -18,7 +18,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <ctime> #include "util/rstime.h"
#include <cstdint> #include <cstdint>
#include <set> #include <set>

View File

@ -601,8 +601,8 @@ const ops_keydata_t *PGPHandler::locked_getPublicKey(const RsPgpId& id,bool stam
{ {
if(stamp_the_key) // Should we stamp the key as used? if(stamp_the_key) // Should we stamp the key as used?
{ {
static time_t last_update_db_because_of_stamp = 0 ; static rstime_t last_update_db_because_of_stamp = 0 ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
res->second._time_stamp = now ; res->second._time_stamp = now ;

View File

@ -57,7 +57,7 @@ class PGPCertificateInfo
uint32_t _flags ; uint32_t _flags ;
uint32_t _type ; uint32_t _type ;
mutable time_t _time_stamp ; // last time the key was used (received, used for signature verification, etc) mutable rstime_t _time_stamp ; // last time the key was used (received, used for signature verification, etc)
PGPFingerprintType _fpr; /* fingerprint */ PGPFingerprintType _fpr; /* fingerprint */
// RsPgpId _key_id ; // RsPgpId _key_id ;
@ -220,9 +220,9 @@ class PGPHandler
bool _pubring_changed ; bool _pubring_changed ;
mutable bool _trustdb_changed ; mutable bool _trustdb_changed ;
time_t _pubring_last_update_time ; rstime_t _pubring_last_update_time ;
time_t _secring_last_update_time ; rstime_t _secring_last_update_time ;
time_t _trustdb_last_update_time ; rstime_t _trustdb_last_update_time ;
// Helper functions. // Helper functions.
// //

View File

@ -421,7 +421,7 @@ RsServiceControl *RsPluginManager::getServiceControl() const
assert(_service_control); assert(_service_control);
return _service_control ; return _service_control ;
} }
void RsPluginManager::slowTickPlugins(time_t seconds) void RsPluginManager::slowTickPlugins(rstime_t seconds)
{ {
for(uint32_t i=0;i<_plugins.size();++i) for(uint32_t i=0;i<_plugins.size();++i)
if(_plugins[i].plugin != NULL && _plugins[i].plugin->rs_cache_service() != NULL && (seconds % _plugins[i].plugin->rs_cache_service()->tickDelay() )) if(_plugins[i].plugin != NULL && _plugins[i].plugin->rs_cache_service() != NULL && (seconds % _plugins[i].plugin->rs_cache_service()->tickDelay() ))

View File

@ -78,7 +78,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config
virtual void enablePlugin(const RsFileHash& hash) ; virtual void enablePlugin(const RsFileHash& hash) ;
virtual void disablePlugin(const RsFileHash &hash) ; virtual void disablePlugin(const RsFileHash &hash) ;
virtual void slowTickPlugins(time_t sec) ; virtual void slowTickPlugins(rstime_t sec) ;
virtual const std::string& getLocalCacheDir() const ; virtual const std::string& getLocalCacheDir() const ;
virtual const std::string& getRemoteCacheDir() const ; virtual const std::string& getRemoteCacheDir() const ;
virtual RsServiceControl *getServiceControl() const ; virtual RsServiceControl *getServiceControl() const ;

View File

@ -44,7 +44,7 @@
//#define DEBUG_AUTHGPG 1 //#define DEBUG_AUTHGPG 1
//const time_t STORE_KEY_TIMEOUT = 1 * 60 * 60; //store key is call around every hour //const rstime_t STORE_KEY_TIMEOUT = 1 * 60 * 60; //store key is call around every hour
AuthGPG *AuthGPG::_instance = NULL ; AuthGPG *AuthGPG::_instance = NULL ;

View File

@ -288,7 +288,7 @@ public:
RsMutex gpgMtxData; RsMutex gpgMtxData;
/* Below is protected via the mutex */ /* Below is protected via the mutex */
time_t mStoreKeyTime; rstime_t mStoreKeyTime;
RsPgpId mOwnGpgId; RsPgpId mOwnGpgId;
bool gpgKeySelected; bool gpgKeySelected;

View File

@ -27,7 +27,7 @@
#include <iomanip> #include <iomanip>
#include <stdio.h> #include <stdio.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <time.h> #include "util/rstime.h"
#include "pqi/p3dhtmgr.h" #include "pqi/p3dhtmgr.h"
#include "pqi/p3peermgr.h" #include "pqi/p3peermgr.h"
@ -322,7 +322,7 @@ bool p3DhtMgr::notifyPeer(const RsPeerId& id)
} }
time_t now = time(NULL); rstime_t now = time(NULL);
if (now - it->second.notifyTS < 2 * DHT_NOTIFY_PERIOD) if (now - it->second.notifyTS < 2 * DHT_NOTIFY_PERIOD)
{ {
@ -578,7 +578,7 @@ void p3DhtMgr::run()
int p3DhtMgr::checkOwnDHTKeys() int p3DhtMgr::checkOwnDHTKeys()
{ {
int repubPeriod = 10000; int repubPeriod = 10000;
time_t now = time(NULL); rstime_t now = time(NULL);
/* in order of importance: /* in order of importance:
* (1) Check for Own Key publish. * (1) Check for Own Key publish.
@ -777,12 +777,12 @@ int p3DhtMgr::checkPeerDHTKeys()
/* iterate through and find min time and suitable candidate */ /* iterate through and find min time and suitable candidate */
std::map<RsPeerId, dhtPeerEntry>::iterator it,pit; std::map<RsPeerId, dhtPeerEntry>::iterator it,pit;
time_t now = time(NULL); rstime_t now = time(NULL);
uint32_t period = 0; uint32_t period = 0;
uint32_t repeatPeriod = 6000; uint32_t repeatPeriod = 6000;
pit = peers.end(); pit = peers.end();
time_t pTS = now; rstime_t pTS = now;
for(it = peers.begin(); it != peers.end(); it++) for(it = peers.begin(); it != peers.end(); it++)
{ {
@ -792,7 +792,7 @@ int p3DhtMgr::checkPeerDHTKeys()
continue; continue;
} }
time_t delta = now - it->second.lastTS; rstime_t delta = now - it->second.lastTS;
if (it->second.state < DHT_PEER_FOUND) if (it->second.state < DHT_PEER_FOUND)
{ {
period = DHT_SEARCH_PERIOD; period = DHT_SEARCH_PERIOD;
@ -866,7 +866,7 @@ int p3DhtMgr::checkNotifyDHT()
/* iterate through and find min time and suitable candidate */ /* iterate through and find min time and suitable candidate */
std::map<RsPeerId, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
time_t now = time(NULL); rstime_t now = time(NULL);
int repeatPeriod = DHT_DEFAULT_PERIOD; int repeatPeriod = DHT_DEFAULT_PERIOD;
/* find the first with a notify flag */ /* find the first with a notify flag */
@ -1084,7 +1084,7 @@ bool p3DhtMgr::getDhtBootstrapList()
#endif #endif
dhtMtx.lock(); /* LOCK MUTEX */ dhtMtx.lock(); /* LOCK MUTEX */
time_t now = time(NULL); rstime_t now = time(NULL);
if (now - mLastBootstrapListTS < DHT_MIN_BOOTSTRAP_REQ_PERIOD) if (now - mLastBootstrapListTS < DHT_MIN_BOOTSTRAP_REQ_PERIOD)
{ {
#ifdef DHT_DEBUG #ifdef DHT_DEBUG
@ -1623,7 +1623,7 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash)
std::cerr << RsUtil::BinToHex(idhash) << std::endl; std::cerr << RsUtil::BinToHex(idhash) << std::endl;
#endif #endif
std::map<RsPeerId, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
time_t now = time(NULL); rstime_t now = time(NULL);
/* if notify - we must match on the second hash */ /* if notify - we must match on the second hash */
for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ; for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ;
@ -1679,7 +1679,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
bool doCb = false; bool doCb = false;
bool doStun = false; bool doStun = false;
uint32_t stunFlags = 0; uint32_t stunFlags = 0;
time_t now = time(NULL); rstime_t now = time(NULL);
dhtPeerEntry ent; dhtPeerEntry ent;

View File

@ -80,10 +80,10 @@ class dhtPeerEntry
RsPeerId id; RsPeerId id;
uint32_t state; uint32_t state;
time_t lastTS; rstime_t lastTS;
uint32_t notifyPending; uint32_t notifyPending;
time_t notifyTS; rstime_t notifyTS;
struct sockaddr_in laddr, raddr; struct sockaddr_in laddr, raddr;
uint32_t type; /* ADDR_TYPE as defined above */ uint32_t type; /* ADDR_TYPE as defined above */
@ -231,17 +231,17 @@ std::string randomBootstrapId();
bool mDhtModifications; /* any user requests? */ bool mDhtModifications; /* any user requests? */
dhtPeerEntry ownEntry; dhtPeerEntry ownEntry;
time_t ownNotifyTS; rstime_t ownNotifyTS;
std::map<RsPeerId, dhtPeerEntry> peers; std::map<RsPeerId, dhtPeerEntry> peers;
std::list<std::string> stunIds; std::list<std::string> stunIds;
bool mStunRequired; bool mStunRequired;
uint32_t mDhtState; uint32_t mDhtState;
time_t mDhtActiveTS; rstime_t mDhtActiveTS;
bool mBootstrapAllowed; bool mBootstrapAllowed;
time_t mLastBootstrapListTS; rstime_t mLastBootstrapListTS;
}; };

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#include <time.h> #include "util/rstime.h"
#include "p3historymgr.h" #include "p3historymgr.h"
#include "rsitems/rshistoryitems.h" #include "rsitems/rshistoryitems.h"
@ -68,7 +68,7 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
{ {
uint32_t addMsgId = 0; uint32_t addMsgId = 0;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(mLastCleanTime + MSG_HISTORY_CLEANING_PERIOD < now) if(mLastCleanTime + MSG_HISTORY_CLEANING_PERIOD < now)
{ {
@ -170,7 +170,7 @@ void p3HistoryMgr::cleanOldMessages()
#ifdef HISTMGR_DEBUG #ifdef HISTMGR_DEBUG
std::cerr << "****** cleaning old messages." << std::endl; std::cerr << "****** cleaning old messages." << std::endl;
#endif #endif
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
bool changed = false ; bool changed = false ;
for(std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.begin(); mit != mMessages.end();) for(std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.begin(); mit != mMessages.end();)

View File

@ -88,7 +88,7 @@ private:
uint32_t mPrivateSaveCount; uint32_t mPrivateSaveCount;
uint32_t mMaxStorageDurationSeconds ; uint32_t mMaxStorageDurationSeconds ;
time_t mLastCleanTime ; rstime_t mLastCleanTime ;
std::list<RsItem*> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */ std::list<RsItem*> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */

View File

@ -327,9 +327,9 @@ void p3LinkMgrIMPL::statusTick()
//std::list<std::string> dummyToRemove; //std::list<std::string> dummyToRemove;
{ {
time_t now = time(NULL); rstime_t now = time(NULL);
time_t oldavail = now - MAX_AVAIL_PERIOD; rstime_t oldavail = now - MAX_AVAIL_PERIOD;
time_t retry = now - mRetryPeriod; rstime_t retry = now - mRetryPeriod;
RsStackMutex stack(mLinkMtx); /****** LOCK MUTEX ******/ RsStackMutex stack(mLinkMtx); /****** LOCK MUTEX ******/
std::map<RsPeerId, peerConnectState>::iterator it; std::map<RsPeerId, peerConnectState>::iterator it;
@ -1080,7 +1080,7 @@ void p3LinkMgrIMPL::peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
std::map<RsPeerId, peerConnectState>::iterator it; std::map<RsPeerId, peerConnectState>::iterator it;
bool isFriend = true; bool isFriend = true;
time_t now = time(NULL); rstime_t now = time(NULL);
peerAddrInfo details; peerAddrInfo details;
details.type = type; details.type = type;
@ -1658,7 +1658,7 @@ bool p3LinkMgrIMPL::retryConnectTCP(const RsPeerId &id)
#define MAX_TCP_ADDR_AGE (3600 * 24 * 14) // two weeks in seconds. #define MAX_TCP_ADDR_AGE (3600 * 24 * 14) // two weeks in seconds.
bool p3LinkMgrIMPL::locked_CheckPotentialAddr(const struct sockaddr_storage &addr, time_t age) bool p3LinkMgrIMPL::locked_CheckPotentialAddr(const struct sockaddr_storage &addr, rstime_t age)
{ {
#ifdef LINKMGR_DEBUG #ifdef LINKMGR_DEBUG
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr("; std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr(";
@ -1805,7 +1805,7 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses(peerConnectState
/* now try historical addresses */ /* now try historical addresses */
/* try local addresses first */ /* try local addresses first */
std::list<pqiIpAddress>::const_iterator ait; std::list<pqiIpAddress>::const_iterator ait;
time_t now = time(NULL); rstime_t now = time(NULL);
#ifdef LINKMGR_DEBUG #ifdef LINKMGR_DEBUG
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses()"; std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses()";
@ -2206,7 +2206,7 @@ void p3LinkMgrIMPL::printPeerLists(std::ostream &out)
return; return;
} }
bool p3LinkMgrIMPL::checkPotentialAddr(const sockaddr_storage &addr, time_t age) bool p3LinkMgrIMPL::checkPotentialAddr(const sockaddr_storage &addr, rstime_t age)
{ {
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/

View File

@ -24,7 +24,7 @@
#include "pqi/pqimonitor.h" #include "pqi/pqimonitor.h"
#include "pqi/pqiipset.h" #include "pqi/pqiipset.h"
#include "util/rstime.h"
#include "pqi/pqiassist.h" #include "pqi/pqiassist.h"
#include "pqi/p3cfgmgr.h" #include "pqi/p3cfgmgr.h"
@ -61,7 +61,7 @@ class peerAddrInfo
bool found; bool found;
uint32_t type; uint32_t type;
pqiIpAddrSet addrs; pqiIpAddrSet addrs;
time_t ts; rstime_t ts;
}; };
class peerConnectAddress class peerConnectAddress
@ -74,7 +74,7 @@ class peerConnectAddress
uint32_t period; /* UDP only */ uint32_t period; /* UDP only */
uint32_t type; uint32_t type;
uint32_t flags; /* CB FLAGS defined in pqimonitor.h */ uint32_t flags; /* CB FLAGS defined in pqimonitor.h */
time_t ts; rstime_t ts;
// Extra Parameters for Relay connections. // Extra Parameters for Relay connections.
struct sockaddr_storage proxyaddr; struct sockaddr_storage proxyaddr;
@ -99,8 +99,8 @@ class peerConnectState
uint32_t connecttype; // RS_NET_CONN_TCP_ALL / RS_NET_CONN_UDP_ALL uint32_t connecttype; // RS_NET_CONN_TCP_ALL / RS_NET_CONN_UDP_ALL
bool actAsServer; bool actAsServer;
time_t lastavailable; rstime_t lastavailable;
time_t lastattempt; rstime_t lastattempt;
std::string name; std::string name;
@ -122,7 +122,7 @@ class peerConnectState
/* information about denial */ /* information about denial */
bool wasDeniedConnection; bool wasDeniedConnection;
time_t deniedTS; rstime_t deniedTS;
bool deniedInConnAttempt; /* is below valid */ bool deniedInConnAttempt; /* is below valid */
peerConnectAddress deniedConnectionAttempt; peerConnectAddress deniedConnectionAttempt;
}; };
@ -182,7 +182,7 @@ virtual bool getLocalAddress(struct sockaddr_storage &addr) = 0;
virtual void getFriendList(std::list<RsPeerId> &ssl_peers) = 0; // ONLY used by p3peers.cc USE p3PeerMgr instead. virtual void getFriendList(std::list<RsPeerId> &ssl_peers) = 0; // ONLY used by p3peers.cc USE p3PeerMgr instead.
virtual bool getFriendNetStatus(const RsPeerId &id, peerConnectState &state) = 0; // ONLY used by p3peers.cc virtual bool getFriendNetStatus(const RsPeerId &id, peerConnectState &state) = 0; // ONLY used by p3peers.cc
virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, time_t age)=0; virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, rstime_t age)=0;
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/ /************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
virtual int addFriend(const RsPeerId &ssl_id, bool isVisible) = 0; virtual int addFriend(const RsPeerId &ssl_id, bool isVisible) = 0;
@ -269,7 +269,7 @@ int removeFriend(const RsPeerId &ssl_id);
void printPeerLists(std::ostream &out); void printPeerLists(std::ostream &out);
virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, time_t age); virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, rstime_t age);
protected: protected:
/* THESE CAN PROBABLY BE REMOVED */ /* THESE CAN PROBABLY BE REMOVED */
//bool shutdown(); /* blocking shutdown call */ //bool shutdown(); /* blocking shutdown call */
@ -302,7 +302,7 @@ void locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const uint32_t
bool locked_ConnectAttempt_Complete(peerConnectState *peer); bool locked_ConnectAttempt_Complete(peerConnectState *peer);
bool locked_CheckPotentialAddr(const struct sockaddr_storage &addr, time_t age); bool locked_CheckPotentialAddr(const struct sockaddr_storage &addr, rstime_t age);
bool addAddressIfUnique(std::list<peerConnectAddress> &addrList, peerConnectAddress &pca, bool pushFront); bool addAddressIfUnique(std::list<peerConnectAddress> &addrList, peerConnectAddress &pca, bool pushFront);

View File

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#include <time.h> #include "util/rstime.h"
#include <vector> #include <vector>
#include "pqi/p3netmgr.h" #include "pqi/p3netmgr.h"
@ -415,7 +415,7 @@ void p3NetMgrIMPL::netStartup()
void p3NetMgrIMPL::tick() void p3NetMgrIMPL::tick()
{ {
time_t now = time(NULL); rstime_t now = time(NULL);
bool doSlowTick = false; bool doSlowTick = false;
{ {
RsStackMutex stack(mNetMtx); /************** LOCK MUTEX ***************/ RsStackMutex stack(mNetMtx); /************** LOCK MUTEX ***************/
@ -474,7 +474,7 @@ void p3NetMgrIMPL::netTick()
checkNetAddress() ; checkNetAddress() ;
uint32_t netStatus = 0; uint32_t netStatus = 0;
time_t age = 0; rstime_t age = 0;
{ {
RsStackMutex stack(mNetMtx); /************** LOCK MUTEX ***************/ RsStackMutex stack(mNetMtx); /************** LOCK MUTEX ***************/
@ -605,7 +605,7 @@ void p3NetMgrIMPL::netUpnpCheck()
/* grab timestamp */ /* grab timestamp */
mNetMtx.lock(); /* LOCK MUTEX */ mNetMtx.lock(); /* LOCK MUTEX */
time_t delta = time(NULL) - mNetInitTS; rstime_t delta = time(NULL) - mNetInitTS;
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET) #if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netUpnpCheck() age: " << delta << std::endl; std::cerr << "p3NetMgrIMPL::netUpnpCheck() age: " << delta << std::endl;
@ -616,8 +616,8 @@ void p3NetMgrIMPL::netUpnpCheck()
struct sockaddr_storage extAddr; struct sockaddr_storage extAddr;
int upnpState = netAssistFirewallActive(); int upnpState = netAssistFirewallActive();
if (((upnpState == 0) && (delta > (time_t)MAX_UPNP_INIT)) || if (((upnpState == 0) && (delta > (rstime_t)MAX_UPNP_INIT)) ||
((upnpState > 0) && (delta > (time_t)MAX_UPNP_COMPLETE))) ((upnpState > 0) && (delta > (rstime_t)MAX_UPNP_COMPLETE)))
{ {
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET) #if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netUpnpCheck() "; std::cerr << "p3NetMgrIMPL::netUpnpCheck() ";

View File

@ -334,7 +334,7 @@ void netStatusReset_locked();
uint16_t mVsDisc; uint16_t mVsDisc;
uint16_t mVsDht; uint16_t mVsDht;
time_t mNetInitTS; rstime_t mNetInitTS;
uint32_t mNetStatus; uint32_t mNetStatus;
bool mStatusChanged; bool mStatusChanged;
@ -349,7 +349,7 @@ void netStatusReset_locked();
// Improved NetStatusBox, which uses the Stunners! // Improved NetStatusBox, which uses the Stunners!
pqiNetStateBox mNetStateBox; pqiNetStateBox mNetStateBox;
time_t mLastSlowTickTime; rstime_t mLastSlowTickTime;
uint32_t mOldNatType; uint32_t mOldNatType;
uint32_t mOldNatHole; uint32_t mOldNatHole;

View File

@ -289,11 +289,11 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht)
void p3PeerMgrIMPL::tick() void p3PeerMgrIMPL::tick()
{ {
static const time_t INTERVAL_BETWEEN_LOCATION_CLEANING = 300 ; // Remove unused locations and clean IPs every 10 minutes. static const rstime_t INTERVAL_BETWEEN_LOCATION_CLEANING = 300 ; // Remove unused locations and clean IPs every 10 minutes.
static time_t last_friends_check = time(NULL) ; // first cleaning after 1 hour. static rstime_t last_friends_check = time(NULL) ; // first cleaning after 1 hour.
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(now > INTERVAL_BETWEEN_LOCATION_CLEANING + last_friends_check ) if(now > INTERVAL_BETWEEN_LOCATION_CLEANING + last_friends_check )
{ {
@ -900,7 +900,7 @@ bool p3PeerMgrIMPL::haveOnceConnected()
/*******************************************************************/ /*******************************************************************/
/*******************************************************************/ /*******************************************************************/
bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, time_t lastContact,ServicePermissionFlags service_flags) bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, rstime_t lastContact,ServicePermissionFlags service_flags)
{ {
bool notifyLinkMgr = false; bool notifyLinkMgr = false;
RsPeerId id = input_id ; RsPeerId id = input_id ;
@ -1718,7 +1718,7 @@ bool p3PeerMgrIMPL::getExtAddressReportedByFriends(sockaddr_storage &addr, uint8
static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkMgr *link_mgr) static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkMgr *link_mgr)
{ {
bool changed = false ; bool changed = false ;
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
for(std::list<pqiIpAddress>::iterator it2(lst.begin());it2 != lst.end();) for(std::list<pqiIpAddress>::iterator it2(lst.begin());it2 != lst.end();)
{ {
@ -2963,9 +2963,9 @@ bool p3PeerMgrIMPL::removeBannedIps()
bool p3PeerMgrIMPL::removeUnusedLocations() bool p3PeerMgrIMPL::removeUnusedLocations()
{ {
std::list<RsPeerId> toRemove; std::list<RsPeerId> toRemove;
std::map<RsPgpId, time_t> mostRecentTime; std::map<RsPgpId, rstime_t> mostRecentTime;
const time_t now = time(NULL); const rstime_t now = time(NULL);
std::list<RsPgpId> pgpList ; std::list<RsPgpId> pgpList ;
@ -2978,7 +2978,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
// First put a sensible number in all PGP ids // First put a sensible number in all PGP ids
for(std::list<RsPgpId>::const_iterator it = pgpList.begin(); it != pgpList.end(); ++it) for(std::list<RsPgpId>::const_iterator it = pgpList.begin(); it != pgpList.end(); ++it)
mostRecentTime[*it] = (time_t)0; mostRecentTime[*it] = (rstime_t)0;
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl; std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl;
@ -2987,7 +2987,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
for( std::map<RsPeerId, peerState>::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it) for( std::map<RsPeerId, peerState>::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it)
{ {
time_t& bst(mostRecentTime[it->second.gpg_id]) ; rstime_t& bst(mostRecentTime[it->second.gpg_id]) ;
bst = std::max(bst,it->second.lastcontact) ; bst = std::max(bst,it->second.lastcontact) ;
} }

View File

@ -65,8 +65,8 @@ const uint32_t RS_NET_FLAGS_TRUSTS_ME = 0x0020;
* remove locations offline since 90 days * remove locations offline since 90 days
* stopt sending locations via discovery when offline for +30 days * stopt sending locations via discovery when offline for +30 days
*/ */
const time_t RS_PEER_OFFLINE_DELETE = (90 * 24 * 3600); const rstime_t RS_PEER_OFFLINE_DELETE = (90 * 24 * 3600);
const time_t RS_PEER_OFFLINE_NO_DISC = (30 * 24 * 3600); const rstime_t RS_PEER_OFFLINE_NO_DISC = (30 * 24 * 3600);
class peerState class peerState
{ {
@ -85,7 +85,7 @@ class peerState
struct sockaddr_storage serveraddr; struct sockaddr_storage serveraddr;
std::string dyndns; std::string dyndns;
time_t lastcontact; rstime_t lastcontact;
/* list of addresses from various sources */ /* list of addresses from various sources */
pqiIpAddrSet ipAddrs; pqiIpAddrSet ipAddrs;
@ -124,7 +124,7 @@ public:
uint32_t netMode = RS_NET_MODE_UDP, uint32_t netMode = RS_NET_MODE_UDP,
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDisc = RS_VS_DISC_FULL,
uint16_t vsDht = RS_VS_DHT_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
time_t lastContact = 0, rstime_t lastContact = 0,
ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT) ) = 0; ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT) ) = 0;
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0; virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
@ -241,7 +241,7 @@ public:
virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP, virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL, uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)); rstime_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT));
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId); virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
virtual bool removeFriend(const RsPgpId &pgp_id); virtual bool removeFriend(const RsPgpId &pgp_id);

View File

@ -25,6 +25,7 @@
#include "pqi/pqi_base.h" #include "pqi/pqi_base.h"
#include "pqi/pqihash.h" #include "pqi/pqihash.h"
#include "util/rstime.h"
#include <stdio.h> #include <stdio.h>
@ -228,7 +229,7 @@ virtual RsFileHash gethash();
bool dummyConnected; bool dummyConnected;
bool toConnect; bool toConnect;
uint32_t connectDelta; uint32_t connectDelta;
time_t connectTS; rstime_t connectTS;
}; };

View File

@ -22,7 +22,7 @@
#include "pqi/pqihandler.h" #include "pqi/pqihandler.h"
#include <stdlib.h> // for NULL #include <stdlib.h> // for NULL
#include <time.h> // for time, time_t #include "util/rstime.h" // for time, rstime_t
#include <algorithm> // for sort #include <algorithm> // for sort
#include <iostream> // for dec #include <iostream> // for dec
#include <string> // for string, char_traits, operator+, bas... #include <string> // for string, char_traits, operator+, bas...
@ -121,7 +121,7 @@ int pqihandler::tick()
#endif #endif
} }
time_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(now > mLastRateCapUpdate + 5) if(now > mLastRateCapUpdate + 5)
{ {

View File

@ -23,7 +23,7 @@
#define MRK_PQI_HANDLER_HEADER #define MRK_PQI_HANDLER_HEADER
#include <stdint.h> // for uint32_t #include <stdint.h> // for uint32_t
#include <time.h> // for time_t, NULL #include "util/rstime.h" // for rstime_t, NULL
#include <list> // for list #include <list> // for list
#include <map> // for map #include <map> // for map
@ -121,8 +121,8 @@ protected:
float rateTotal_out; float rateTotal_out;
uint32_t nb_ticks ; uint32_t nb_ticks ;
time_t last_m ; rstime_t last_m ;
time_t mLastRateCapUpdate ; rstime_t mLastRateCapUpdate ;
float ticks_per_sec ; float ticks_per_sec ;
}; };

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#include <time.h> #include "util/rstime.h"
#include "pqi/pqiipset.h" #include "pqi/pqiipset.h"
#include "util/rsstring.h" #include "util/rsstring.h"
@ -193,7 +193,7 @@ void pqiIpAddrList::loadTlv(RsTlvIpAddrSet &tlvAddrs) const
void pqiIpAddrList::printIpAddressList(std::string &out) const void pqiIpAddrList::printIpAddressList(std::string &out) const
{ {
std::list<pqiIpAddress>::const_iterator it; std::list<pqiIpAddress>::const_iterator it;
time_t now = time(NULL); rstime_t now = time(NULL);
for(it = mAddrs.begin(); it != mAddrs.end(); ++it) for(it = mAddrs.begin(); it != mAddrs.end(); ++it)
{ {
out += sockaddr_storage_tostring(it->mAddr); out += sockaddr_storage_tostring(it->mAddr);

View File

@ -24,6 +24,7 @@
#include "util/rsnet.h" #include "util/rsnet.h"
#include "serialiser/rstlvaddrs.h" #include "serialiser/rstlvaddrs.h"
#include "util/rstime.h"
#define MAX_ADDRESS_LIST_SIZE 10 #define MAX_ADDRESS_LIST_SIZE 10
@ -34,7 +35,7 @@ class pqiIpAddress
bool validAddress() const; bool validAddress() const;
struct sockaddr_storage mAddr; struct sockaddr_storage mAddr;
time_t mSeenTime; rstime_t mSeenTime;
uint32_t mSrc; uint32_t mSrc;
}; };

View File

@ -23,7 +23,7 @@
#include "retroshare/rsconfig.h" #include "retroshare/rsconfig.h"
#include "util/rsnet.h" #include "util/rsnet.h"
#include "pqi/pqinetstatebox.h" #include "pqi/pqinetstatebox.h"
#include "time.h" #include "util/rstime.h"
#ifdef RS_USE_BITDHT #ifdef RS_USE_BITDHT
#include "bitdht/bdiface.h" #include "bitdht/bdiface.h"
@ -191,7 +191,7 @@ void pqiNetStateBox::reset()
{ {
mStatusOkay = false; mStatusOkay = false;
//time_t mStatusTS; //rstime_t mStatusTS;
mNetworkMode = RSNET_NETWORK_UNKNOWN; mNetworkMode = RSNET_NETWORK_UNKNOWN;
mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatTypeMode = RSNET_NATTYPE_UNKNOWN;
@ -244,7 +244,7 @@ int pqiNetStateBox::statusOkay()
{ {
return 0; return 0;
} }
time_t now = time(NULL); rstime_t now = time(NULL);
if (now - mStatusTS > NETSTATE_TIMEOUT) if (now - mStatusTS > NETSTATE_TIMEOUT)
{ {
return 0; return 0;
@ -268,7 +268,7 @@ void pqiNetStateBox::clearOldNetworkData()
{ {
#ifdef RS_USE_DHT_STUNNER #ifdef RS_USE_DHT_STUNNER
/* check if any measurements are too old to consider */ /* check if any measurements are too old to consider */
time_t now = time(NULL); rstime_t now = time(NULL);
if (now - mStunProxyTS > NETSTATE_PARAM_TIMEOUT) if (now - mStunProxyTS > NETSTATE_PARAM_TIMEOUT)
{ {
mStunProxySet = false; mStunProxySet = false;
@ -292,7 +292,7 @@ void pqiNetStateBox::clearOldNetworkData()
void pqiNetStateBox::determineNetworkState() void pqiNetStateBox::determineNetworkState()
{ {
clearOldNetworkData(); clearOldNetworkData();
time_t now = time(NULL); rstime_t now = time(NULL);
/* now we use the remaining valid input to determine network state */ /* now we use the remaining valid input to determine network state */

View File

@ -69,7 +69,7 @@ class pqiNetStateBox
void workoutNetworkMode(); void workoutNetworkMode();
bool mStatusOkay; bool mStatusOkay;
time_t mStatusTS; rstime_t mStatusTS;
uint32_t mNetworkMode; uint32_t mNetworkMode;
uint32_t mNatTypeMode; uint32_t mNatTypeMode;
@ -80,35 +80,35 @@ class pqiNetStateBox
/* Parameters set externally */ /* Parameters set externally */
bool mStunDhtSet; bool mStunDhtSet;
time_t mStunDhtTS; rstime_t mStunDhtTS;
bool mStunDhtStable; bool mStunDhtStable;
struct sockaddr_storage mStunDhtAddr; struct sockaddr_storage mStunDhtAddr;
bool mStunProxySet; bool mStunProxySet;
time_t mStunProxyTS; rstime_t mStunProxyTS;
bool mStunProxyStable; bool mStunProxyStable;
bool mStunProxySemiStable; bool mStunProxySemiStable;
struct sockaddr_storage mStunProxyAddr; struct sockaddr_storage mStunProxyAddr;
bool mDhtSet; bool mDhtSet;
time_t mDhtTS; rstime_t mDhtTS;
bool mDhtOn; bool mDhtOn;
bool mDhtActive; bool mDhtActive;
bool mUPnPSet; bool mUPnPSet;
struct sockaddr_storage mUPnPAddr; struct sockaddr_storage mUPnPAddr;
bool mUPnPActive; bool mUPnPActive;
time_t mUPnPTS; rstime_t mUPnPTS;
bool mNatPMPSet; bool mNatPMPSet;
struct sockaddr_storage mNatPMPAddr; struct sockaddr_storage mNatPMPAddr;
bool mNatPMPActive; bool mNatPMPActive;
time_t mNatPMPTS; rstime_t mNatPMPTS;
bool mWebIPSet; bool mWebIPSet;
struct sockaddr_storage mWebIPAddr; struct sockaddr_storage mWebIPAddr;
bool mWebIPActive; bool mWebIPActive;
time_t mWebIPTS; rstime_t mWebIPTS;
bool mPortForwardSet; bool mPortForwardSet;
uint16_t mPortForwarded; uint16_t mPortForwarded;

View File

@ -38,7 +38,7 @@ static const int CONNECT_UNREACHABLE = 3;
static const int CONNECT_FIREWALLED = 4; static const int CONNECT_FIREWALLED = 4;
static const int CONNECT_FAILED = 5; static const int CONNECT_FAILED = 5;
static const time_t HEARTBEAT_REPEAT_TIME = 5; static const rstime_t HEARTBEAT_REPEAT_TIME = 5;
#include "pqi/pqiqosstreamer.h" #include "pqi/pqiqosstreamer.h"
#include "pqi/pqithreadstreamer.h" #include "pqi/pqithreadstreamer.h"
@ -167,7 +167,7 @@ private:
pqiconnect *activepqi; pqiconnect *activepqi;
bool inConnectAttempt; bool inConnectAttempt;
//int waittimes; //int waittimes;
time_t lastHeartbeatReceived; // use to track connection failure rstime_t lastHeartbeatReceived; // use to track connection failure
pqipersongrp *pqipg; /* parent for callback */ pqipersongrp *pqipg; /* parent for callback */
}; };

View File

@ -66,7 +66,7 @@ const int PQISSL_UDP_FLAG = 0x02;
//#define PQISSL_LOG_DEBUG2 1 //#define PQISSL_LOG_DEBUG2 1
static const int PQISSL_MAX_READ_ZERO_COUNT = 20; static const int PQISSL_MAX_READ_ZERO_COUNT = 20;
static const time_t PQISSL_MAX_READ_ZERO_TIME = 15; // 15 seconds of no data => reset. (atm HeartBeat pkt sent 5 secs) static const rstime_t PQISSL_MAX_READ_ZERO_TIME = 15; // 15 seconds of no data => reset. (atm HeartBeat pkt sent 5 secs)
static const int PQISSL_SSL_CONNECT_TIMEOUT = 30; static const int PQISSL_SSL_CONNECT_TIMEOUT = 30;

View File

@ -195,14 +195,14 @@ bool CheckConnectionTimeout();
int attempt_ts; int attempt_ts;
int n_read_zero; /* a counter to determine if the connection is really dead */ int n_read_zero; /* a counter to determine if the connection is really dead */
time_t mReadZeroTS; /* timestamp of first READ_ZERO occurance */ rstime_t mReadZeroTS; /* timestamp of first READ_ZERO occurance */
int ssl_connect_timeout; /* timeout to ensure that we don't get stuck (can happen on udp!) */ int ssl_connect_timeout; /* timeout to ensure that we don't get stuck (can happen on udp!) */
uint32_t mConnectDelay; uint32_t mConnectDelay;
time_t mConnectTS; rstime_t mConnectTS;
uint32_t mConnectTimeout; uint32_t mConnectTimeout;
time_t mTimeoutTS; rstime_t mTimeoutTS;
private: private:
// ssl only fns. // ssl only fns.

View File

@ -658,7 +658,7 @@ int pqissllistenbase::finaliseAccepts()
// for each of the incoming sockets.... call continue. // for each of the incoming sockets.... call continue.
std::list<AcceptedSSL>::iterator it; std::list<AcceptedSSL>::iterator it;
time_t now = time(NULL); rstime_t now = time(NULL);
for(it = accepted_ssl.begin(); it != accepted_ssl.end();) for(it = accepted_ssl.begin(); it != accepted_ssl.end();)
{ {
pqioutput(PQL_DEBUG_BASIC, pqissllistenzone, pqioutput(PQL_DEBUG_BASIC, pqissllistenzone,

View File

@ -49,7 +49,7 @@ public:
RsPeerId mPeerId; RsPeerId mPeerId;
sockaddr_storage mAddr; sockaddr_storage mAddr;
time_t mAcceptTS; rstime_t mAcceptTS;
}; };

Some files were not shown because too many files have changed in this diff Show More