diff --git a/libretroshare/src/retroshare/rsgxsifacehelper.h b/libretroshare/src/retroshare/rsgxsifacehelper.h index 60f317de1..99d029361 100644 --- a/libretroshare/src/retroshare/rsgxsifacehelper.h +++ b/libretroshare/src/retroshare/rsgxsifacehelper.h @@ -274,8 +274,7 @@ struct RsGxsIfaceHelper { mTokenService.requestGroupStatistic(token, grpId); } /// @see RsTokenService::cancelRequest - bool cancelRequest(uint32_t token) - { return mTokenService.cancelRequest(token); } + bool cancelRequest(uint32_t token) { return mTokenService.cancelRequest(token); } /** * @deprecated @@ -291,12 +290,21 @@ protected: * @param[in] token token associated to the request caller is waiting for * @param[in] maxWait maximum waiting time in milliseconds * @param[in] checkEvery time in millisecond between status checks + * @param[in] auto_delete_if_unsuccessful delete the request when it fails. This avoid leaving useless pending requests in the queue that would slow down additional calls. */ RsTokenService::GxsRequestStatus waitToken( uint32_t token, std::chrono::milliseconds maxWait = std::chrono::milliseconds(2000), - std::chrono::milliseconds checkEvery = std::chrono::milliseconds(20)) - { return mTokenService.waitToken(token, maxWait, checkEvery); } + std::chrono::milliseconds checkEvery = std::chrono::milliseconds(20), + bool auto_delete_if_unsuccessful=true) + { + RsTokenService::GxsRequestStatus res = mTokenService.waitToken(token, maxWait, checkEvery); + + if(res != RsTokenService::COMPLETE && auto_delete_if_unsuccessful) + cancelRequest(token); + + return res; + } private: RsGxsIface& mGxs; diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 8d5e878c1..7c1892cd1 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -278,8 +278,9 @@ bool p3GxsCircles::getCirclesSummaries(std::list& circles) uint32_t token; RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; - if( !requestGroupInfo(token, opts) - || waitToken(token) != RsTokenService::COMPLETE ) return false; + if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE ) + cancelRequest(token); + return getGroupSummary(token, circles); } @@ -289,8 +290,9 @@ bool p3GxsCircles::getCirclesInfo( const std::list& circlesIds, uint32_t token; RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; - if( !requestGroupInfo(token, opts, circlesIds) - || waitToken(token) != RsTokenService::COMPLETE ) return false; + if( !requestGroupInfo(token, opts, circlesIds) || waitToken(token) != RsTokenService::COMPLETE ) + return false; + return getGroupData(token, circlesInfo); }