mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-27 02:11:27 -05:00
fixed small bug causing update of TS to fail in encrypted NxsItems
This commit is contained in:
parent
6a4add8806
commit
41a03eb331
@ -209,6 +209,7 @@
|
|||||||
#include "retroshare/rsgxscircles.h"
|
#include "retroshare/rsgxscircles.h"
|
||||||
#include "pgp/pgpauxutils.h"
|
#include "pgp/pgpauxutils.h"
|
||||||
#include "util/rsmemory.h"
|
#include "util/rsmemory.h"
|
||||||
|
#include "util/stacktrace.h"
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Use the following defines to debug:
|
* Use the following defines to debug:
|
||||||
@ -583,6 +584,23 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class RsGxsMetaDataTemporaryMapVector: public std::vector<T*>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~RsGxsMetaDataTemporaryMapVector()
|
||||||
|
{
|
||||||
|
clear() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void clear()
|
||||||
|
{
|
||||||
|
for(typename RsGxsMetaDataTemporaryMapVector<T>::iterator it = this->begin();it!=this->end();++it)
|
||||||
|
if(it->second != NULL)
|
||||||
|
delete it->second ;
|
||||||
|
std::vector<T*>::clear() ;
|
||||||
|
}
|
||||||
|
};
|
||||||
void RsGxsNetService::syncWithPeers()
|
void RsGxsNetService::syncWithPeers()
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
@ -2012,16 +2030,15 @@ bool RsGxsNetService::locked_checkTransacTimedOut(NxsTransaction* tr)
|
|||||||
|
|
||||||
void RsGxsNetService::processTransactions()
|
void RsGxsNetService::processTransactions()
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG_1
|
|
||||||
if(!mTransactions.empty())
|
|
||||||
GXSNETDEBUG___ << "processTransactions()" << std::endl;
|
|
||||||
#endif
|
|
||||||
RS_STACK_MUTEX(mNxsMutex) ;
|
RS_STACK_MUTEX(mNxsMutex) ;
|
||||||
|
|
||||||
TransactionsPeerMap::iterator mit = mTransactions.begin();
|
for(TransactionsPeerMap::iterator mit = mTransactions.begin();mit != mTransactions.end(); ++mit)
|
||||||
|
|
||||||
for(; mit != mTransactions.end(); ++mit)
|
|
||||||
{
|
{
|
||||||
|
#ifdef NXS_NET_DEBUG_1
|
||||||
|
if(!mit->second.empty())
|
||||||
|
GXSNETDEBUG_P_(mit->first) << "processTransactions from/to peer " << mit->first << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
TransactionIdMap& transMap = mit->second;
|
TransactionIdMap& transMap = mit->second;
|
||||||
TransactionIdMap::iterator mmit = transMap.begin(), mmit_end = transMap.end();
|
TransactionIdMap::iterator mmit = transMap.begin(), mmit_end = transMap.end();
|
||||||
|
|
||||||
@ -2496,6 +2513,13 @@ void RsGxsNetService::locked_doMsgUpdateWork(const RsNxsTransacItem *nxsTrans, c
|
|||||||
const RsPeerId& peerFrom = nxsTrans->PeerId();
|
const RsPeerId& peerFrom = nxsTrans->PeerId();
|
||||||
|
|
||||||
ClientMsgMap::iterator it = mClientMsgUpdateMap.find(peerFrom);
|
ClientMsgMap::iterator it = mClientMsgUpdateMap.find(peerFrom);
|
||||||
|
|
||||||
|
if(peerFrom.isNull())
|
||||||
|
{
|
||||||
|
std::cerr << "(EE) update from null peer!" << std::endl;
|
||||||
|
print_stacktrace() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RsGxsMsgUpdateItem* mui = NULL;
|
RsGxsMsgUpdateItem* mui = NULL;
|
||||||
|
|
||||||
@ -3859,11 +3883,14 @@ bool RsGxsNetService::processTransactionForDecryption(NxsTransaction *tr)
|
|||||||
{
|
{
|
||||||
ditem = RsNxsSerialiser(mServType).deserialise(decrypted_mem,&decrypted_len) ;
|
ditem = RsNxsSerialiser(mServType).deserialise(decrypted_mem,&decrypted_len) ;
|
||||||
|
|
||||||
if(ditem == NULL)
|
if(ditem != NULL)
|
||||||
|
{
|
||||||
|
ditem->PeerId((*it)->PeerId()) ; // This is needed because the deserialised item has no peer id
|
||||||
|
nxsitem = dynamic_cast<RsNxsItem*>(ditem) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
std::cerr << " Cannot deserialise. Item encoding error!" << std::endl;
|
std::cerr << " Cannot deserialise. Item encoding error!" << std::endl;
|
||||||
|
|
||||||
nxsitem = dynamic_cast<RsNxsItem*>(ditem) ;
|
|
||||||
|
|
||||||
if(nxsitem == NULL)
|
if(nxsitem == NULL)
|
||||||
std::cerr << " (EE) Deserialised item is not an NxsItem. Weird. Dropping transaction." << std::endl;
|
std::cerr << " (EE) Deserialised item is not an NxsItem. Weird. Dropping transaction." << std::endl;
|
||||||
}
|
}
|
||||||
@ -4343,12 +4370,12 @@ bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncMsgReqItem *item)
|
|||||||
const RsGxsServerMsgUpdateItem *msui = cit->second;
|
const RsGxsServerMsgUpdateItem *msui = cit->second;
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " local time stamp: " << std::dec<< time(NULL) - msui->msgUpdateTS << " secs ago. Update sent: " << (item->updateTS < msui->msgUpdateTS) ;
|
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " local time stamp: " << std::dec<< time(NULL) - msui->msgUpdateTS << " secs ago. Update sent: " << (item->updateTS < msui->msgUpdateTS) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return item->updateTS < msui->msgUpdateTS ;
|
return item->updateTS < msui->msgUpdateTS ;
|
||||||
}
|
}
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " no local time stamp for this grp. " ;
|
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " no local time stamp for this grp. "<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -4381,9 +4408,6 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsMsgMetaResult metaResult;
|
|
||||||
GxsMsgReq req;
|
|
||||||
|
|
||||||
RsGxsMetaDataTemporaryMap<RsGxsGrpMetaData> grpMetas;
|
RsGxsMetaDataTemporaryMap<RsGxsGrpMetaData> grpMetas;
|
||||||
grpMetas[item->grpId] = NULL;
|
grpMetas[item->grpId] = NULL;
|
||||||
|
|
||||||
@ -4405,7 +4429,10 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item)
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GxsMsgReq req;
|
||||||
req[item->grpId] = std::vector<RsGxsMessageId>();
|
req[item->grpId] = std::vector<RsGxsMessageId>();
|
||||||
|
|
||||||
|
GxsMsgMetaResult metaResult;
|
||||||
mDataStore->retrieveGxsMsgMetaData(req, metaResult);
|
mDataStore->retrieveGxsMsgMetaData(req, metaResult);
|
||||||
std::vector<RsGxsMsgMetaData*>& msgMetas = metaResult[item->grpId];
|
std::vector<RsGxsMsgMetaData*>& msgMetas = metaResult[item->grpId];
|
||||||
|
|
||||||
@ -4428,10 +4455,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item)
|
|||||||
RsGxsCircleId should_encrypt_to_this_circle_id ;
|
RsGxsCircleId should_encrypt_to_this_circle_id ;
|
||||||
|
|
||||||
if(canSendMsgIds(msgMetas, *grpMeta, peer, should_encrypt_to_this_circle_id))
|
if(canSendMsgIds(msgMetas, *grpMeta, peer, should_encrypt_to_this_circle_id))
|
||||||
{
|
for(std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin();vit != msgMetas.end(); ++vit)
|
||||||
std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin();
|
|
||||||
|
|
||||||
for(; vit != msgMetas.end(); ++vit)
|
|
||||||
{
|
{
|
||||||
RsGxsMsgMetaData* m = *vit;
|
RsGxsMsgMetaData* m = *vit;
|
||||||
|
|
||||||
@ -4457,7 +4481,17 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item)
|
|||||||
delete mItem ;
|
delete mItem ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cerr << " (EE) Cannot encrypt msg meta data. MsgId=" << mItem->msgId << ", grpId=" << mItem->grpId << ", circleId=" << should_encrypt_to_this_circle_id << std::endl;
|
{
|
||||||
|
// Something's not ready (probably the circle content. We could put on a vetting list, but actually the client will re-ask the list asap.
|
||||||
|
|
||||||
|
std::cerr << " (EE) Cannot encrypt msg meta data. MsgId=" << mItem->msgId << ", grpId=" << mItem->grpId << ", circleId=" << should_encrypt_to_this_circle_id << ". Dropping the whole list." << std::endl;
|
||||||
|
|
||||||
|
for(std::list<RsNxsItem*>::const_iterator it(itemL.begin());it!=itemL.end();++it)
|
||||||
|
delete *it ;
|
||||||
|
|
||||||
|
itemL.clear() ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4466,28 +4500,27 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item)
|
|||||||
#endif
|
#endif
|
||||||
itemL.push_back(mItem);
|
itemL.push_back(mItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!itemL.empty())
|
|
||||||
{
|
|
||||||
#ifdef NXS_NET_DEBUG_0
|
|
||||||
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " sending final msg info list of " << itemL.size() << " items." << std::endl;
|
|
||||||
#endif
|
|
||||||
locked_pushMsgRespFromList(itemL, peer, item->grpId,transN);
|
|
||||||
}
|
|
||||||
#ifdef NXS_NET_DEBUG_0
|
|
||||||
else
|
|
||||||
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " list is empty! Not sending anything." << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
else
|
else
|
||||||
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " vetting forbids sending. Nothing will be sent." << itemL.size() << " items." << std::endl;
|
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " vetting forbids sending. Nothing will be sent." << itemL.size() << " items." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin();
|
if(!itemL.empty())
|
||||||
|
{
|
||||||
|
#ifdef NXS_NET_DEBUG_0
|
||||||
|
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " sending final msg info list of " << itemL.size() << " items." << std::endl;
|
||||||
|
#endif
|
||||||
|
locked_pushMsgRespFromList(itemL, peer, item->grpId,transN);
|
||||||
|
}
|
||||||
|
#ifdef NXS_NET_DEBUG_0
|
||||||
|
else
|
||||||
|
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " list is empty! Not sending anything." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// release meta resource
|
// release meta resource
|
||||||
for(vit = msgMetas.begin(); vit != msgMetas.end(); ++vit)
|
for(std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin(); vit != msgMetas.end(); ++vit)
|
||||||
delete *vit;
|
delete *vit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user