diff --git a/libretroshare/src/retroshare/rsdisc.h b/libretroshare/src/retroshare/rsdisc.h index a31764817..2e1420908 100644 --- a/libretroshare/src/retroshare/rsdisc.h +++ b/libretroshare/src/retroshare/rsdisc.h @@ -71,6 +71,15 @@ class RsDisc */ virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0; + /** + * @brief getWaitingDiscCount get the number of queued discovery packets. + * @jsonapi{development} + * @param[out] sendCount number of queued outgoing packets + * @param[out] recvCount number of queued incoming packets + * @return true on success false otherwise + */ + virtual bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount) = 0; + /** * @brief getWaitingDiscCount get the number of queued discovery packets. * @param[out] sendCount number of queued outgoing packets diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index cf4bc28dd..05fa7a982 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -1174,7 +1174,16 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list &proxy } } return true; - + +} + +bool p3discovery2::getWaitingDiscCount(size_t &sendCount, size_t &recvCount) +{ + RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + sendCount = mPendingDiscPgpCertOutList.size(); + recvCount = mPendingDiscPgpCertInList.size(); + + return true; } @@ -1245,14 +1254,15 @@ bool p3discovery2::getWaitingDiscCount(unsigned int *sendCount, unsigned int *re return false; } - RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + size_t send, recv; + getWaitingDiscCount(send, recv); if (sendCount) { - *sendCount = mPendingDiscPgpCertOutList.size(); + *sendCount = send; } if (recvCount) { - *recvCount = mPendingDiscPgpCertInList.size(); + *recvCount = recv; } return true; } diff --git a/libretroshare/src/services/p3discovery2.h b/libretroshare/src/services/p3discovery2.h index a4b127553..a31137f5a 100644 --- a/libretroshare/src/services/p3discovery2.h +++ b/libretroshare/src/services/p3discovery2.h @@ -87,10 +87,11 @@ virtual RsServiceInfo getServiceInfo(); int tick(); /* external interface */ -virtual bool getDiscFriends(const RsPeerId &id, std::list &friends); -virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list &gpg_friends); -virtual bool getPeerVersion(const RsPeerId &id, std::string &version); -virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount); + bool getDiscFriends(const RsPeerId &id, std::list &friends); + bool getDiscPgpFriends(const RsPgpId &pgpid, std::list &gpg_friends); + bool getPeerVersion(const RsPeerId &id, std::string &version); + bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount); + bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount); /************* from AuthGPService ****************/ virtual AuthGPGOperation *getGPGOperation();