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

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

View file

@ -21,7 +21,7 @@
******************************************************************************/
#include <sstream>
#include <algorithm>
#include <time.h>
#include "util/rstime.h"
#include "util/rsdir.h"
#include "util/rsprint.h"
#include "retroshare/rsexpr.h"
@ -356,7 +356,7 @@ bool InternalFileHierarchyStorage::updateHash(const DirectoryStorage::EntryIndex
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))
{
@ -427,7 +427,7 @@ DirectoryStorage::EntryIndex InternalFileHierarchyStorage::allocateNewIndex()
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))
{
@ -599,7 +599,7 @@ void InternalFileHierarchyStorage::getStatistics(SharedDirStats& stats) const
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))
{
@ -614,7 +614,7 @@ bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& ind
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))
{
@ -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.
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])) ;
time_t largest_modf_time = d.dir_modtime ;
rstime_t largest_modf_time = d.dir_modtime ;
unfinished_files_present = false ;
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 uint64_t file_size() const { return mFe.file_size ; }
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 uint32_t file_popularity() const { NOT_IMPLEMENTED() ; return 0; }

View file

@ -47,8 +47,8 @@ public:
{
public:
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,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) : file_name(name),file_size(size),file_modtime(modtime) {}
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 ~FileEntry() {}
@ -56,7 +56,7 @@ public:
// local stuff
std::string file_name ;
uint64_t file_size ;
time_t file_modtime;
rstime_t file_modtime;
RsFileHash file_hash ;
};
@ -76,9 +76,9 @@ public:
std::vector<DirectoryStorage::EntryIndex> subdirs ;
std::vector<DirectoryStorage::EntryIndex> subfiles ;
time_t dir_modtime;
time_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_modtime;
rstime_t dir_most_recent_time;// recursive most recent modification time, including files and subdirs in the entire hierarchy below.
rstime_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info.
};
// class stuff
@ -95,18 +95,18 @@ public:
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 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 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 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, 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.
bool getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) const;
bool setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) ;
bool getTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* ) const;
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.
// 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

View file

@ -20,7 +20,7 @@
* *
******************************************************************************/
#include <set>
#include <time.h>
#include "util/rstime.h"
#include "serialiser/rstlvbinary.h"
#include "retroshare/rspeers.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(); }
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(); }
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(); }
@ -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::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::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::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,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,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::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::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::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,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,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)
{
@ -281,7 +281,7 @@ bool DirectoryStorage::getIndexFromDirHash(const RsFileHash& hash,EntryIndex& in
void DirectoryStorage::checkSave()
{
time_t now = time(NULL);
rstime_t now = time(NULL);
if(mChanged && mLastSavedTime + MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE < now)
{
@ -489,7 +489,7 @@ void LocalDirectoryStorage::updateTimeStamps()
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 ;
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE

View file

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

View file

@ -64,7 +64,7 @@ void LocalDirectoryUpdater::setEnabled(bool b)
void LocalDirectoryUpdater::data_tick()
{
time_t now = time(NULL) ;
rstime_t now = time(NULL) ;
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.
time_t dir_local_mod_time ;
rstime_t 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;
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.
// 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/directory_storage.h"
#include "util/rstime.h"
class LocalDirectoryUpdater: public HashStorageClient, public RsTickingThread
{
@ -77,8 +78,8 @@ private:
RsFileHash mHashSalt ;
time_t mLastSweepTime;
time_t mLastTSUpdateTime;
rstime_t mLastSweepTime;
rstime_t mLastTSUpdateTime;
uint32_t mDelayBetweenDirectoryUpdates;
bool mIsEnabled ;

View file

@ -232,7 +232,7 @@ void HashStorage::data_tick()
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.
@ -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) ;
time_t now = time(NULL) ;
rstime_t now = time(NULL) ;
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.
@ -318,8 +318,8 @@ void HashStorage::clean()
{
RS_STACK_MUTEX(mHashMtx) ;
time_t now = time(NULL) ;
time_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds
rstime_t now = time(NULL) ;
rstime_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds
#ifdef HASHSTORAGE_DEBUG
std::cerr << "Cleaning hash cache." << std::endl ;

View file

@ -26,6 +26,7 @@
#include <map>
#include "util/rsthreads.h"
#include "retroshare/rsfiles.h"
#include "util/rstime.h"
/*!
* \brief The HashStorageClient class
@ -65,7 +66,7 @@ public:
*
* \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
{
@ -120,7 +121,7 @@ private:
uint64_t size ;
HashStorageClient *client;
uint32_t client_param ;
time_t ts;
rstime_t ts;
};
// current work
@ -136,7 +137,7 @@ private:
uint64_t mTotalSizeToHash ;
uint64_t mTotalHashedSize ;
uint64_t mTotalFilesToHash ;
time_t mLastSaveTime ;
rstime_t mLastSaveTime ;
// The following is used to estimate hashing speed.

View file

@ -171,7 +171,7 @@ int p3FileDatabase::tick()
tickRecv() ;
tickSend() ;
time_t now = time(NULL) ;
rstime_t now = time(NULL) ;
// cleanup
// - remove/delete shared file lists for people who are not friend anymore
@ -183,7 +183,7 @@ int p3FileDatabase::tick()
mLastCleanupTime = now ;
}
static time_t last_print_time = 0;
static rstime_t last_print_time = 0;
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)
friend_set.insert(*it) ;
}
time_t now = time(NULL);
rstime_t now = time(NULL);
for(uint32_t i=0;i<mRemoteDirectories.size();++i)
if(mRemoteDirectories[i] != NULL)
{
time_t recurs_mod_time ;
rstime_t recurs_mod_time ;
mRemoteDirectories[i]->getDirectoryRecursModTime(0,recurs_mod_time) ;
time_t last_contact = 0 ;
rstime_t last_contact = 0 ;
RsPeerDetails pd ;
if(rsPeers->getPeerDetails(mRemoteDirectories[i]->peerId(),pd))
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
time_t now = time(NULL);
rstime_t now = time(NULL);
if(mLastExtraFilesCacheUpdate + DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES <= now)
{
@ -1627,7 +1627,7 @@ void p3FileDatabase::handleDirSyncRequest(RsFileListsSyncRequestItem *item)
}
else
{
time_t local_recurs_max_time ;
rstime_t 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.
@ -1792,7 +1792,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem)
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
@ -1899,7 +1899,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem)
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,' ') ;
@ -1912,7 +1912,7 @@ void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *r
P3FILELISTS_DEBUG() << "currently at entry index " << e << std::endl;
#endif
time_t local_update_TS;
rstime_t 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)
{
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))
{
@ -2118,7 +2118,7 @@ void p3FileDatabase::checkSendBannedFilesInfo()
P3FILELISTS_DEBUG() << " Checking banned files information: " << std::endl;
#endif
time_t now = time(NULL);
rstime_t now = time(NULL);
std::list<RsPeerId> online_friends ;
rsPeers->getOnlineList(online_friends);

View file

@ -48,7 +48,7 @@
#include "ft/ftextralist.h"
#include "retroshare/rsfiles.h"
#include "services/p3service.h"
#include "util/rstime.h"
#include "file_sharing/hash_cache.h"
#include "file_sharing/directory_storage.h"
@ -71,7 +71,7 @@ struct PeerBannedFilesEntry
{
std::set<RsFileHash> mBannedHashOfHash;
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
@ -246,11 +246,11 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
struct DirSyncRequestData
{
RsPeerId peer_id ;
time_t request_TS ;
rstime_t request_TS ;
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,RsFileListsSyncResponseItem *> mPartialResponseItems;
@ -265,8 +265,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
mutable RsMutex mFLSMtx ;
uint32_t mUpdateFlags ;
std::string mFileSharingDir ;
time_t mLastCleanupTime;
time_t mLastDataRecvTS ;
rstime_t mLastCleanupTime;
rstime_t mLastDataRecvTS ;
// 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::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 time_t mLastExtraFilesCacheUpdate ;
mutable rstime_t mLastExtraFilesCacheUpdate ;
bool mTrustFriendNodesForBannedFiles ;
bool mBannedFileListNeedsUpdate;
time_t mLastPrimaryBanListChangeTimeStamp;
rstime_t mLastPrimaryBanListChangeTimeStamp;
void locked_sendBanInfo(const RsPeerId& pid);
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<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
{