fix to duplicate msgs found between cachefile being formed

(caused by not marking cache opt loaded files as local or not)
also missing own-msgs bug caused by not accounting for msgs created by users


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4374 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2011-07-02 01:14:23 +00:00
parent 3f809b6c3a
commit 37a81e98ef

View File

@ -199,7 +199,7 @@ int p3GroupDistrib::tick()
receivePubKeys();
}
// update cache document every 1 minute (5 mins in production)
// update cache document every 1 minute (should be 5 mins in production)
// after historical files have loaded and there is reason to
bool updateCacheDoc = false;
{
@ -680,7 +680,7 @@ void p3GroupDistrib::locked_processHistoryCached(const std::string& grpId)
std::list<CacheData> cDataList;
std::list<CacheData>::iterator cit;
std::string file;
CacheData cDataTemp;
uint16_t cacheType = CacheSource::getCacheType();
// if not history cached then load it
@ -701,7 +701,7 @@ void p3GroupDistrib::locked_processHistoryCached(const std::string& grpId)
// note: you could load msgs for a cache historied group that is not loaded,
// but any request for info of affected grp will consequently load
// all its msgs through this function anyways
locked_loadFileMsgs(file, cit->cid.subid, cit->pid, cit->recvd, false, true);
locked_loadFileMsgs(file, cit->cid.subid, cit->pid, cit->recvd, (cit->pid == mOwnId), true);
}
@ -1985,7 +1985,8 @@ void p3GroupDistrib::locked_publishPendingMsgs()
newCache.pid = mOwnId;
newCache.cid.type = CacheSource::getCacheType();
newCache.cid.subid = locked_determineCacheSubId();
newCache.cid.subid = locked_determineCacheSubId();
/* create filename */
std::string path = CacheSource::getCacheDir();
@ -2001,6 +2002,11 @@ void p3GroupDistrib::locked_publishPendingMsgs()
bool resave = false;
std::list<RsDistribSignedMsg *>::iterator it;
// for cache opt
std::list<grpCachePair> gcpList;
pCacheId pcId(newCache.pid, newCache.cid.subid);
for(it = mPendingPublish.begin(); it != mPendingPublish.end(); it++)
{
#ifdef DISTRIB_DEBUG
@ -2022,10 +2028,15 @@ void p3GroupDistrib::locked_publishPendingMsgs()
// prevent sending original source of message to peers
(*it)->PeerId(mOwnId);
gcpList.push_back(grpCachePair((*it)->grpId, pcId));
if(!store->SendItem(*it)) /* deletes it */
{
ok &= false;
}
}
/* Extract File Information from pqistore */
@ -2060,6 +2071,7 @@ void p3GroupDistrib::locked_publishPendingMsgs()
if(ok)
refreshCache(newCache);
std::list<grpCachePair>::iterator git = gcpList.begin();
if (ok && resave)
{
@ -2069,7 +2081,15 @@ void p3GroupDistrib::locked_publishPendingMsgs()
#endif
/* flag to store config (saying we've published messages) */
IndicateConfigChanged(); /**** INDICATE CONFIG CHANGED! *****/
// add new cache to cache opt doc
for(;git != gcpList.end(); git++)
mMsgHistPending.push_back(*git);
mUpdateCacheDoc = true;
}
}
@ -2389,7 +2409,9 @@ RsDistribMsg *p3GroupDistrib::locked_getGroupMsg(const std::string& grpId, const
/************* ALREADY LOCKED ************/
#ifdef ENABLE_CACHE_OPT
locked_processHistoryCached(grpId);
#endif
std::map<std::string, GroupInfo>::iterator git;
if (mGroups.end() == (git = mGroups.find(grpId)))
@ -5133,7 +5155,11 @@ bool p3GroupDistrib::getDummyParentMsgList(const std::string& grpId, const std::
RsDistribDummyMsg *p3GroupDistrib::locked_getGroupDummyMsg(const std::string& grpId, const std::string& msgId)
{
#ifdef ENABLE_CACHE_OPT
locked_processHistoryCached(grpId);
#endif
#ifdef DISTRIB_DUMMYMSG_DEBUG
std::cerr << "p3GroupDistrib::locked_getGroupDummyMsg(grpId:" << grpId << "," << msgId << ")";
std::cerr << std::endl;