modified wrong comment in why mLastPost should not be used in rsgxsnetservice.cc, and added a call to clearing GrpMeta cache when new msg in that group are received

This commit is contained in:
csoler 2016-08-02 16:25:00 +02:00
parent 3cd90ae11c
commit 17003f136b
2 changed files with 27 additions and 20 deletions

View File

@ -712,25 +712,25 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
// start a transaction // start a transaction
mDb->beginTransaction(); mDb->beginTransaction();
for(; mit != msg.end(); ++mit){ for(; mit != msg.end(); ++mit)
{
RsNxsMsg* msgPtr = mit->first; RsNxsMsg* msgPtr = mit->first;
RsGxsMsgMetaData* msgMetaPtr = mit->second; RsGxsMsgMetaData* msgMetaPtr = mit->second;
#ifdef RS_DATA_SERVICE_DEBUG #ifdef RS_DATA_SERVICE_DEBUG
std::cerr << "RsDataService::storeMessage() "; std::cerr << "RsDataService::storeMessage() ";
std::cerr << " GroupId: " << msgMetaPtr->mGroupId.toStdString(); std::cerr << " GroupId: " << msgMetaPtr->mGroupId.toStdString();
std::cerr << " MessageId: " << msgMetaPtr->mMsgId.toStdString(); std::cerr << " MessageId: " << msgMetaPtr->mMsgId.toStdString();
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
// skip msg item if size if greater than // skip msg item if size if greater than
if(!validSize(msgPtr)) if(!validSize(msgPtr))
{ {
std::cerr << "RsDataService::storeMessage() ERROR invalid size"; std::cerr << "RsDataService::storeMessage() ERROR invalid size";
std::cerr << std::endl; std::cerr << std::endl;
continue; continue;
} }
ContentValue cv; ContentValue cv;
@ -773,14 +773,18 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
cv.put(KEY_CHILD_TS, (int32_t)msgMetaPtr->mChildTs); cv.put(KEY_CHILD_TS, (int32_t)msgMetaPtr->mChildTs);
if (!mDb->sqlInsert(MSG_TABLE_NAME, "", cv)) if (!mDb->sqlInsert(MSG_TABLE_NAME, "", cv))
{ {
std::cerr << "RsDataService::storeMessage() sqlInsert Failed"; std::cerr << "RsDataService::storeMessage() sqlInsert Failed";
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "\t For GroupId: " << msgMetaPtr->mGroupId.toStdString(); std::cerr << "\t For GroupId: " << msgMetaPtr->mGroupId.toStdString();
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "\t & MessageId: " << msgMetaPtr->mMsgId.toStdString(); std::cerr << "\t & MessageId: " << msgMetaPtr->mMsgId.toStdString();
std::cerr << std::endl; std::cerr << std::endl;
} }
// This is needed so that mLastPost is correctly updated in the group meta when it is re-loaded.
locked_clearGrpMetaCache(msgMetaPtr->mGroupId);
} }
// finish transaction // finish transaction

View File

@ -2096,7 +2096,10 @@ void RsGxsNetService::updateServerSyncTS()
else else
msui = mapIT->second; msui = mapIT->second;
// (cyril) I'm removing this, becuse mLastPost is *never* updated. So this code it not useful at all. // (cyril) I'm removing this, because the msgUpdateTS is updated when new messages are received by calling locked_stampMsgServerUpdateTS().
// mLastPost is actually updated somewhere when loading group meta data. It's not clear yet whether it is set to the latest publish time (wrong)
// or the latest receive time (right). The former would cause problems because it would need to compare times coming from different (potentially async-ed)
// machines.
// //
// if(grpMeta->mLastPost > msui->msgUpdateTS ) // if(grpMeta->mLastPost > msui->msgUpdateTS )
// { // {