From ee5417e46a1b1eae98c9d9742d76052152741743 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 23 Jan 2011 14:06:56 +0000 Subject: [PATCH] suppressed bug due to asking again to publish a groupkey that had been deleted before. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3976 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/services/p3distrib.cc | 39 ++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/libretroshare/src/services/p3distrib.cc b/libretroshare/src/services/p3distrib.cc index 7297e5835..c0ba043be 100644 --- a/libretroshare/src/services/p3distrib.cc +++ b/libretroshare/src/services/p3distrib.cc @@ -525,19 +525,22 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey) #endif // if this is an in-date full publish key then keep to see if group arrives later - if(((time_t)(newKey->key.startTS + mStorePeriod) > time(NULL)) && (newKey->key.keyFlags & RSTLV_KEY_TYPE_FULL)){ + if(((time_t)(newKey->key.startTS + mStorePeriod) > time(NULL)) && (newKey->key.keyFlags & RSTLV_KEY_TYPE_FULL)) + { // make sure key does not exist if(mRecvdPubKeys.find(gid) == mRecvdPubKeys.end()){ mRecvdPubKeys.insert(std::pair(gid, newKey)); return true; - }else{ + } + else + { #ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::loadGroupKey() Key already received; discarding"; std::cerr << std::endl; #endif delete newKey; - + return false ; } } @@ -548,11 +551,8 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey) #endif delete newKey; - - + return false ; } - - return false; } @@ -604,7 +604,9 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey) return updateOk; } - delete newKey; + if(!updateOk) + delete newKey; + return updateOk; } @@ -726,7 +728,7 @@ void p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src, (git->second).msgs[msg->msgId] = msg; // update the time stamp of group for last post - if((git->second.lastPost < msg->timestamp)) + if((git->second.lastPost < (time_t)msg->timestamp)) git->second.lastPost = msg->timestamp; /* now update parents TS */ @@ -1308,13 +1310,22 @@ bool p3GroupDistrib::subscribeToGroup(const std::string &grpId, bool subscrib bool p3GroupDistrib::attemptPublishKeysRecvd() { + std::map::iterator mit = mRecvdPubKeys.begin(); - std::map::iterator mit; - mit = mRecvdPubKeys.begin(); + for(;mit != mRecvdPubKeys.end();) + { + bool ok = loadGroupKey(mit->second); - for(; mit != mRecvdPubKeys.end(); mit++){ - loadGroupKey(mit->second); - } + if(!ok) + { + std::map::iterator tmp(mit); + ++mit ; + + mRecvdPubKeys.erase(tmp) ; + } + else + ++mit ; + } return true; }