diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index c8295f80b..c93d8e1e1 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -35,7 +35,7 @@ // | // +----------- sharePublishKeys() // | -// +----------- pullFromPeers() +// +----------- checkUpdatesFromPeers() // | | // | +--if AutoSync--- send global UpdateTS of each peer to itself => the peer knows the last // | | time current peer has received an updated from himself @@ -127,14 +127,14 @@ // (Set at server side to be mGrpServerUpdateItem->grpUpdateTS) // // Only updated in processCompletedIncomingTransaction() from Grp list transaction. -// Used in pullFromPeers() sending in RsNxsSyncGrp once to all peers: peer will send data if +// Used in checkUpdatesFromPeers() sending in RsNxsSyncGrp once to all peers: peer will send data if // has something new. All time comparisons are in the friends' clock time. // // mClientMsgUpdateMap: map< RsPeerId, map > // // Last msg list modification time sent by that peer Id // Updated in processCompletedIncomingTransaction() from Grp list trans. -// Used in pullFromPeers() sending in RsNxsSyncGrp once to all peers. +// Used in checkUpdatesFromPeers() sending in RsNxsSyncGrp once to all peers. // Set at server to be mServerMsgUpdateMap[grpId]->msgUpdateTS // // mGrpServerUpdateItem: TimeStamp Last group local modification timestamp over all groups @@ -150,7 +150,7 @@ // // tick() tick() // | | -// +---- pullFromPeers +-- recvNxsItemQueue() +// +---- checkUpdatesFromPeers() +-- recvNxsItemQueue() // | | // +---------------- Send global UpdateTS of each peer to itself => the peer knows +---------> +------ handleRecvSyncGroup( RsNxsSyncGrp*) // | the last msg sent (stored in mClientGrpUpdateMap[peer_id]), | | - parse all subscribed groups. For each, send a RsNxsSyncGrpItem with publish TS @@ -457,7 +457,7 @@ int RsGxsNetService::tick() if((elapsed) < now) { - pullFromPeers(); + checkUpdatesFromPeers(); syncGrpStatistics(); checkDistantSyncState(); @@ -570,7 +570,8 @@ RsGxsGroupId RsGxsNetService::hashGrpId(const RsGxsGroupId& gid,const RsPeerId& return RsGxsGroupId( RsDirUtil::sha1sum(tmpmem,SIZE).toByteArray() ); } -void RsGxsNetService::pullFromPeers(std::set peers) +std::error_condition RsGxsNetService::checkUpdatesFromPeers( + std::set peers ) { #ifdef NXS_NET_DEBUG_0 RS_DBG("this=", (void*)this, ". serviceInfo=", mServiceInfo); @@ -594,8 +595,8 @@ void RsGxsNetService::pullFromPeers(std::set peers) } } - // Still empty? Then nothing to do - if (peers.empty()) return; + // Still empty? Reports there are no available peers + if (peers.empty()) return std::errc::network_down; RS_STACK_MUTEX(mNxsMutex); @@ -624,7 +625,7 @@ void RsGxsNetService::pullFromPeers(std::set peers) generic_sendItem(grp); } - if(!mAllowMsgSync) return; + if(!mAllowMsgSync) return std::error_condition(); #ifndef GXS_DISABLE_SYNC_MSGS @@ -742,7 +743,9 @@ void RsGxsNetService::pullFromPeers(std::set peers) } } -#endif +#endif // ndef GXS_DISABLE_SYNC_MSGS + + return std::error_condition(); } void RsGxsNetService::generic_sendItem(rs_owner_ptr si) @@ -5123,7 +5126,7 @@ std::error_condition RsGxsNetService::requestPull(std::set peers) void RsGxsNetService::handlePullRequest( std::unique_ptr item ) { - pullFromPeers(std::set{item->PeerId()}); + checkUpdatesFromPeers(std::set{item->PeerId()}); } bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& group_server_update_TS, rstime_t& msg_server_update_TS) diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 308f9b067..0baee2a2f 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -252,7 +252,8 @@ public: /// @see RsNetworkExchangeService - void pullFromPeers(std::set peers = std::set()) override; + std::error_condition checkUpdatesFromPeers( + std::set peers = std::set() ) override; /// @see RsNetworkExchangeService std::error_condition requestPull( diff --git a/libretroshare/src/gxs/rsnxs.h b/libretroshare/src/gxs/rsnxs.h index 5933d4572..2197d0e7a 100644 --- a/libretroshare/src/gxs/rsnxs.h +++ b/libretroshare/src/gxs/rsnxs.h @@ -327,10 +327,10 @@ public: } /** - * @brief Pull new stuff from peers - * @param peers peers to pull from, if empty all available peers are pulled + * @brief Check if new stuff is available from peers + * @param peers peers to check, if empty all available peers are checked */ - virtual void pullFromPeers( + virtual std::error_condition checkUpdatesFromPeers( std::set peers = std::set() ) = 0; /** diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 81f03b6ec..97d880880 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -907,12 +907,12 @@ bool p3GxsForums::subscribeToForum(const RsGxsGroupId& groupId, bool subscribe ) acknowledgeGrp(token, grp); /* Since subscribe has been requested, the caller is most probably - * interested in getting the group messages ASAP so pull from peers without - * waiting GXS sync timer. + * interested in getting the group messages ASAP so check updates from peers + * without waiting GXS sync timer. * Do it here as this is meaningful or not depending on the service. * Do it only after the token has been completed otherwise the pull have no * effect. */ - if(subscribe) RsGenExchange::netService()->pullFromPeers(); + if(subscribe) RsGenExchange::netService()->checkUpdatesFromPeers(); return true; } @@ -1161,7 +1161,8 @@ std::error_condition p3GxsForums::setPostKeepForever( std::error_condition p3GxsForums::requestSynchronization() { - RsGenExchange::netService()->pullFromPeers(); + auto errc = RsGenExchange::netService()->checkUpdatesFromPeers(); + if(errc) return errc; return RsGenExchange::netService()->requestPull(); }