mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
added params to disable the use of cache when retrieving msg and grp data and metadata. Made GxsUtil::check() not use the cache
This commit is contained in:
parent
22ceec6c43
commit
5ff58e6a5f
@ -1059,7 +1059,7 @@ bool RsDataService::validSize(RsNxsGrp* grp) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta, bool /* cache */)
|
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta, bool cache)
|
||||||
{
|
{
|
||||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
rstime::RsScopeTimer timer("");
|
rstime::RsScopeTimer timer("");
|
||||||
@ -1067,8 +1067,8 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
int requestedGroups = grp.size();
|
int requestedGroups = grp.size();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(grp.empty()){
|
if(grp.empty())
|
||||||
|
{
|
||||||
RsStackMutex stack(mDbMutex);
|
RsStackMutex stack(mDbMutex);
|
||||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, withMeta ? mGrpColumnsWithMeta : mGrpColumns, "", "");
|
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, withMeta ? mGrpColumnsWithMeta : mGrpColumns, "", "");
|
||||||
|
|
||||||
@ -1076,7 +1076,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
{
|
{
|
||||||
std::vector<RsNxsGrp*> grps;
|
std::vector<RsNxsGrp*> grps;
|
||||||
|
|
||||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
|
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0,cache);
|
||||||
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
|
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
|
||||||
|
|
||||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
@ -1091,8 +1091,9 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
RsStackMutex stack(mDbMutex);
|
RsStackMutex stack(mDbMutex);
|
||||||
std::map<RsGxsGroupId, RsNxsGrp *>::iterator mit = grp.begin();
|
std::map<RsGxsGroupId, RsNxsGrp *>::iterator mit = grp.begin();
|
||||||
|
|
||||||
@ -1106,7 +1107,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
if(c)
|
if(c)
|
||||||
{
|
{
|
||||||
std::vector<RsNxsGrp*> grps;
|
std::vector<RsNxsGrp*> grps;
|
||||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
|
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0,cache);
|
||||||
|
|
||||||
if(!grps.empty())
|
if(!grps.empty())
|
||||||
{
|
{
|
||||||
@ -1138,7 +1139,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset)
|
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset,bool use_cache)
|
||||||
{
|
{
|
||||||
if(c){
|
if(c){
|
||||||
bool valid = c->moveToFirst();
|
bool valid = c->moveToFirst();
|
||||||
@ -1150,7 +1151,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
|
|||||||
if(g)
|
if(g)
|
||||||
{
|
{
|
||||||
if (metaOffset)
|
if (metaOffset)
|
||||||
g->metaData = new RsGxsGrpMetaData(*locked_getGrpMeta(*c, metaOffset,true));
|
g->metaData = new RsGxsGrpMetaData(*locked_getGrpMeta(*c, metaOffset,use_cache));
|
||||||
else
|
else
|
||||||
g->metaData = nullptr;
|
g->metaData = nullptr;
|
||||||
|
|
||||||
@ -1161,9 +1162,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsDataService::retrieveNxsMsgs(
|
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool withMeta, bool cache)
|
||||||
const GxsMsgReq &reqIds, GxsMsgResult &msg, bool /* cache */,
|
|
||||||
bool withMeta )
|
|
||||||
{
|
{
|
||||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
rstime::RsScopeTimer timer("");
|
rstime::RsScopeTimer timer("");
|
||||||
@ -1186,9 +1185,7 @@ int RsDataService::retrieveNxsMsgs(
|
|||||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
{
|
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0,cache);
|
||||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
@ -1207,7 +1204,7 @@ int RsDataService::retrieveNxsMsgs(
|
|||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
{
|
{
|
||||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
|
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0,cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
@ -1230,7 +1227,7 @@ int RsDataService::retrieveNxsMsgs(
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs, int metaOffset)
|
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs, int metaOffset,bool use_cache)
|
||||||
{
|
{
|
||||||
bool valid = c->moveToFirst();
|
bool valid = c->moveToFirst();
|
||||||
while(valid){
|
while(valid){
|
||||||
@ -1238,7 +1235,7 @@ void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg
|
|||||||
|
|
||||||
if(m){
|
if(m){
|
||||||
if (metaOffset)
|
if (metaOffset)
|
||||||
m->metaData = new RsGxsMsgMetaData(*locked_getMsgMeta(*c, metaOffset,false));
|
m->metaData = new RsGxsMsgMetaData(*locked_getMsgMeta(*c, metaOffset,use_cache));
|
||||||
else
|
else
|
||||||
m->metaData = nullptr;
|
m->metaData = nullptr;
|
||||||
|
|
||||||
|
@ -143,9 +143,7 @@ public:
|
|||||||
* @param strictFilter if true do not request any message if reqIds is empty
|
* @param strictFilter if true do not request any message if reqIds is empty
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
int retrieveNxsMsgs(
|
int retrieveNxsMsgs( const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false, bool cache=true );
|
||||||
const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache,
|
|
||||||
bool withMeta = false );
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retrieves groups, if empty, retrieves all grps, if map is not empty
|
* Retrieves groups, if empty, retrieves all grps, if map is not empty
|
||||||
@ -274,7 +272,7 @@ private:
|
|||||||
* @param c cursor to result set
|
* @param c cursor to result set
|
||||||
* @param msgs messages retrieved from cursor are stored here
|
* @param msgs messages retrieved from cursor are stored here
|
||||||
*/
|
*/
|
||||||
void locked_retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs, int metaOffset);
|
void locked_retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs, int metaOffset, bool use_cache);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retrieves all the grp results from a cursor
|
* Retrieves all the grp results from a cursor
|
||||||
@ -282,7 +280,7 @@ private:
|
|||||||
* @param grps groups retrieved from cursor are stored here
|
* @param grps groups retrieved from cursor are stored here
|
||||||
* @param withMeta this initialise the metaData member of the nxsgroups retrieved
|
* @param withMeta this initialise the metaData member of the nxsgroups retrieved
|
||||||
*/
|
*/
|
||||||
void locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset);
|
void locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset, bool use_cache);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retrieves all the msg meta results from a cursor
|
* Retrieves all the msg meta results from a cursor
|
||||||
|
@ -142,9 +142,7 @@ public:
|
|||||||
* @param strictFilter if true do not request any message if reqIds is empty
|
* @param strictFilter if true do not request any message if reqIds is empty
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
virtual int retrieveNxsMsgs(
|
virtual int retrieveNxsMsgs( const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false , bool cache=true) = 0;
|
||||||
const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache,
|
|
||||||
bool withMeta = false ) = 0;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retrieves all groups stored. Caller owns the memory and is supposed to delete the RsNxsGrp pointers after use.
|
* Retrieves all groups stored. Caller owns the memory and is supposed to delete the RsNxsGrp pointers after use.
|
||||||
|
@ -2802,7 +2802,7 @@ void RsGenExchange::publishGrps()
|
|||||||
RsNxsGrpDataTemporaryMap oldGrpDatas;
|
RsNxsGrpDataTemporaryMap oldGrpDatas;
|
||||||
oldGrpDatas.insert(std::make_pair(grpId, (RsNxsGrp*)NULL));
|
oldGrpDatas.insert(std::make_pair(grpId, (RsNxsGrp*)NULL));
|
||||||
|
|
||||||
if(mDataStore->retrieveNxsGrps(oldGrpDatas,true,false) && oldGrpDatas.size() == 1)
|
if(mDataStore->retrieveNxsGrps(oldGrpDatas,true,true) && oldGrpDatas.size() == 1)
|
||||||
{
|
{
|
||||||
auto oldGrp = oldGrpDatas[grpId];
|
auto oldGrp = oldGrpDatas[grpId];
|
||||||
c->mOldGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(oldGrp->grp.bin_data,&oldGrp->grp.bin_len));
|
c->mOldGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(oldGrp->grp.bin_data,&oldGrp->grp.bin_len));
|
||||||
@ -3330,7 +3330,7 @@ void RsGenExchange::performUpdateValidation()
|
|||||||
for(auto vit(mGroupUpdates.begin()); vit != mGroupUpdates.end(); ++vit)
|
for(auto vit(mGroupUpdates.begin()); vit != mGroupUpdates.end(); ++vit)
|
||||||
grpDatas.insert(std::make_pair(vit->newGrp->grpId, (RsNxsGrp*)NULL));
|
grpDatas.insert(std::make_pair(vit->newGrp->grpId, (RsNxsGrp*)NULL));
|
||||||
|
|
||||||
if(grpDatas.empty() || !mDataStore->retrieveNxsGrps(grpDatas,true,false))
|
if(grpDatas.empty() || !mDataStore->retrieveNxsGrps(grpDatas,true,true))
|
||||||
{
|
{
|
||||||
if(grpDatas.empty())
|
if(grpDatas.empty())
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " Validation of multiple group updates failed: no group in list!" << std::endl;
|
RsErr() << __PRETTY_FUNCTION__ << " Validation of multiple group updates failed: no group in list!" << std::endl;
|
||||||
|
@ -3551,7 +3551,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mDataStore->retrieveNxsMsgs(msgIds, msgs, false, false);
|
mDataStore->retrieveNxsMsgs(msgIds, msgs, false);
|
||||||
|
|
||||||
NxsTransaction* newTr = new NxsTransaction();
|
NxsTransaction* newTr = new NxsTransaction();
|
||||||
newTr->mFlag = NxsTransaction::FLAG_STATE_WAITING_CONFIRM;
|
newTr->mFlag = NxsTransaction::FLAG_STATE_WAITING_CONFIRM;
|
||||||
|
@ -233,7 +233,7 @@ bool RsGxsIntegrityCheck::check(uint16_t service_type, RsGixs *mgixs, RsGeneralD
|
|||||||
|
|
||||||
// first take out all the groups
|
// first take out all the groups
|
||||||
std::map<RsGxsGroupId, RsNxsGrp*> grp;
|
std::map<RsGxsGroupId, RsNxsGrp*> grp;
|
||||||
mds->retrieveNxsGrps(grp, true, true);
|
mds->retrieveNxsGrps(grp, true, false);
|
||||||
GxsMsgReq msgIds;
|
GxsMsgReq msgIds;
|
||||||
GxsMsgReq grps;
|
GxsMsgReq grps;
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ bool RsGxsIntegrityCheck::check(uint16_t service_type, RsGixs *mgixs, RsGeneralD
|
|||||||
// now messages
|
// now messages
|
||||||
GxsMsgResult msgs;
|
GxsMsgResult msgs;
|
||||||
|
|
||||||
mds->retrieveNxsMsgs(grps, msgs, false, true);
|
mds->retrieveNxsMsgs(grps, msgs, true,false);
|
||||||
|
|
||||||
// Check msg ids and messages. Go through all message IDs referred to by the db call
|
// Check msg ids and messages. Go through all message IDs referred to by the db call
|
||||||
// and verify that the message belongs to the nxs msg data that was just retrieved.
|
// and verify that the message belongs to the nxs msg data that was just retrieved.
|
||||||
|
@ -389,7 +389,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
|
|||||||
std::list<RsGxsTransId> received_msgs ;
|
std::list<RsGxsTransId> received_msgs ;
|
||||||
|
|
||||||
GxsMsgResult msgs;
|
GxsMsgResult msgs;
|
||||||
mDs->retrieveNxsMsgs(grps, msgs, false, true);
|
mDs->retrieveNxsMsgs(grps, msgs, true, false);
|
||||||
|
|
||||||
for(GxsMsgResult::iterator mit = msgs.begin();mit != msgs.end(); ++mit)
|
for(GxsMsgResult::iterator mit = msgs.begin();mit != msgs.end(); ++mit)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user