suppressed memory fault (call to ++it on a invalid iterator). Simplified a bit some syntax

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3623 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-10-06 19:32:55 +00:00
parent 709f9b515b
commit a76566c65d

View File

@ -326,11 +326,12 @@ int bdQuery::addPeer(const bdId *id, uint32_t mode)
fprintf(stderr, "Dropping Peer that dont reply\n");
#endif
bool removed = false;
for(it = mClosest.begin(); (!removed) && (it != mClosest.end()); it++)
for(it = mClosest.begin(); it != mClosest.end(); ++it)
{
time_t sendts = ts - it->second.mLastSendTime;
bool hasSent = (it->second.mLastSendTime != 0);
bool hasReply = (it->second.mLastRecvTime >= it->second.mLastSendTime);
if ((hasSent) && (!hasReply) && (sendts > EXPECTED_REPLY))
{
#ifdef DEBUG_QUERY
@ -340,6 +341,7 @@ int bdQuery::addPeer(const bdId *id, uint32_t mode)
#endif
mClosest.erase(it);
removed = true;
break ;
}
}
}
@ -349,7 +351,7 @@ int bdQuery::addPeer(const bdId *id, uint32_t mode)
{
std::multimap<bdMetric, bdPeer>::iterator it;
it = mClosest.end();
if (mClosest.begin() != mClosest.end())
if (!mClosest.empty())
{
it--;
#ifdef DEBUG_QUERY
@ -503,15 +505,15 @@ int bdQuery::addPotentialPeer(const bdId *id, uint32_t mode)
{
std::multimap<bdMetric, bdPeer>::iterator it;
it = mPotentialClosest.end();
if (mPotentialClosest.begin() != mPotentialClosest.end())
if(!mPotentialClosest.empty())
{
it--;
--it;
#ifdef DEBUG_QUERY
fprintf(stderr, "Removing Furthest Peer: ");
mFns->bdPrintId(std::cerr, &(it->second.mPeerId));
fprintf(stderr, "\n");
#endif
mPotentialClosest.erase(it);
}
}