diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index fb9706aef..5dda6ee47 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -463,6 +463,7 @@ void p3ConnectMgr::statusTick() #endif std::list retryIds; std::list::iterator it2; + std::list dummyToRemove; time_t now = time(NULL); time_t oldavail = now - MAX_AVAIL_PERIOD; @@ -473,6 +474,18 @@ void p3ConnectMgr::statusTick() std::map::iterator it; for(it = mFriendList.begin(); it != mFriendList.end(); it++) { + if (it->second.id == ("dummy" + it->second.gpg_id)) { + //if there is other friends for the same gpg key (that obviously are not "dummy"), we will remove this useless dummy friend + std::map::iterator it2; + for(it2 = mFriendList.begin(); it2 != mFriendList.end(); it2++) { + if ((it->second.id != it2->second.id) && (it->second.gpg_id == it2->second.gpg_id)) { + dummyToRemove.push_back(it->first); + break; + } + } + continue; + } + if (it->second.state & RS_PEER_S_CONNECTED) { continue; @@ -496,6 +509,10 @@ void p3ConnectMgr::statusTick() } } + for (std::list::iterator dummyIt = dummyToRemove.begin(); dummyIt != dummyToRemove.end(); dummyIt++) { + removeFriend(*dummyIt); + } + #ifndef P3CONNMGR_NO_AUTO_CONNECTION for(it2 = retryIds.begin(); it2 != retryIds.end(); it2++) @@ -2015,12 +2032,6 @@ bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMod std::cerr << "p3ConnectMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl; #endif -#ifdef CONN_DEBUG - std::cerr << "p3ConnectMgr::addFriend() removing dummy friend" << std::endl; -#endif - //remove any dummy friend because we just add a real ssl friend - removeFriend("dummy"+ gpg_id); - RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/