From d643f168a0685888292b40840b8fd21c8c3ae8bf Mon Sep 17 00:00:00 2001 From: drbob Date: Mon, 11 Jul 2011 12:11:58 +0000 Subject: [PATCH] Fixed up Adding / Removing Peers. * added OthersList to p3linkmgr. this is important so we can send ACTIONS for removed Peers. * added missing mStatusChanged when adding Friend. * added printPeerLists to PeerMgr and LinkMgr. * tweaked debugging. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4427 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3linkmgr.cc | 99 +++++++++++++---- libretroshare/src/pqi/p3linkmgr.h | 1 + libretroshare/src/pqi/p3peermgr.cc | 149 +++++++++++++++++--------- libretroshare/src/pqi/p3peermgr.h | 1 + libretroshare/src/pqi/pqiperson.cc | 5 +- libretroshare/src/pqi/pqipersongrp.cc | 17 ++- 6 files changed, 193 insertions(+), 79 deletions(-) diff --git a/libretroshare/src/pqi/p3linkmgr.cc b/libretroshare/src/pqi/p3linkmgr.cc index bc13a1bf0..bb204d29a 100644 --- a/libretroshare/src/pqi/p3linkmgr.cc +++ b/libretroshare/src/pqi/p3linkmgr.cc @@ -53,9 +53,12 @@ const int p3connectzone = 3431; /**** * #define LINKMGR_DEBUG 1 * #define LINKMGR_DEBUG_CONNFAIL 1 + * #define LINKMGR_DEBUG_ACTIONS 1 ***/ #define LINKMGR_DEBUG_CONNFAIL 1 +#define LINKMGR_DEBUG_ACTIONS 1 + /**** * #define P3CONNMGR_NO_TCP_CONNECTIONS 1 @@ -442,7 +445,7 @@ void p3LinkMgr::tickMonitors() if (mStatusChanged) { -#ifdef LINKMGR_DEBUG +#ifdef LINKMGR_DEBUG_ACTIONS std::cerr << "p3LinkMgr::tickMonitors() StatusChanged! List:" << std::endl; #endif /* assemble list */ @@ -462,7 +465,7 @@ void p3LinkMgr::tickMonitors() actionList.push_back(peer); -#ifdef LINKMGR_DEBUG +#ifdef LINKMGR_DEBUG_ACTIONS std::cerr << "Friend: " << peer.name << " Id: " << peer.id << " State: " << peer.state; if (peer.state & RS_PEER_S_FRIEND) std::cerr << " S:RS_PEER_S_FRIEND"; @@ -497,6 +500,7 @@ void p3LinkMgr::tickMonitors() } } } + /* do the Others as well! */ for(it = mOthersList.begin(); it != mOthersList.end(); it++) { @@ -512,7 +516,7 @@ void p3LinkMgr::tickMonitors() /* reset action */ it->second.actions = 0; -#ifdef LINKMGR_DEBUG +#ifdef LINKMGR_DEBUG_ACTIONS std::cerr << "Other: " << peer.name << " Id: " << peer.id << " State: " << peer.state; if (peer.state & RS_PEER_S_FRIEND) std::cerr << " S:RS_PEER_S_FRIEND"; @@ -554,7 +558,7 @@ void p3LinkMgr::tickMonitors() if (doStatusChange) { -#ifdef LINKMGR_DEBUG +#ifdef LINKMGR_DEBUG_ACTIONS std::cerr << "Sending to " << clients.size() << " monitorClients" << std::endl; #endif @@ -578,6 +582,14 @@ void p3LinkMgr::tickMonitors() /////////////////////////////////////////////////////////// #endif + + { + RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ + + /* Now Cleanup OthersList (served its purpose (MOVE Action)) */ + mOthersList.clear(); + } + } @@ -1760,11 +1772,13 @@ int p3LinkMgr::addFriend(const std::string &id, bool isVisible) peerConnectState pcs; pcs.dhtVisible = isVisible; pcs.id = id; - pcs.name = "Dummy Id Name"; + pcs.name = "NoName"; pcs.state = RS_PEER_S_FRIEND; pcs.actions = RS_PEER_NEW; mFriendList[id] = pcs; + + mStatusChanged = true; } mNetMgr->netAssistFriend(id, isVisible); @@ -1775,28 +1789,73 @@ int p3LinkMgr::addFriend(const std::string &id, bool isVisible) int p3LinkMgr::removeFriend(const std::string &id) { - RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ - -#ifdef LINKMGR_DEBUG - std::cerr << "p3LinkMgr::removeFriend(" << id << ")"; - std::cerr << std::endl; -#endif - - std::map::iterator it; - it = mFriendList.find(id); - - if (it == mFriendList.end()) { - std::cerr << "p3LinkMgr::removeFriend() ERROR, friend not there : " << id; + RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ + + #ifdef LINKMGR_DEBUG + std::cerr << "p3LinkMgr::removeFriend(" << id << ")"; std::cerr << std::endl; - return 0; - } + #endif + + std::map::iterator it; + it = mFriendList.find(id); + + if (it == mFriendList.end()) + { + std::cerr << "p3LinkMgr::removeFriend() ERROR, friend not there : " << id; + std::cerr << std::endl; + return 0; + } + + /* Move to OthersList (so remove can be handled via the action) */ + peerConnectState peer = it->second; + + peer.state &= (~RS_PEER_S_FRIEND); + peer.state &= (~RS_PEER_S_CONNECTED); + peer.state &= (~RS_PEER_S_ONLINE); + peer.actions = RS_PEER_MOVED; + peer.inConnAttempt = false; + mOthersList[id] = peer; + + mStatusChanged = true; + + mFriendList.erase(it); + } + + mNetMgr->netAssistFriend(id, false); - mFriendList.erase(it); return 1; } +void p3LinkMgr::printPeerLists(std::ostream &out) +{ + { + RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ + + out << "p3LinkMgr::printPeerLists() Friend List"; + out << std::endl; + + + std::map::iterator it; + for(it = mFriendList.begin(); it != mFriendList.end(); it++) + { + out << "\t SSL ID: " << it->second.id; + out << "\t State: " << it->second.state; + out << std::endl; + } + + out << "p3LinkMgr::printPeerLists() Others List"; + out << std::endl; + for(it = mOthersList.begin(); it != mOthersList.end(); it++) + { + out << "\t SSL ID: " << it->second.id; + out << "\t State: " << it->second.state; + } + } + + return; +} void printConnectState(std::ostream &out, peerConnectState &peer) diff --git a/libretroshare/src/pqi/p3linkmgr.h b/libretroshare/src/pqi/p3linkmgr.h index c7d3648b6..497942c20 100644 --- a/libretroshare/src/pqi/p3linkmgr.h +++ b/libretroshare/src/pqi/p3linkmgr.h @@ -184,6 +184,7 @@ void setFriendVisibility(const std::string &id, bool isVisible); /* add/remove friends */ int addFriend(const std::string &ssl_id, bool isVisible); int removeFriend(const std::string &ssl_id); +void printPeerLists(std::ostream &out); /*************** External Control ****************/ diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index 05f7061e9..e1d2bb6eb 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -62,11 +62,11 @@ const uint32_t MIN_TIME_BETWEEN_NET_RESET = 5; const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 4; /**** - * #define CONN_DEBUG 1 - * #define CONN_DEBUG_RESET 1 - * #define CONN_DEBUG_TICK 1 + * #define PEER_DEBUG 1 ***/ +#define PEER_DEBUG 1 + #define MAX_AVAIL_PERIOD 230 //times a peer stay in available state when not connected #define MIN_RETRY_PERIOD 140 @@ -120,7 +120,7 @@ p3PeerMgr::p3PeerMgr() } -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr() Startup" << std::endl; #endif @@ -139,7 +139,7 @@ void p3PeerMgr::setOwnNetworkMode(uint32_t netMode) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setOwnNetworkMode() :"; std::cerr << " Existing netMode: " << mOwnState.netMode; std::cerr << " Input netMode: " << netMode; @@ -160,7 +160,7 @@ void p3PeerMgr::setOwnVisState(uint32_t visState) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setOwnVisState()"; std::cerr << "Existing vis: " << mOwnState.visState; std::cerr << "Input vis: " << visState; @@ -217,12 +217,12 @@ bool p3PeerMgr::getOwnNetStatus(peerState &state) bool p3PeerMgr::isFriend(const std::string &id) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG_COMMON std::cerr << "p3PeerMgr::isFriend(" << id << ") called" << std::endl; #endif RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ bool ret = (mFriendList.end() != mFriendList.find(id)); -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG_COMMON std::cerr << "p3PeerMgr::isFriend(" << id << ") returning : " << ret << std::endl; #endif return ret; @@ -345,7 +345,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint if (id == AuthSSL::getAuthSSL()->OwnId()) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::addFriend() cannot add own id as a friend." << std::endl; #endif /* (1) already exists */ @@ -357,14 +357,14 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint * (3) is non-existant -> create new one. */ -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl; #endif std::map::iterator it; if (mFriendList.end() != mFriendList.find(id)) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::addFriend() Already Exists" << std::endl; #endif /* (1) already exists */ @@ -375,7 +375,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint // if (!AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id) && gpg_id != AuthGPG::getAuthGPG()->getGPGOwnId()) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::addFriend() gpg is not accepted" << std::endl; #endif /* no auth */ @@ -387,7 +387,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint if (mOthersList.end() != (it = mOthersList.find(id))) { /* (2) in mOthersList -> move over */ -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::addFriend() Move from Others" << std::endl; #endif @@ -409,7 +409,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint } else { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::addFriend() Creating New Entry" << std::endl; #endif @@ -441,6 +441,11 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint mLinkMgr->addFriend(id, !(visState & RS_VIS_STATE_NODHT)); } +#ifdef PEER_DEBUG + printPeerLists(std::cerr); + mLinkMgr->printPeerLists(std::cerr); +#endif + return true; } @@ -448,14 +453,12 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint bool p3PeerMgr::removeFriend(const std::string &id) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::removeFriend() for id : " << id << std::endl; std::cerr << "p3PeerMgr::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl; #endif - mLinkMgr->removeFriend(id); - - std::list toRemove; + std::list toRemove; // This is a list of SSLIds. { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ @@ -467,7 +470,7 @@ bool p3PeerMgr::removeFriend(const std::string &id) for(it = mFriendList.begin(); it != mFriendList.end(); it++) { if (it->second.id == id || it->second.gpg_id == id) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::removeFriend() friend found in the list." << id << std::endl; #endif peerState peer = it->second; @@ -481,18 +484,26 @@ bool p3PeerMgr::removeFriend(const std::string &id) } } - std::list::iterator toRemoveIt; - for(toRemoveIt = toRemove.begin(); toRemoveIt != toRemove.end(); toRemoveIt++) { - if (mFriendList.end() != (it = mFriendList.find(*toRemoveIt))) { + std::list::iterator rit; + for(rit = toRemove.begin(); rit != toRemove.end(); rit++) + { + if (mFriendList.end() != (it = mFriendList.find(*rit))) + { mFriendList.erase(it); } } -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl; #endif } + std::list::iterator rit; + for(rit = toRemove.begin(); rit != toRemove.end(); rit++) + { + mLinkMgr->removeFriend(*rit); + } + /* remove id from all groups */ std::list peerIds; peerIds.push_back(id); @@ -501,16 +512,52 @@ bool p3PeerMgr::removeFriend(const std::string &id) IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ +#ifdef PEER_DEBUG + printPeerLists(std::cerr); + mLinkMgr->printPeerLists(std::cerr); +#endif + return !toRemove.empty(); } +void p3PeerMgr::printPeerLists(std::ostream &out) +{ + { + RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ + + out << "p3PeerMgr::printPeerLists() Friend List"; + out << std::endl; + + + std::map::iterator it; + for(it = mFriendList.begin(); it != mFriendList.end(); it++) + { + out << "\t SSL ID: " << it->second.id; + out << "\t GPG ID: " << it->second.gpg_id; + out << std::endl; + } + + out << "p3PeerMgr::printPeerLists() Others List"; + out << std::endl; + for(it = mOthersList.begin(); it != mOthersList.end(); it++) + { + out << "\t SSL ID: " << it->second.id; + out << "\t GPG ID: " << it->second.gpg_id; + out << std::endl; + } + } + + return; +} + + #if 0 bool p3PeerMgr::addNeighbour(std::string id) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::addNeighbour() not implemented anymore." << id << std::endl; #endif @@ -602,10 +649,6 @@ bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in add mNetMgr->setLocalAddress(addr); mLinkMgr->setLocalAddress(addr); - - #ifdef CONN_DEBUG_RESET - std::cerr << "p3PeerMgr::setLocalAddress() Calling NetReset" << std::endl; - #endif } return true; } @@ -617,9 +660,9 @@ bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in add { if (mOthersList.end() == (it = mOthersList.find(id))) { - #ifdef CONN_DEBUG - std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl; - #endif +#ifdef PEER_DEBUG + std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl; +#endif return false; } } @@ -661,7 +704,7 @@ bool p3PeerMgr::setExtAddress(const std::string &id, struct sockaddr_in addr) { if (mOthersList.end() == (it = mOthersList.find(id))) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl; #endif return false; @@ -701,7 +744,7 @@ bool p3PeerMgr::setDynDNS(const std::string &id, const std::string &dyndns) { if (mOthersList.end() == (it = mOthersList.find(id))) { - #ifdef CONN_DEBUG + #ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setDynDNS() cannot add dyn dns info : peer id not found in friend list id: " << id << std::endl; #endif return false; @@ -718,7 +761,7 @@ bool p3PeerMgr::setDynDNS(const std::string &id, const std::string &dyndns) bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &addrs) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setAddressList() called for id : " << id << std::endl; #endif @@ -737,7 +780,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet & { if (mOthersList.end() == (it = mOthersList.find(id))) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list. id: " << id << std::endl; #endif return false; @@ -746,7 +789,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet & /* "it" points to peer */ it->second.ipAddrs.updateAddrs(addrs); -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setLocalAddress() Updated Address for: " << id; std::cerr << std::endl; it->second.ipAddrs.printAddrs(std::cerr); @@ -761,7 +804,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet & bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddress &addr) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::updateCurrentAddress() called for id : " << id << std::endl; #endif @@ -791,7 +834,7 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres it->second.serveraddr = addr.mAddr; } -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::updatedCurrentAddress() Updated Address for: " << id; std::cerr << std::endl; it->second.ipAddrs.printAddrs(std::cerr); @@ -806,7 +849,7 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres bool p3PeerMgr::updateLastContact(const std::string& id) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::updateLastContact() called for id : " << id << std::endl; #endif @@ -865,7 +908,7 @@ bool p3PeerMgr::setLocation(const std::string &id, const std::string &locatio { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::setLocation() called for id : " << id << "; with location " << location << std::endl; #endif if (id == AuthSSL::getAuthSSL()->OwnId()) @@ -995,7 +1038,7 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list& saveData) mOwnState.ipAddrs.mLocal.loadTlv(item->localAddrList); mOwnState.ipAddrs.mExt.loadTlv(item->extAddrList); -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::saveList() Own Config Item:" << std::endl; item->print(std::cerr, 10); std::cerr << std::endl; @@ -1025,7 +1068,7 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list& saveData) saveData.push_back(item); saveCleanupList.push_back(item); -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::saveList() Peer Config Item:" << std::endl; item->print(std::cerr, 10); std::cerr << std::endl; @@ -1041,9 +1084,9 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list& saveData) kv.value = (useExtAddrFinder)?"TRUE":"FALSE" ; vitem->tlvkvs.pairs.push_back(kv) ; - #ifdef CONN_DEBUG - std::cout << "Pushing item for use_extr_addr_finder = " << mUseExtAddrFinder << std::endl ; - #endif +#ifdef PEER_DEBUG + std::cout << "Pushing item for use_extr_addr_finder = " << useExtAddrFinder << std::endl ; +#endif saveData.push_back(vitem); saveCleanupList.push_back(vitem); @@ -1056,9 +1099,9 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list& saveData) kv2.value = (allowTunnelConnection)?"TRUE":"FALSE" ; vitem2->tlvkvs.pairs.push_back(kv2) ; - #ifdef CONN_DEBUG - std::cout << "Pushing item for allow_tunnel_connection = " << mAllowTunnelConnection << std::endl ; - #endif +#ifdef PEER_DEBUG + std::cout << "Pushing item for allow_tunnel_connection = " << allowTunnelConnection << std::endl ; +#endif saveData.push_back(vitem2); saveCleanupList.push_back(vitem2); @@ -1099,7 +1142,7 @@ bool p3PeerMgr::loadList(std::list& load) return false; } -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::loadList() Item Count: " << load.size() << std::endl; #endif @@ -1114,7 +1157,7 @@ bool p3PeerMgr::loadList(std::list& load) { if (pitem->pid == ownId) { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::loadList() Own Config Item:" << std::endl; pitem->print(std::cerr, 10); std::cerr << std::endl; @@ -1128,7 +1171,7 @@ bool p3PeerMgr::loadList(std::list& load) } else { -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::loadList() Peer Config Item:" << std::endl; pitem->print(std::cerr, 10); std::cerr << std::endl; @@ -1159,7 +1202,7 @@ bool p3PeerMgr::loadList(std::list& load) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::loadList() General Variable Config Item:" << std::endl; vitem->print(std::cerr, 10); std::cerr << std::endl; @@ -1185,7 +1228,7 @@ bool p3PeerMgr::loadList(std::list& load) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ -#ifdef CONN_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgr::loadList() Peer group item:" << std::endl; gitem->print(std::cerr, 10); std::cerr << std::endl; diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index a0c6454be..16af29bad 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -148,6 +148,7 @@ bool addFriend(const std::string &ssl_id, const std::string &gpg_id, uint32_t n bool removeFriend(const std::string &ssl_id); bool addNeighbour(const std::string&); +void printPeerLists(std::ostream &out); /*************** External Control ****************/ diff --git a/libretroshare/src/pqi/pqiperson.cc b/libretroshare/src/pqi/pqiperson.cc index 4d9ce7a24..d8bc0b034 100644 --- a/libretroshare/src/pqi/pqiperson.cc +++ b/libretroshare/src/pqi/pqiperson.cc @@ -268,7 +268,8 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState) "CONNECT_FAILED->marking so!"); active = false; activepqi = NULL; - } else { + } else + { pqioutput(PQL_WARNING, pqipersonzone, "CONNECT_FAILED-> from an unactive connection, don't flag the peer as not connected, just try next attempt !"); } @@ -279,7 +280,7 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState) "CONNECT_FAILED+NOT active -> try connect again"); } - /* notify up (But not if we are actually active: rtn -1 case above) */ + /* notify up */ if (pqipg) { struct sockaddr_in raddr; diff --git a/libretroshare/src/pqi/pqipersongrp.cc b/libretroshare/src/pqi/pqipersongrp.cc index e0e13b450..f57f3100b 100644 --- a/libretroshare/src/pqi/pqipersongrp.cc +++ b/libretroshare/src/pqi/pqipersongrp.cc @@ -381,9 +381,9 @@ int pqipersongrp::addPeer(std::string id) pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, out.str()); } -#ifdef PGRP_DEBUG - std::cerr << " pqipersongrp::addPeer() id: " << id; + std::cerr << "pqipersongrp::addPeer() id: " << id; std::cerr << std::endl; +#ifdef PGRP_DEBUG #endif SearchModule *sm = NULL; @@ -394,6 +394,10 @@ int pqipersongrp::addPeer(std::string id) { pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, "pqipersongrp::addPeer() Peer already in Use!"); + + std::cerr << " pqipersongrp::addPeer() ERROR Peer already in use! id: " << id; + std::cerr << std::endl; + return -1; } @@ -419,9 +423,9 @@ int pqipersongrp::removePeer(std::string id) std::map::iterator it; #ifdef PGRP_DEBUG - std::cerr << " pqipersongrp::removePeer() id: " << id; - std::cerr << std::endl; #endif + std::cerr << "pqipersongrp::removePeer() id: " << id; + std::cerr << std::endl; RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/ @@ -438,6 +442,11 @@ int pqipersongrp::removePeer(std::string id) delete p; mods.erase(it); } + else + { + std::cerr << " pqipersongrp::removePeer() ERROR doesn't exist! id: " << id; + std::cerr << std::endl; + } return 1; }