mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed serialisation bug in new UpdateMap code, and removed debug info from RsGxsNetService
This commit is contained in:
parent
0d94b683dd
commit
dd2a3c26de
@ -128,11 +128,10 @@ bool RsGenExchange::getGroupServerUpdateTS(const RsGxsGroupId& gid, time_t& grp_
|
||||
|
||||
void RsGenExchange::data_tick()
|
||||
{
|
||||
static const double timeDelta = 0.1; // slow tick in sec
|
||||
|
||||
static const double timeDelta = 0.1; // slow tick in sec
|
||||
|
||||
tick();
|
||||
usleep((int) (timeDelta * 1000 *1000)); // timeDelta sec
|
||||
tick();
|
||||
usleep((int) (timeDelta * 1000 *1000)); // timeDelta sec
|
||||
}
|
||||
|
||||
void RsGenExchange::tick()
|
||||
@ -2723,13 +2722,17 @@ void RsGenExchange::processRecvdMessages()
|
||||
|
||||
msg->metaData = meta;
|
||||
|
||||
uint32_t max_sync_age = ( mNetService != NULL)?( mNetService->getSyncAge(msg->metaData->mGroupId)):RS_GXS_DEFAULT_MSG_REQ_PERIOD;
|
||||
|
||||
if(max_sync_age != 0 && msg->metaData->mPublishTs + max_sync_age < time(NULL))
|
||||
{
|
||||
std::cerr << "(WW) not validating message " << msg->metaData->mMsgId << " in group " << msg->metaData->mGroupId << " because it is older than synchronisation limit. This message was probably sent by a friend node that does not accept sync limits already." << std::endl;
|
||||
ok = false ;
|
||||
}
|
||||
// (cyril) Normally we should discard posts that are older than the sync request. But that causes a problem because
|
||||
// RsGxsNetService requests posts to sync by chunks of 20. So if the 20 are discarded, they will be re-synced next time, and the sync process
|
||||
// will indefinitly loop on the same 20 posts. Since the posts are there already, keeping them is the least problematique way to fix this problem.
|
||||
//
|
||||
// uint32_t max_sync_age = ( mNetService != NULL)?( mNetService->getSyncAge(msg->metaData->mGroupId)):RS_GXS_DEFAULT_MSG_REQ_PERIOD;
|
||||
//
|
||||
// if(max_sync_age != 0 && msg->metaData->mPublishTs + max_sync_age < time(NULL))
|
||||
// {
|
||||
// std::cerr << "(WW) not validating message " << msg->metaData->mMsgId << " in group " << msg->metaData->mGroupId << " because it is older than synchronisation limit. This message was probably sent by a friend node that does not accept sync limits already." << std::endl;
|
||||
// ok = false ;
|
||||
// }
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " deserialised info: grp id=" << meta->mGroupId << ", msg id=" << meta->mMsgId ;
|
||||
|
@ -224,13 +224,13 @@
|
||||
NXS_NET_DEBUG_7 encryption/decryption of transactions
|
||||
|
||||
***/
|
||||
#define NXS_NET_DEBUG_0 1
|
||||
//#define NXS_NET_DEBUG_0 1
|
||||
//#define NXS_NET_DEBUG_1 1
|
||||
//#define NXS_NET_DEBUG_2 1
|
||||
//#define NXS_NET_DEBUG_3 1
|
||||
//#define NXS_NET_DEBUG_4 1
|
||||
#define NXS_NET_DEBUG_5 1
|
||||
#define NXS_NET_DEBUG_6 1
|
||||
//#define NXS_NET_DEBUG_5 1
|
||||
//#define NXS_NET_DEBUG_6 1
|
||||
//#define NXS_NET_DEBUG_7 1
|
||||
|
||||
//#define NXS_FRAG
|
||||
@ -266,8 +266,7 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
|
||||
|| defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7)
|
||||
|
||||
static const RsPeerId peer_to_print = RsPeerId(std::string("")) ;
|
||||
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("cb98f4013f7b4ed4245e54ca7095925b")) ; // use this to allow to this group id only, or "" for all IDs
|
||||
//static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs
|
||||
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs
|
||||
static const uint32_t service_to_print = 0x215 ; // use this to allow to this service id only, or 0 for all services
|
||||
// warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums)
|
||||
|
||||
@ -1460,7 +1459,7 @@ void RsGxsNetService::locked_checkDelay(uint32_t& time_in_secs)
|
||||
template <typename UpdateMap,class ItemClass>
|
||||
struct get_second : public std::unary_function<typename UpdateMap::value_type, RsItem*>
|
||||
{
|
||||
get_second(uint16_t serv_type): mServType(serv_type) {}
|
||||
get_second(uint16_t serv_type,typename UpdateMap::key_type ItemClass::*member): mServType(serv_type),ID_member(member) {}
|
||||
|
||||
RsItem* operator()(const typename UpdateMap::value_type& value) const
|
||||
{
|
||||
@ -1473,42 +1472,17 @@ struct get_second : public std::unary_function<typename UpdateMap::value_type, R
|
||||
typename UpdateMap::key_type ItemClass::*ID_member ;
|
||||
};
|
||||
|
||||
// void clean_copy_value_into_item(ID_class id, UpdateMap& thismap,typename UpdateMap::iterator& iter, ID_class& dest)
|
||||
// {
|
||||
// if(id.isNull())
|
||||
// {
|
||||
// std::cerr << "(EE) had to remove NULL value from ..." << std::endl;
|
||||
//
|
||||
// typename UpdateMap::iterator tmp(iter) ;
|
||||
// ++tmp ;
|
||||
// thismap.erase(iter) ;
|
||||
// iter = tmp ;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dest = id ;
|
||||
// ++iter;
|
||||
// }
|
||||
// }
|
||||
|
||||
bool RsGxsNetService::saveList(bool& cleanup, std::list<RsItem*>& save)
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
||||
// // First, make sure that all IDs (which are needed twice) are consistent
|
||||
//
|
||||
// for(GrpConfigMap::iterator it(mServerGrpConfigMap.begin());it!=mServerGrpConfigMap.end();) clean_copy_value_into_item(it->first,mServerGrpConfigMap,it,it->second.grpId);
|
||||
// for(ServerMsgMap::iterator it(mServerMsgUpdateMap.begin());it!=mServerMsgUpdateMap.end();) clean_copy_value_into_item(it->first,mServerMsgUpdateMap,it,it->second.grpId);
|
||||
// for(ClientGrpMap::iterator it(mClientGrpUpdateMap.begin());it!=mClientGrpUpdateMap.end();) clean_copy_value_into_item(it->first,mClientGrpUpdateMap,it,it->second.peerID);
|
||||
// for(ClientMsgMap::iterator it(mClientMsgUpdateMap.begin());it!=mClientMsgUpdateMap.end();) clean_copy_value_into_item(it->first,mClientMsgUpdateMap,it,it->second.peerID);
|
||||
|
||||
std::cerr << "RsGxsNetService::saveList()..." << std::endl;
|
||||
|
||||
// hardcore templates
|
||||
std::transform(mClientGrpUpdateMap.begin(), mClientGrpUpdateMap.end(), std::back_inserter(save), get_second<ClientGrpMap,RsGxsGrpUpdateItem>(mServType));
|
||||
std::transform(mClientMsgUpdateMap.begin(), mClientMsgUpdateMap.end(), std::back_inserter(save), get_second<ClientMsgMap,RsGxsMsgUpdateItem>(mServType));
|
||||
std::transform(mServerMsgUpdateMap.begin(), mServerMsgUpdateMap.end(), std::back_inserter(save), get_second<ServerMsgMap,RsGxsServerMsgUpdateItem>(mServType));
|
||||
std::transform(mServerGrpConfigMap.begin(), mServerGrpConfigMap.end(), std::back_inserter(save), get_second<GrpConfigMap,RsGxsGrpConfigItem>(mServType));
|
||||
std::transform(mClientGrpUpdateMap.begin(), mClientGrpUpdateMap.end(), std::back_inserter(save), get_second<ClientGrpMap,RsGxsGrpUpdateItem>(mServType,&RsGxsGrpUpdateItem::peerID));
|
||||
std::transform(mClientMsgUpdateMap.begin(), mClientMsgUpdateMap.end(), std::back_inserter(save), get_second<ClientMsgMap,RsGxsMsgUpdateItem>(mServType,&RsGxsMsgUpdateItem::peerID));
|
||||
std::transform(mServerMsgUpdateMap.begin(), mServerMsgUpdateMap.end(), std::back_inserter(save), get_second<ServerMsgMap,RsGxsServerMsgUpdateItem>(mServType,&RsGxsServerMsgUpdateItem::grpId));
|
||||
std::transform(mServerGrpConfigMap.begin(), mServerGrpConfigMap.end(), std::back_inserter(save), get_second<GrpConfigMap,RsGxsGrpConfigItem>(mServType,&RsGxsGrpConfigItem::grpId));
|
||||
|
||||
RsGxsServerGrpUpdateItem *it = new RsGxsServerGrpUpdateItem(mGrpServerUpdate,mServType) ;
|
||||
|
||||
|
@ -221,7 +221,10 @@ public:
|
||||
RsGxsNetServiceItem *gitem = dynamic_cast<RsGxsNetServiceItem *>(item);
|
||||
|
||||
if (!gitem)
|
||||
{
|
||||
std::cerr << "(EE) trying to serialise/size an item that is not a RsGxsNetServiceItem!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return gitem->serial_size() ;
|
||||
}
|
||||
@ -230,7 +233,10 @@ public:
|
||||
RsGxsNetServiceItem *gitem = dynamic_cast<RsGxsNetServiceItem *>(item);
|
||||
|
||||
if (!gitem)
|
||||
{
|
||||
std::cerr << "(EE) trying to serialise an item that is not a RsGxsNetServiceItem!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return gitem->serialise(data,*size) ;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user