diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index adea14205..c8295f80b 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -1021,32 +1021,32 @@ void RsGxsNetService::locked_resetClientTS(const RsGxsGroupId& grpId) it->second.msgUpdateInfos.erase(grpId) ; } -void RsGxsNetService::subscribeStatusChanged(const RsGxsGroupId& grpId,bool subscribed) +void RsGxsNetService::subscribeStatusChanged( + const RsGxsGroupId& grpId, bool subscribed ) { - RS_STACK_MUTEX(mNxsMutex) ; - - if(!subscribed) - return ; + if(!subscribed) return; // When we subscribe, we reset the time stamps, so that the entire group list // gets requested once again, for a proper update. + RS_STACK_MUTEX(mNxsMutex); + #ifdef NXS_NET_DEBUG_0 - GXSNETDEBUG__G(grpId) << "Changing subscribe status for grp " << grpId << " to " << subscribed << ": reseting all server msg time stamps for this group, and server global TS." << std::endl; - std::map::iterator it = mServerMsgUpdateMap.find(grpId) ; + RS_DBG( "Changing subscribe status for grp", grpId, " to ", subscribed, + ": reseting all server msg time stamps for this group, and " + "server global TS." ); #endif - RsGxsServerMsgUpdate& item(mServerMsgUpdateMap[grpId]) ; + RsGxsServerMsgUpdate& item(mServerMsgUpdateMap[grpId]); + item.msgUpdateTS = static_cast(time(nullptr)); - item.msgUpdateTS = time(NULL) ; + /* We also update mGrpServerUpdateItem so as to trigger a new grp list + * exchange with friends (friends will send their known ClientTS which + * will be lower than our own grpUpdateTS, triggering our sending of the + * new subscribed grp list. */ + mGrpServerUpdate.grpUpdateTS = static_cast(time(nullptr)); - // We also update mGrpServerUpdateItem so as to trigger a new grp list exchange with friends (friends will send their known ClientTS which - // will be lower than our own grpUpdateTS, triggering our sending of the new subscribed grp list. - - mGrpServerUpdate.grpUpdateTS = time(NULL) ; - - if(subscribed) - locked_resetClientTS(grpId) ; + locked_resetClientTS(grpId); } bool RsGxsNetService::fragmentMsg(RsNxsMsg& msg, MsgFragments& msgFragments) const diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 6cb3ae5c6..c930046a9 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -900,10 +900,19 @@ bool p3GxsForums::markRead(const RsGxsGrpMsgIdPair& msgId, bool read) bool p3GxsForums::subscribeToForum(const RsGxsGroupId& groupId, bool subscribe ) { uint32_t token; - if( !RsGenExchange::subscribeToGroup(token, groupId, subscribe) || waitToken(token) != RsTokenService::COMPLETE ) return false; + if( !RsGenExchange::subscribeToGroup(token, groupId, subscribe) || + waitToken(token) != RsTokenService::COMPLETE ) return false; - RsGxsGroupId grp; - acknowledgeGrp(token,grp); + RsGxsGroupId grp; + 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. + * 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(); return true; }