mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-05 13:19:32 -04:00
Use safer rstime_t instead of time_t
Avoid problems to serialization on different platforms, without breaking nested STL containers serialization. The conversion have been made with sed, and checked with grep, plus kdiff3 visual ispection, plus rutime tests, so it should be fine.
This commit is contained in:
parent
41aa675a9b
commit
329050a9c2
223 changed files with 930 additions and 911 deletions
|
@ -36,10 +36,10 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
const time_t MAX_TIME_BEFORE_RETRY = 300 ; /* seconds before retrying an ip address */
|
||||
const time_t MAX_KEEP_DNS_ENTRY = 3600 ; /* seconds during which a DNS entry is considered valid */
|
||||
const rstime_t MAX_TIME_BEFORE_RETRY = 300 ; /* seconds before retrying an ip address */
|
||||
const rstime_t MAX_KEEP_DNS_ENTRY = 3600 ; /* seconds during which a DNS entry is considered valid */
|
||||
|
||||
static const std::string ADDR_AGENT = "Mozilla/5.0";
|
||||
|
||||
|
@ -51,7 +51,7 @@ void *solveDNSEntries(void *p)
|
|||
while(more_to_go)
|
||||
{
|
||||
// get an address request
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
more_to_go = false ;
|
||||
|
||||
std::string next_call = "" ;
|
||||
|
@ -152,7 +152,7 @@ bool DNSResolver::getIPAddressFromString(const std::string& server_name,struct s
|
|||
RsStackMutex mut(_rdnsMtx) ;
|
||||
|
||||
std::map<std::string, AddrInfo>::iterator it(_addr_map->find(server_name)) ;
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
AddrInfo *addr_info ;
|
||||
|
||||
if(it != _addr_map->end())
|
||||
|
|
|
@ -50,7 +50,7 @@ class DNSResolver
|
|||
struct AddrInfo
|
||||
{
|
||||
uint32_t state ; // state: Looked-up, not found, have
|
||||
time_t last_lookup_time ; // last lookup time
|
||||
rstime_t last_lookup_time ; // last lookup time
|
||||
struct sockaddr_storage addr ;
|
||||
};
|
||||
friend void *solveDNSEntries(void *p) ;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
const uint32_t MAX_IP_STORE = 300; /* seconds ip address timeout */
|
||||
|
||||
|
@ -253,7 +253,7 @@ bool ExtAddrFinder::hasValidIP(struct sockaddr_storage &addr)
|
|||
addr = mAddr;
|
||||
}
|
||||
}
|
||||
time_t delta;
|
||||
rstime_t delta;
|
||||
{
|
||||
RsStackMutex mut(mAddrMtx) ;
|
||||
//timeout the current ip
|
||||
|
|
|
@ -45,7 +45,7 @@ class ExtAddrFinder
|
|||
friend void* doExtAddrSearch(void *p) ;
|
||||
|
||||
RsMutex mAddrMtx ;
|
||||
time_t mFoundTS;
|
||||
rstime_t mFoundTS;
|
||||
struct sockaddr_storage mAddr;
|
||||
bool mFound ;
|
||||
bool mSearching ;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
#include "util/rswin.h"
|
||||
|
@ -227,12 +227,12 @@ bool FolderIterator::readdir()
|
|||
#endif
|
||||
}
|
||||
|
||||
time_t FolderIterator::dir_modtime() const { return mFolderModTime ; }
|
||||
rstime_t FolderIterator::dir_modtime() const { return mFolderModTime ; }
|
||||
|
||||
const std::string& FolderIterator::file_fullpath() { return mFullPath ; }
|
||||
const std::string& FolderIterator::file_name() { return mFileName ; }
|
||||
uint64_t FolderIterator::file_size() { return mFileSize ; }
|
||||
time_t FolderIterator::file_modtime() { return mFileModTime ; }
|
||||
rstime_t FolderIterator::file_modtime() { return mFileModTime ; }
|
||||
uint8_t FolderIterator::file_type() { return mType ; }
|
||||
|
||||
bool FolderIterator::closedir()
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include "util/rstime.h"
|
||||
|
||||
namespace librs { namespace util {
|
||||
|
||||
|
@ -52,7 +53,7 @@ public:
|
|||
};
|
||||
|
||||
// info about current parent directory
|
||||
time_t dir_modtime() const ;
|
||||
rstime_t dir_modtime() const ;
|
||||
|
||||
// info about directory content
|
||||
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
const std::string& file_fullpath() ;
|
||||
uint64_t file_size() ;
|
||||
uint8_t file_type() ;
|
||||
time_t file_modtime() ;
|
||||
rstime_t file_modtime() ;
|
||||
|
||||
private:
|
||||
bool is_open;
|
||||
|
@ -82,8 +83,8 @@ private:
|
|||
#endif
|
||||
bool updateFileInfo(bool &should_skip) ;
|
||||
|
||||
time_t mFileModTime ;
|
||||
time_t mFolderModTime ;
|
||||
rstime_t mFileModTime ;
|
||||
rstime_t mFolderModTime ;
|
||||
uint64_t mFileSize ;
|
||||
uint8_t mType ;
|
||||
std::string mFileName ;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <memory.h>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "retrodb.h"
|
||||
|
@ -147,7 +147,7 @@ bool RetroDb::execSQL(const std::string &query){
|
|||
|
||||
|
||||
uint32_t delta = 3;
|
||||
time_t stamp = time(NULL), now = 0;
|
||||
rstime_t stamp = time(NULL), now = 0;
|
||||
bool timeOut = false, ok = false;
|
||||
|
||||
while(!timeOut){
|
||||
|
@ -348,7 +348,7 @@ bool RetroDb::execSQL_bind(const std::string &query, std::list<RetroBind*> ¶
|
|||
}
|
||||
|
||||
uint32_t delta = 3;
|
||||
time_t stamp = time(NULL), now = 0;
|
||||
rstime_t stamp = time(NULL), now = 0;
|
||||
bool timeOut = false, ok = false;
|
||||
|
||||
while(!timeOut){
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
const int RS_DEBUG_STDERR = 1; /* stuff goes to stderr */
|
||||
const int RS_DEBUG_LOGFILE = 2; /* stuff goes to logfile */
|
||||
|
@ -147,8 +147,8 @@ void rslog(const RsLog::logLvl lvl, RsLog::logInfo *info, const std::string &msg
|
|||
return;
|
||||
|
||||
{
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
time_t t = time(NULL);
|
||||
RS_STACK_MUTEX(logMtx);
|
||||
rstime_t t = time(NULL);
|
||||
|
||||
if (debugMode == RS_DEBUG_LOGCRASH)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*******************************************************************************/
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
|
@ -49,7 +49,7 @@
|
|||
* #define DEBUG_RSDISCSPACE
|
||||
*/
|
||||
|
||||
time_t RsDiscSpace::_last_check[RS_DIRECTORY_COUNT] = { 0,0,0,0 } ;
|
||||
rstime_t RsDiscSpace::_last_check[RS_DIRECTORY_COUNT] = { 0,0,0,0 } ;
|
||||
uint32_t RsDiscSpace::_size_limit_mb = 100 ;
|
||||
uint32_t RsDiscSpace::_current_size[RS_DIRECTORY_COUNT] = { 10000,10000,10000,10000 } ;
|
||||
bool RsDiscSpace::_last_res[RS_DIRECTORY_COUNT] = { true,true,true,true };
|
||||
|
@ -142,7 +142,7 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
|
|||
if( (_partials_path == "" && loc == RS_PARTIALS_DIRECTORY) || (_download_path == "" && loc == RS_DOWNLOAD_DIRECTORY))
|
||||
throw std::runtime_error("Download path and partial path not properly set in RsDiscSpace. Please call RsDiscSpace::setPartialsPath() and RsDiscSpace::setDownloadPath()") ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
|
||||
if(_last_check[loc]+DELAY_BETWEEN_CHECKS < now)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ class RsDiscSpace
|
|||
|
||||
static RsMutex _mtx ;
|
||||
|
||||
static time_t _last_check[RS_DIRECTORY_COUNT] ;
|
||||
static rstime_t _last_check[RS_DIRECTORY_COUNT] ;
|
||||
static uint32_t _size_limit_mb ;
|
||||
static uint32_t _current_size[RS_DIRECTORY_COUNT] ;
|
||||
static bool _last_res[RS_DIRECTORY_COUNT] ;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define RS_UTIL_MEM_CACHE
|
||||
|
||||
#include <map>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include <iostream>
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
uint32_t size() const { return mDataMap.size() ; }
|
||||
private:
|
||||
|
||||
bool update_lrumap(const Key &key, time_t old_ts, time_t new_ts);
|
||||
bool update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts);
|
||||
bool discard_LRU(int count_to_clear);
|
||||
|
||||
// internal class.
|
||||
|
@ -81,16 +81,16 @@ private:
|
|||
{
|
||||
public:
|
||||
cache_data() { return; }
|
||||
cache_data(Key in_key, Value in_data, time_t in_ts)
|
||||
cache_data(Key in_key, Value in_data, rstime_t in_ts)
|
||||
:key(in_key), data(in_data), ts(in_ts) { return; }
|
||||
Key key;
|
||||
Value data;
|
||||
time_t ts;
|
||||
rstime_t ts;
|
||||
};
|
||||
|
||||
|
||||
std::map<Key, cache_data > mDataMap;
|
||||
std::multimap<time_t, Key> mLruMap;
|
||||
std::multimap<rstime_t, Key> mLruMap;
|
||||
uint32_t mDataCount;
|
||||
uint32_t mMaxSize;
|
||||
std::string mName;
|
||||
|
@ -170,8 +170,8 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::fetch(const Key &k
|
|||
data = it->second.data;
|
||||
|
||||
/* update ts on data */
|
||||
time_t old_ts = it->second.ts;
|
||||
time_t new_ts = time(NULL);
|
||||
rstime_t old_ts = it->second.ts;
|
||||
rstime_t new_ts = time(NULL);
|
||||
it->second.ts = new_ts;
|
||||
|
||||
update_lrumap(key, old_ts, new_ts);
|
||||
|
@ -209,8 +209,8 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::erase(const Key &k
|
|||
|
||||
|
||||
/* get timestamps */
|
||||
time_t old_ts = it->second.ts;
|
||||
time_t new_ts = 0;
|
||||
rstime_t old_ts = it->second.ts;
|
||||
rstime_t new_ts = 0;
|
||||
|
||||
// remove from lru.
|
||||
mDataMap.erase(it);
|
||||
|
@ -241,7 +241,7 @@ template<class Key, class Value> Value &RsMemCache<Key, Value>::ref(const Key &k
|
|||
#endif // DEBUG_RSMEMCACHE
|
||||
|
||||
// insert operation.
|
||||
time_t new_ts = 0;
|
||||
rstime_t new_ts = 0;
|
||||
Value data;
|
||||
mDataMap[key] = cache_data(key, data, new_ts);
|
||||
mDataCount++;
|
||||
|
@ -259,8 +259,8 @@ template<class Key, class Value> Value &RsMemCache<Key, Value>::ref(const Key &k
|
|||
#endif // DEBUG_RSMEMCACHE
|
||||
|
||||
/* update ts on data */
|
||||
time_t old_ts = it->second.ts;
|
||||
time_t new_ts = time(NULL);
|
||||
rstime_t old_ts = it->second.ts;
|
||||
rstime_t new_ts = time(NULL);
|
||||
it->second.ts = new_ts;
|
||||
|
||||
update_lrumap(key, old_ts, new_ts);
|
||||
|
@ -279,8 +279,8 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::store(const Key &k
|
|||
#endif // DEBUG_RSMEMCACHE
|
||||
|
||||
/* update lrumap entry */
|
||||
time_t old_ts = 0;
|
||||
time_t new_ts = time(NULL);
|
||||
rstime_t old_ts = 0;
|
||||
rstime_t new_ts = time(NULL);
|
||||
|
||||
// For consistency
|
||||
typename std::map<Key, cache_data>::const_iterator it;
|
||||
|
@ -309,7 +309,7 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::store(const Key &k
|
|||
}
|
||||
|
||||
|
||||
template<class Key, class Value> bool RsMemCache<Key, Value>::update_lrumap(const Key &key, time_t old_ts, time_t new_ts)
|
||||
template<class Key, class Value> bool RsMemCache<Key, Value>::update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts)
|
||||
{
|
||||
if (old_ts == 0)
|
||||
{
|
||||
|
@ -324,9 +324,9 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::update_lrumap(cons
|
|||
}
|
||||
|
||||
/* find old entry */
|
||||
typename std::multimap<time_t, Key>::iterator mit;
|
||||
typename std::multimap<time_t, Key>::iterator sit = mLruMap.lower_bound(old_ts);
|
||||
typename std::multimap<time_t, Key>::iterator eit = mLruMap.upper_bound(old_ts);
|
||||
typename std::multimap<rstime_t, Key>::iterator mit;
|
||||
typename std::multimap<rstime_t, Key>::iterator sit = mLruMap.lower_bound(old_ts);
|
||||
typename std::multimap<rstime_t, Key>::iterator eit = mLruMap.upper_bound(old_ts);
|
||||
|
||||
for(mit = sit; mit != eit; ++mit)
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::discard_LRU(int co
|
|||
{
|
||||
while(count_to_clear > 0)
|
||||
{
|
||||
typename std::multimap<time_t, Key>::iterator mit = mLruMap.begin();
|
||||
typename std::multimap<rstime_t, Key>::iterator mit = mLruMap.begin();
|
||||
if (mit != mLruMap.end())
|
||||
{
|
||||
Key key = mit->second;
|
||||
|
@ -451,8 +451,8 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::discard_LRU(int co
|
|||
// These aren't templated functions.
|
||||
template<class Key, class Value> void RsMemCache<Key, Value>::printStats(std::ostream &out)
|
||||
{
|
||||
typename std::multimap<time_t, Key>::iterator mit = mLruMap.begin();
|
||||
time_t age = 0;
|
||||
typename std::multimap<rstime_t, Key>::iterator mit = mLruMap.begin();
|
||||
rstime_t age = 0;
|
||||
if (mit != mLruMap.end())
|
||||
{
|
||||
age = time(NULL) - mit->first;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <sys/time.h>
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ RsMutex RSRandom::rndMtx("RSRandom") ;
|
|||
// have anyway)
|
||||
//
|
||||
#ifdef WINDOWS_SYS
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#ifdef WIN_PTHREADS_H
|
||||
static bool auto_seed = RSRandom::seed( (time(NULL) + ((uint32_t) pthread_self())*0x1293fe)^0x18e34a12 ) ;
|
||||
#else
|
||||
|
|
|
@ -91,7 +91,7 @@ bool RsRecogn::loadSigningKeys(std::map<RsGxsId, RsGxsRecognSignerItem *> &signM
|
|||
}
|
||||
|
||||
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
for(int i = 0; i < NUM_RECOGN_SIGN_KEYS; i++)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <unistd.h> // for usleep()
|
||||
#include <errno.h> // for errno
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
#include "util/rstime.h"
|
||||
|
||||
|
@ -265,7 +265,7 @@ void RsQueueThread::data_tick()
|
|||
{
|
||||
doneWork = true;
|
||||
}
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
if (doneWork)
|
||||
{
|
||||
mLastWork = now;
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <util/rsmemory.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
/* RsIface Thread Wrappers */
|
||||
|
||||
|
@ -309,7 +311,7 @@ private:
|
|||
uint32_t mMinSleep; /* ms */
|
||||
uint32_t mMaxSleep; /* ms */
|
||||
uint32_t mLastSleep; /* ms */
|
||||
time_t mLastWork; /* secs */
|
||||
rstime_t mLastWork; /* secs */
|
||||
float mRelaxFactor;
|
||||
};
|
||||
|
||||
|
|
|
@ -33,14 +33,14 @@ void RsTickEvent::tick_events()
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
{
|
||||
RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
if (!mEvents.empty())
|
||||
{
|
||||
std::multimap<time_t, uint32_t>::iterator it;
|
||||
std::multimap<rstime_t, uint32_t>::iterator it;
|
||||
|
||||
for(it = mEvents.begin(); it != mEvents.end(); ++it)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ void RsTickEvent::tick_events()
|
|||
RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/
|
||||
while((!mEvents.empty()) && (mEvents.begin()->first <= now))
|
||||
{
|
||||
std::multimap<time_t, EventData>::iterator it = mEvents.begin();
|
||||
std::multimap<rstime_t, EventData>::iterator it = mEvents.begin();
|
||||
uint32_t event_type = it->second.mEventType;
|
||||
toProcess.push_back(it->second);
|
||||
mEvents.erase(it);
|
||||
|
@ -103,7 +103,7 @@ void RsTickEvent::schedule_now(uint32_t event_type, const std::string &elabel)
|
|||
RsTickEvent::schedule_in(event_type, 0, elabel);
|
||||
}
|
||||
|
||||
void RsTickEvent::schedule_event(uint32_t event_type, time_t when, const std::string &elabel)
|
||||
void RsTickEvent::schedule_event(uint32_t event_type, rstime_t when, const std::string &elabel)
|
||||
{
|
||||
RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/
|
||||
mEvents.insert(std::make_pair(when, EventData(event_type, elabel)));
|
||||
|
@ -125,7 +125,7 @@ void RsTickEvent::schedule_in(uint32_t event_type, uint32_t in_secs, const std::
|
|||
std::cerr << std::endl;
|
||||
#endif // DEBUG_EVENTS
|
||||
|
||||
time_t event_time = time(NULL) + in_secs;
|
||||
rstime_t event_time = time(NULL) + in_secs;
|
||||
RsTickEvent::schedule_event(event_type, event_time, elabel);
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ int32_t RsTickEvent::event_count(uint32_t event_type)
|
|||
bool RsTickEvent::prev_event_ago(uint32_t event_type, int32_t &age)
|
||||
{
|
||||
RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/
|
||||
std::map<uint32_t, time_t>::iterator it;
|
||||
std::map<uint32_t, rstime_t>::iterator it;
|
||||
|
||||
it = mPreviousEvent.find(event_type);
|
||||
if (it == mPreviousEvent.end())
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <map>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
|
@ -43,7 +43,7 @@ void tick_events();
|
|||
void schedule_now(uint32_t event_type);
|
||||
void schedule_now(uint32_t event_type, const std::string &elabel);
|
||||
|
||||
void schedule_event(uint32_t event_type, time_t when, const std::string &elabel);
|
||||
void schedule_event(uint32_t event_type, rstime_t when, const std::string &elabel);
|
||||
|
||||
void schedule_in(uint32_t event_type, uint32_t in_secs);
|
||||
void schedule_in(uint32_t event_type, uint32_t in_secs, const std::string &elabel);
|
||||
|
@ -74,8 +74,8 @@ void note_event_locked(uint32_t event_type);
|
|||
|
||||
RsMutex mEventMtx;
|
||||
std::map<uint32_t, int32_t> mEventCount;
|
||||
std::map<uint32_t, time_t> mPreviousEvent;
|
||||
std::multimap<time_t, EventData> mEvents;
|
||||
std::map<uint32_t, rstime_t> mPreviousEvent;
|
||||
std::multimap<rstime_t, EventData> mEvents;
|
||||
};
|
||||
|
||||
#endif // RS_UTIL_TICK_EVENT
|
||||
|
|
|
@ -19,8 +19,25 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#include <string>
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <ctime> // Added for comfort of users of this util header
|
||||
|
||||
/**
|
||||
* Safer alternative to time_t.
|
||||
* As time_t have not same lenght accross platforms, even though representation
|
||||
* is not guaranted to be the same but we found it being number of seconds since
|
||||
* the epoch for time points in all platforms we could test, or plain seconds
|
||||
* for intervals.
|
||||
* Still in some platforms it's 32bit long and in other 64bit long.
|
||||
* To avoid uncompatibility due to different serialzation format use this
|
||||
* reasonably safe alternative instead.
|
||||
*/
|
||||
typedef int64_t rstime_t;
|
||||
|
||||
// Do we really need this? Our names have rs prefix to avoid pollution already!
|
||||
namespace rstime {
|
||||
|
||||
/*!
|
||||
|
|
|
@ -287,8 +287,8 @@ void *SmallObject::operator new(size_t size)
|
|||
bool print=false ;
|
||||
{
|
||||
RsStackMutex m(_mtx) ;
|
||||
static time_t last_time = 0 ;
|
||||
time_t now = time(NULL) ;
|
||||
static rstime_t last_time = 0 ;
|
||||
rstime_t now = time(NULL) ;
|
||||
if(now > last_time + 20)
|
||||
{
|
||||
last_time = now ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue