fixed enabling of distant messages, fixed serialisation bug

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7294 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-04-21 13:08:42 +00:00
parent 4d2907efed
commit 9beb33f172
3 changed files with 17 additions and 25 deletions

View File

@ -259,6 +259,7 @@ RsGRouterRoutingInfoItem *RsGRouterSerialiser::deserialise_RsGRouterRoutingInfoI
ok &= getRawUInt32(data, pktsize, &offset, &item->status_flags);
ok &= item->origin.deserialise(data, pktsize, offset) ;
ok &= getRawTimeT(data, pktsize, &offset, item->received_time);
ok &= getRawTimeT(data, pktsize, &offset, item->last_sent);
ok &= getRawUInt32(data, pktsize, &offset, &item->client_id);
uint32_t s = 0 ;
@ -282,6 +283,8 @@ RsGRouterRoutingInfoItem *RsGRouterSerialiser::deserialise_RsGRouterRoutingInfoI
else
ok = false ;
item->destination_key = item->data_item->destination_key ;
if (offset != rssize || !ok)
{
std::cerr << __PRETTY_FUNCTION__ << ": error while deserialising! Item will be dropped." << std::endl;
@ -457,6 +460,7 @@ uint32_t RsGRouterRoutingInfoItem::serial_size() const
s += 4 ; // status_flags
s += origin.serial_size() ; // origin
s += 8 ; // received_time
s += 8 ; // last_sent
s += 4 ; // tried_friends.size() ;
s += sizeof(GRouterServiceId) ; // service_id
s += tried_friends.size() * ( RsPeerId::SIZE_IN_BYTES + 8 + 4 + 4 ) ; // FriendTrialRecord
@ -544,6 +548,7 @@ bool RsGRouterRoutingInfoItem::serialise(void *data,uint32_t& size) const
ok &= setRawUInt32(data, tlvsize, &offset, status_flags) ;
ok &= origin.serialise(data, tlvsize, offset) ;
ok &= setRawTimeT(data, tlvsize, &offset, received_time) ;
ok &= setRawTimeT(data, tlvsize, &offset, last_sent) ;
ok &= setRawUInt32(data, tlvsize, &offset, client_id) ;
ok &= setRawUInt32(data, tlvsize, &offset, tried_friends.size()) ;
@ -606,6 +611,7 @@ std::ostream& RsGRouterRoutingInfoItem::print(std::ostream& o, uint16_t)
o << " direct origin: \""<< PeerId() << "\"" << std::endl ;
o << " origin: "<< origin.toStdString() << std::endl ;
o << " recv time: "<< received_time << std::endl ;
o << " Last sent: "<< last_sent << std::endl ;
o << " flags: "<< std::hex << status_flags << std::dec << std::endl ;
o << " Key: "<< data_item->destination_key.toStdString() << std::endl ;
o << " Data size: "<< data_item->data_size << std::endl ;

View File

@ -38,7 +38,7 @@ const uint8_t RS_PKT_SUBTYPE_GROUTER_DATA = 0x05 ; // used to send da
const uint8_t RS_PKT_SUBTYPE_GROUTER_MATRIX_CLUES = 0x80 ; // item to save matrix clues
const uint8_t RS_PKT_SUBTYPE_GROUTER_FRIENDS_LIST = 0x82 ; // item to save friend lists
const uint8_t RS_PKT_SUBTYPE_GROUTER_ROUTING_INFO = 0x86 ; // item to save routing info
const uint8_t RS_PKT_SUBTYPE_GROUTER_ROUTING_INFO = 0x87 ; // item to save routing info
const uint8_t QOS_PRIORITY_RS_GROUTER_PUBLISH_KEY = 3 ; // slow items. No need to congest the network with this.
const uint8_t QOS_PRIORITY_RS_GROUTER_ACK = 3 ;

View File

@ -364,7 +364,6 @@ int p3MsgService::checkOutgoingMessages()
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
"p3MsgService::checkOutGoingMessages() Sending out message");
/* remove the pending flag */
(mit->second)->msgFlags &= ~RS_MSG_FLAGS_PENDING;
output_queue.push_back(mit->second) ;
@ -372,11 +371,17 @@ int p3MsgService::checkOutgoingMessages()
//
if(!(mit->second->msgFlags & RS_MSG_FLAGS_DISTANT))
{
(mit->second)->msgFlags &= ~RS_MSG_FLAGS_PENDING;
toErase.push_back(mit->first);
changed = true ;
}
else
{
#ifdef DEBUG_DISTANT_MSG
std::cerr << "Message id " << mit->first << " is distant: kept in outgoing, and marked as ROUTED" << std::endl;
#endif
mit->second->msgFlags |= RS_MSG_FLAGS_ROUTED ;
}
}
else
{
@ -590,7 +595,7 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
}
}
if(!distant_messaging_set)
if(mDistantMessagingEnabled || !distant_messaging_set)
{
#ifdef DEBUG_DISTANT_MSG
std::cerr << "No config value for distant messaging. Setting it to true." << std::endl;
@ -2106,26 +2111,7 @@ void p3MsgService::manageDistantPeers()
#ifdef DEBUG_DISTANT_MSG
std::cerr << "p3MsgService::manageDistantPeers()" << std::endl;
#endif
time_t now = time(NULL) ;
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
// // clean dead contacts.
// //
// for(std::map<Sha1CheckSum,DistantMessengingContact>::iterator it(_messenging_contacts.begin());it!=_messenging_contacts.end();)
// if((!it->second.pending_messages) && it->second.status == RS_DISTANT_MSG_STATUS_TUNNEL_DN)
// {
//#ifdef DEBUG_DISTANT_MSG
// std::cerr << " Removing dead contact with no pending msgs and dead tunnel. hash=" << it->first << std::endl;
//#endif
// std::map<Sha1CheckSum,DistantMessengingContact>::iterator tmp(it) ;
// ++tmp ;
// _messenging_contacts.erase(it) ;
// it = tmp ;
// }
// else
// ++it ;
}
enableDistantMessaging(mDistantMessagingEnabled) ;
}
void p3MsgService::sendGRouterData(const GRouterKeyId& key_id,RsMsgItem *msgitem)
@ -2152,7 +2138,7 @@ void p3MsgService::sendGRouterData(const GRouterKeyId& key_id,RsMsgItem *msgitem
GRouterMsgPropagationId grouter_message_id ;
mGRouter->sendData(key_id,item,grouter_message_id) ;
mGRouter->sendData(key_id,GROUTER_CLIENT_ID_MESSAGES,item,grouter_message_id) ;
// now store the grouter id along with the message id, so that we can keep track of received messages
@ -2187,7 +2173,7 @@ void p3MsgService::acknowledgeDataReceived(const GRouterMsgPropagationId& id)
delete it2->second ;
msgOutgoing.erase(it2) ;
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
IndicateConfigChanged() ;
}
void p3MsgService::receiveGRouterData(const GRouterKeyId& key, const RsGRouterGenericDataItem *gitem)