From 73d9a483666ac6339bdc0ff191c379ca46c78c68 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 22 Jan 2017 18:36:36 +0100 Subject: [PATCH] update client Grp TS even when friend peer is subscribed to no groups, so as to avoid the friend re-sendign an empty list indefinitly (fix suggested by jo) --- libretroshare/src/gxs/rsgxsnetservice.cc | 41 ++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 5f37dd23f..a41229a2f 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -2973,9 +2973,8 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr) GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << "locked_genReqGrpTransaction(): " << std::endl; #endif - RsGxsMetaDataTemporaryMap grpMetaMap; - std::list grpItemL; + RsGxsMetaDataTemporaryMap grpMetaMap; for(std::list::iterator lit = tr->mItems.begin(); lit != tr->mItems.end(); ++lit) { @@ -2993,7 +2992,23 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr) } if (grpItemL.empty()) - return; + { + // Normally the client grp updateTS is set after the transaction, but if no transaction is to happen, we have to set it here. + // Possible change: always do the update of the grpClientTS here. Needs to be tested... + + RsGxsGrpUpdate& item (mClientGrpUpdateMap[tr->mTransaction->PeerId()]); + +#ifdef NXS_NET_DEBUG_0 + GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << " reqList is empty, updating anyway ClientGrpUpdate TS for peer " << tr->mTransaction->PeerId() << " to: " << tr->mTransaction->updateTS << std::endl; +#endif + + if(item.grpUpdateTS != tr->mTransaction->updateTS) + { + item.grpUpdateTS = tr->mTransaction->updateTS; + IndicateConfigChanged(); + } + return; + } mDataStore->retrieveGxsGrpMetaData(grpMetaMap); @@ -3038,16 +3053,23 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr) if(!reqList.empty()) locked_pushGrpTransactionFromList(reqList, tr->mTransaction->PeerId(), transN); else - { - RsGxsGrpUpdate& item (mClientGrpUpdateMap[tr->mTransaction->PeerId()]); + { + // Normally the client grp updateTS is set after the transaction, but if no transaction is to happen, we have to set it here. + // Possible change: always do the update of the grpClientTS here. Needs to be tested... + + RsGxsGrpUpdate& item (mClientGrpUpdateMap[tr->mTransaction->PeerId()]); #ifdef NXS_NET_DEBUG_0 - GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << " reqList is empty, updating anyway ClientGrpUpdate TS for peer " << tr->mTransaction->PeerId() << " to: " << tr->mTransaction->updateTS << std::endl; + GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << " reqList is empty, updating anyway ClientGrpUpdate TS for peer " << tr->mTransaction->PeerId() << " to: " << tr->mTransaction->updateTS << std::endl; #endif - item.grpUpdateTS = tr->mTransaction->updateTS; - IndicateConfigChanged(); - } + if(item.grpUpdateTS != tr->mTransaction->updateTS) + { + item.grpUpdateTS = tr->mTransaction->updateTS; + IndicateConfigChanged(); + } + } + } void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr) @@ -4793,6 +4815,7 @@ bool RsGxsNetService::removeGroups(const std::list& groups) } IndicateConfigChanged(); + return true ; } bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid)