Fix Clang warnings: Overloaded vf hide in p3dhtmgr

warning: 'p3DhtMgr::findPeer' hides overloaded virtual function [-
Woverloaded-virtual]
virtual bool    findPeer(std::string id);
warning: 'p3DhtMgr::dropPeer' hides overloaded virtual function [-
Woverloaded-virtual]
virtual bool    dropPeer(std::string id);
warning: 'p3DhtMgr::getPeerStatus' hides overloaded virtual function [-
Woverloaded-virtual]
virtual bool    getPeerStatus(std::string id,
This commit is contained in:
Phenom 2017-03-16 21:04:38 +01:00 committed by csoler
parent 5bc6558567
commit 65321501e4
2 changed files with 34 additions and 36 deletions

View File

@ -92,7 +92,7 @@ dhtPeerEntry::dhtPeerEntry()
return; return;
} }
p3DhtMgr::p3DhtMgr(std::string id, pqiConnectCb *cb) p3DhtMgr::p3DhtMgr(RsPeerId id, pqiConnectCb *cb)
:pqiNetAssistConnect(id, cb), dhtMtx("p3DhtMgr"), mStunRequired(true) :pqiNetAssistConnect(id, cb), dhtMtx("p3DhtMgr"), mStunRequired(true)
{ {
/* setup own entry */ /* setup own entry */
@ -237,13 +237,13 @@ bool p3DhtMgr::setExternalInterface(
/* add / remove peers */ /* add / remove peers */
bool p3DhtMgr::findPeer(std::string id) bool p3DhtMgr::findPeer(const RsPeerId& id)
{ {
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/ RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
mDhtModifications = true; mDhtModifications = true;
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
it = peers.find(id); it = peers.find(id);
if (it != peers.end()) if (it != peers.end())
{ {
@ -281,14 +281,14 @@ bool p3DhtMgr::findPeer(std::string id)
return true; return true;
} }
bool p3DhtMgr::dropPeer(std::string id) bool p3DhtMgr::dropPeer(const RsPeerId& id)
{ {
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/ RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
mDhtModifications = true; mDhtModifications = true;
/* once we are connected ... don't worry about them anymore */ /* once we are connected ... don't worry about them anymore */
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
it = peers.find(id); it = peers.find(id);
if (it == peers.end()) if (it == peers.end())
{ {
@ -302,14 +302,14 @@ bool p3DhtMgr::dropPeer(std::string id)
} }
/* post DHT key saying we should connect */ /* post DHT key saying we should connect */
bool p3DhtMgr::notifyPeer(std::string id) bool p3DhtMgr::notifyPeer(const RsPeerId& id)
{ {
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/ RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
#ifdef DHT_DEBUG #ifdef DHT_DEBUG
std::cerr << "p3DhtMgr::notifyPeer() " << id << std::endl; std::cerr << "p3DhtMgr::notifyPeer() " << id.toStdString() << std::endl;
#endif #endif
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
it = peers.find(id); it = peers.find(id);
if (it == peers.end()) if (it == peers.end())
{ {
@ -333,7 +333,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
#ifdef DHT_LOGS #ifdef DHT_LOGS
{ {
/* Log */ /* Log */
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " TO SOON - DROPPING"); rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " TO SOON - DROPPING");
} }
#endif #endif
@ -352,7 +352,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
#ifdef DHT_LOGS #ifdef DHT_LOGS
{ {
/* Log */ /* Log */
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " PEER NOT FOUND - Trigger Search"); rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " PEER NOT FOUND - Trigger Search");
} }
#endif #endif
it->second.lastTS = 0; it->second.lastTS = 0;
@ -364,14 +364,14 @@ bool p3DhtMgr::notifyPeer(std::string id)
} }
/* extract current peer status */ /* extract current peer status */
bool p3DhtMgr::getPeerStatus(std::string id, bool p3DhtMgr::getPeerStatus(const RsPeerId &id,
struct sockaddr_in &laddr, struct sockaddr_in &laddr,
struct sockaddr_in &raddr, struct sockaddr_in &raddr,
uint32_t &type, uint32_t &state) uint32_t &type, uint32_t &state)
{ {
RsStackMutex stack(dhtMtx); /* LOCK MUTEX */ RsStackMutex stack(dhtMtx); /* LOCK MUTEX */
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
it = peers.find(id); it = peers.find(id);
/* ignore OFF peers */ /* ignore OFF peers */
@ -776,7 +776,7 @@ int p3DhtMgr::checkPeerDHTKeys()
dhtMtx.lock(); /* LOCK MUTEX */ dhtMtx.lock(); /* LOCK MUTEX */
/* iterate through and find min time and suitable candidate */ /* iterate through and find min time and suitable candidate */
std::map<std::string, dhtPeerEntry>::iterator it,pit; std::map<RsPeerId, dhtPeerEntry>::iterator it,pit;
time_t now = time(NULL); time_t now = time(NULL);
uint32_t period = 0; uint32_t period = 0;
uint32_t repeatPeriod = 6000; uint32_t repeatPeriod = 6000;
@ -802,7 +802,7 @@ int p3DhtMgr::checkPeerDHTKeys()
period = DHT_CHECK_PERIOD; period = DHT_CHECK_PERIOD;
} }
#ifdef DHT_DEBUG #ifdef DHT_DEBUG
std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id; std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id.toStdString();
std::cerr << " Period: " << period; std::cerr << " Period: " << period;
std::cerr << " Delta: " << delta; std::cerr << " Delta: " << delta;
std::cerr << std::endl; std::cerr << std::endl;
@ -865,7 +865,7 @@ int p3DhtMgr::checkNotifyDHT()
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/ RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
/* iterate through and find min time and suitable candidate */ /* iterate through and find min time and suitable candidate */
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
time_t now = time(NULL); time_t now = time(NULL);
int repeatPeriod = DHT_DEFAULT_PERIOD; int repeatPeriod = DHT_DEFAULT_PERIOD;
@ -1015,7 +1015,7 @@ int p3DhtMgr::checkStunState()
if (mDhtState == DHT_STATE_CHECK_PEERS) if (mDhtState == DHT_STATE_CHECK_PEERS)
{ {
/* check that they have all be searched for */ /* check that they have all be searched for */
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
for(it = peers.begin(); it != peers.end(); it++) for(it = peers.begin(); it != peers.end(); it++)
{ {
if (it->second.state == DHT_PEER_INIT) if (it->second.state == DHT_PEER_INIT)
@ -1287,7 +1287,7 @@ int p3DhtMgr::status(std::ostream &out)
out << "OWN DETAILS END----------------------------------------" << std::endl; out << "OWN DETAILS END----------------------------------------" << std::endl;
/* now peers states */ /* now peers states */
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
out << "PEER DETAILS ------------------------------------------" << std::endl; out << "PEER DETAILS ------------------------------------------" << std::endl;
for(it = peers.begin(); it != peers.end(); it++) for(it = peers.begin(); it != peers.end(); it++)
{ {
@ -1622,15 +1622,13 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash)
std::cerr << "p3DhtMgr::dhtResultNotify() from idhash: "; std::cerr << "p3DhtMgr::dhtResultNotify() from idhash: ";
std::cerr << RsUtil::BinToHex(idhash) << std::endl; std::cerr << RsUtil::BinToHex(idhash) << std::endl;
#endif #endif
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
time_t now = time(NULL); time_t now = time(NULL);
/* if notify - we must match on the second hash */ /* if notify - we must match on the second hash */
for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ; for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ;
/* update data */ /* update data */
std::string peerid;
/* ignore OFF peers */ /* ignore OFF peers */
if ((it != peers.end()) && (it->second.state != DHT_PEER_OFF)) if ((it != peers.end()) && (it->second.state != DHT_PEER_OFF))
{ {
@ -1677,7 +1675,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
std::cerr << "p3DhtMgr::dhtResultSearch() for idhash: "; std::cerr << "p3DhtMgr::dhtResultSearch() for idhash: ";
std::cerr << RsUtil::BinToHex(idhash) << std::endl; std::cerr << RsUtil::BinToHex(idhash) << std::endl;
#endif #endif
std::map<std::string, dhtPeerEntry>::iterator it; std::map<RsPeerId, dhtPeerEntry>::iterator it;
bool doCb = false; bool doCb = false;
bool doStun = false; bool doStun = false;
uint32_t stunFlags = 0; uint32_t stunFlags = 0;
@ -1780,7 +1778,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out) void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out)
{ {
out << "DhtEntry: ID: " << ent->id; out << "DhtEntry: ID: " << ent->id.toStdString();
out << " State: " << ent->state; out << " State: " << ent->state;
out << " lastTS: " << ent->lastTS; out << " lastTS: " << ent->lastTS;
out << " notifyPending: " << ent->notifyPending; out << " notifyPending: " << ent->notifyPending;

View File

@ -78,7 +78,7 @@ class dhtPeerEntry
public: public:
dhtPeerEntry(); dhtPeerEntry();
std::string id; RsPeerId id;
uint32_t state; uint32_t state;
time_t lastTS; time_t lastTS;
@ -97,7 +97,7 @@ class p3DhtMgr: public pqiNetAssistConnect, public RsThread
/* /*
*/ */
public: public:
p3DhtMgr(std::string id, pqiConnectCb *cb); p3DhtMgr(RsPeerId id, pqiConnectCb *cb);
/********** External DHT Interface ************************ /********** External DHT Interface ************************
* These Functions are the external interface * These Functions are the external interface
@ -121,14 +121,14 @@ virtual bool setExternalInterface(struct sockaddr_in laddr,
struct sockaddr_in raddr, uint32_t type); struct sockaddr_in raddr, uint32_t type);
/* add / remove peers */ /* add / remove peers */
virtual bool findPeer(std::string id); virtual bool findPeer(const RsPeerId& id);
virtual bool dropPeer(std::string id); virtual bool dropPeer(const RsPeerId& id);
/* post DHT key saying we should connect (callback when done) */ /* post DHT key saying we should connect (callback when done) */
virtual bool notifyPeer(std::string id); virtual bool notifyPeer(const RsPeerId& id);
/* extract current peer status */ /* extract current peer status */
virtual bool getPeerStatus(std::string id, virtual bool getPeerStatus(const RsPeerId& id,
struct sockaddr_in &laddr, struct sockaddr_in &raddr, struct sockaddr_in &laddr, struct sockaddr_in &raddr,
uint32_t &type, uint32_t &mode); uint32_t &type, uint32_t &mode);
@ -154,17 +154,17 @@ virtual bool dhtResultBootstrap(std::string idhash);
protected: protected:
/* can block briefly (called only from thread) */ /* can block briefly (called only from thread) */
virtual bool dhtPublish(std::string id, virtual bool dhtPublish(std::string idhash,
struct sockaddr_in &laddr, struct sockaddr_in &laddr,
struct sockaddr_in &raddr, struct sockaddr_in &raddr,
uint32_t type, std::string sign); uint32_t type, std::string sign);
virtual bool dhtNotify(std::string peerid, std::string ownId, virtual bool dhtNotify(std::string idhash, std::string ownIdHash,
std::string sign); std::string sign);
virtual bool dhtSearch(std::string id, uint32_t mode); virtual bool dhtSearch(std::string idhash, uint32_t mode);
virtual bool dhtBootstrap(std::string storehash, std::string ownIdHash, virtual bool dhtBootstrap(std::string idhash, std::string ownIdHash,
std::string sign); /* to publish bootstrap */ std::string sign); /* to publish bootstrap */
@ -232,7 +232,7 @@ std::string randomBootstrapId();
dhtPeerEntry ownEntry; dhtPeerEntry ownEntry;
time_t ownNotifyTS; time_t ownNotifyTS;
std::map<std::string, dhtPeerEntry> peers; std::map<RsPeerId, dhtPeerEntry> peers;
std::list<std::string> stunIds; std::list<std::string> stunIds;
bool mStunRequired; bool mStunRequired;