mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 05:42:19 -04:00
faulty version of cache opt - committing to keep useful code in history
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-cacheopt@4528 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
bea5f2250f
commit
49f0f13fa2
1 changed files with 116 additions and 80 deletions
|
@ -398,6 +398,7 @@ void p3GroupDistrib::updateCacheDocument()
|
||||||
std::vector<grpCachePair> msgHistRestart;
|
std::vector<grpCachePair> msgHistRestart;
|
||||||
pugi::xml_node messages_node;
|
pugi::xml_node messages_node;
|
||||||
pCacheId pCid;
|
pCacheId pCid;
|
||||||
|
pugi::xml_node cacheNode;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
@ -419,15 +420,20 @@ void p3GroupDistrib::updateCacheDocument()
|
||||||
if(!messages_node)
|
if(!messages_node)
|
||||||
messages_node = nodeIter.append_child("messages");
|
messages_node = nodeIter.append_child("messages");
|
||||||
|
|
||||||
messages_node.append_child("msg");
|
|
||||||
|
// local caches at begining so loaded first
|
||||||
|
if(pCid.first == mOwnId)
|
||||||
|
cacheNode = messages_node.prepend_child("msg");
|
||||||
|
else
|
||||||
|
cacheNode = messages_node.append_child("msg");
|
||||||
|
|
||||||
// add cache id
|
// add cache id
|
||||||
messages_node.last_child().append_child("pId").append_child(
|
cacheNode.last_child().append_child("pId").append_child(
|
||||||
pugi::node_pcdata).set_value(msgIt->second.first
|
pugi::node_pcdata).set_value(msgIt->second.first
|
||||||
.c_str());
|
.c_str());
|
||||||
sprintf(subIdBuffer, "%d", msgIt->second.second);
|
sprintf(subIdBuffer, "%d", msgIt->second.second);
|
||||||
subId = subIdBuffer;
|
subId = subIdBuffer;
|
||||||
messages_node.last_child().append_child("subId").append_child(
|
cacheNode.last_child().append_child("subId").append_child(
|
||||||
pugi::node_pcdata).set_value(subId.c_str());
|
pugi::node_pcdata).set_value(subId.c_str());
|
||||||
|
|
||||||
// add msg to grp set
|
// add msg to grp set
|
||||||
|
@ -1152,8 +1158,8 @@ void p3GroupDistrib::loadFileGroups(const std::string &filename, const std::stri
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSubId, const std::string &src, uint32_t ts, bool local, bool historical,
|
void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSubId,
|
||||||
bool cacheLoad)
|
const std::string &src, uint32_t ts, bool local, bool historical, bool cacheLoad)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
|
@ -1163,27 +1169,39 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
bool cache = false;
|
bool cache = false;
|
||||||
|
bool cached = false;
|
||||||
|
|
||||||
|
/****
|
||||||
|
* okay here is the logic:
|
||||||
|
* If this a newly received cache then this loaded and cached-opted granted the
|
||||||
|
* message doesn't exist already
|
||||||
|
* If this is a historical load (caches that exist at rs start-up)
|
||||||
|
* and not a cache-opt load then the cache-opt table is checked to see if it exists
|
||||||
|
* if it does then nothing is loaded, but the latest cache timestamp is updated
|
||||||
|
*
|
||||||
|
* But now if this is a cache-load then load up as usual
|
||||||
|
* and should ignore fact that it is cache-opted since
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// if cache id exists in cache table exit
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(distribMtx);
|
RsStackMutex stack(distribMtx);
|
||||||
// if this is a cache load proceed if not check
|
// if this is a cache load proceed if not check
|
||||||
// cache id exists in cache table, if so don't load
|
// cache id exists in cache table, if so don't load
|
||||||
|
|
||||||
if(!cacheLoad)
|
if(!cacheLoad)
|
||||||
{
|
{
|
||||||
|
// if cache id exists and old cache don't load msgs
|
||||||
if(historical && locked_historyCached(pCacheId(src, cacheSubId)))
|
if(historical && locked_historyCached(pCacheId(src, cacheSubId)))
|
||||||
{
|
cached = true;
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
cache = true;
|
cache = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't attempt to load if cached
|
||||||
|
if(!cached)
|
||||||
|
{
|
||||||
// link grp to cache id (only one cache id, so doesn't matter if one grp comes out twice
|
// link grp to cache id (only one cache id, so doesn't matter if one grp comes out twice
|
||||||
// with same cache id)
|
// with same cache id)
|
||||||
std::map<std::string, pCacheId> msgCacheMap;
|
std::map<std::string, pCacheId> msgCacheMap;
|
||||||
|
@ -1214,6 +1232,18 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub
|
||||||
if ((newMsg = dynamic_cast<RsDistribSignedMsg *>(item)))
|
if ((newMsg = dynamic_cast<RsDistribSignedMsg *>(item)))
|
||||||
{
|
{
|
||||||
grpId = newMsg->grpId;
|
grpId = newMsg->grpId;
|
||||||
|
cached = false;
|
||||||
|
// if grp cache-opted still then delete msg
|
||||||
|
if(locked_historyCached(grpId, cached)){
|
||||||
|
|
||||||
|
if(cached && historical)
|
||||||
|
{
|
||||||
|
delete newMsg;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(loadMsg(newMsg, src, local, historical))
|
if(loadMsg(newMsg, src, local, historical))
|
||||||
{
|
{
|
||||||
if(cache)
|
if(cache)
|
||||||
|
@ -1255,6 +1285,10 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub
|
||||||
mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache));
|
mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
delete store;
|
||||||
|
}
|
||||||
|
|
||||||
if (local)
|
if (local)
|
||||||
{
|
{
|
||||||
/* now we create a map of time -> subid
|
/* now we create a map of time -> subid
|
||||||
|
@ -1287,7 +1321,6 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete store;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1553,7 +1586,9 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if unique (new) msg - do validation */
|
/* if not new unique (new) msg - do validation */
|
||||||
|
if(!local)
|
||||||
|
{
|
||||||
if (!locked_validateDistribSignedMsg(git->second, newMsg) )
|
if (!locked_validateDistribSignedMsg(git->second, newMsg) )
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
|
@ -1563,6 +1598,7 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src,
|
||||||
delete newMsg;
|
delete newMsg;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void *temp_ptr = newMsg->packet.bin_data;
|
void *temp_ptr = newMsg->packet.bin_data;
|
||||||
int temp_len = newMsg->packet.bin_len;
|
int temp_len = newMsg->packet.bin_len;
|
||||||
|
@ -1922,7 +1958,7 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
||||||
newCache.cid.type = CacheSource::getCacheType();
|
newCache.cid.type = CacheSource::getCacheType();
|
||||||
newCache.cid.subid = locked_determineCacheSubId();
|
newCache.cid.subid = locked_determineCacheSubId();
|
||||||
|
|
||||||
// remove old cache entry using this pid
|
// remove old cache entry using this cache id
|
||||||
locked_removeCacheTableEntry(pCacheId(newCache.pid, newCache.cid.subid));
|
locked_removeCacheTableEntry(pCacheId(newCache.pid, newCache.cid.subid));
|
||||||
|
|
||||||
/* create filename */
|
/* create filename */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue