Merge pull request #1099 from csoler/v0.6-PRTest

V0.6 pr test
This commit is contained in:
csoler 2017-11-05 17:00:26 +01:00 committed by GitHub
commit aeb7b3302f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 41 additions and 32 deletions

View File

@ -59,7 +59,7 @@ const uint8_t QOS_PRIORITY_RS_GROUTER = 4 ; // relevant for items that travel
class RsGRouterItem: public RsItem
{
public:
RsGRouterItem(uint8_t grouter_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GROUTER,grouter_subtype) {}
explicit RsGRouterItem(uint8_t grouter_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GROUTER,grouter_subtype) {}
virtual ~RsGRouterItem() {}
@ -90,7 +90,7 @@ class RsGRouterNonCopyableObject
class RsGRouterAbstractMsgItem: public RsGRouterItem
{
public:
RsGRouterAbstractMsgItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {}
explicit RsGRouterAbstractMsgItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype), flags(0) {}
virtual ~RsGRouterAbstractMsgItem() {}
GRouterMsgPropagationId routing_id ;
@ -103,7 +103,7 @@ public:
class RsGRouterGenericDataItem: public RsGRouterAbstractMsgItem, public RsGRouterNonCopyableObject
{
public:
RsGRouterGenericDataItem() : RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_DATA) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
RsGRouterGenericDataItem() : RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_DATA), data_size(0), data_bytes(NULL), duplication_factor(0) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
virtual ~RsGRouterGenericDataItem() { clear() ; }
virtual void clear()
@ -144,7 +144,7 @@ class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem
class RsGRouterTransactionItem: public RsGRouterItem
{
public:
RsGRouterTransactionItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {}
explicit RsGRouterTransactionItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {}
virtual ~RsGRouterTransactionItem() {}
@ -156,7 +156,7 @@ class RsGRouterTransactionItem: public RsGRouterItem
class RsGRouterTransactionChunkItem: public RsGRouterTransactionItem, public RsGRouterNonCopyableObject
{
public:
RsGRouterTransactionChunkItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_CHUNK) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
RsGRouterTransactionChunkItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_CHUNK), chunk_start(0), chunk_size(0), total_size(0), chunk_data(NULL) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
virtual ~RsGRouterTransactionChunkItem() { free(chunk_data) ; }
@ -217,7 +217,7 @@ class RsGRouterMatrixCluesItem: public RsGRouterItem
class RsGRouterMatrixTrackItem: public RsGRouterItem
{
public:
RsGRouterMatrixTrackItem() : RsGRouterItem(RS_PKT_SUBTYPE_GROUTER_MATRIX_TRACK)
RsGRouterMatrixTrackItem() : RsGRouterItem(RS_PKT_SUBTYPE_GROUTER_MATRIX_TRACK), time_stamp(0)
{ setPriorityLevel(0) ; } // this item is never sent through the network
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
@ -271,7 +271,7 @@ class RsGRouterRoutingInfoItem: public RsGRouterItem, public GRouterRoutingInfo,
class RsGRouterSerialiser: public RsServiceSerializer
{
public:
RsGRouterSerialiser(SerializationFlags flags = SERIALIZATION_FLAG_NONE) : RsServiceSerializer(RS_SERVICE_TYPE_GROUTER,RsGenericSerializer::FORMAT_BINARY,flags) {}
explicit RsGRouterSerialiser(SerializationFlags flags = SERIALIZATION_FLAG_NONE) : RsServiceSerializer(RS_SERVICE_TYPE_GROUTER,RsGenericSerializer::FORMAT_BINARY,flags) {}
virtual RsItem *create_item(uint16_t service,uint8_t subtype) const ;
};

View File

@ -97,11 +97,17 @@ class GRouterRoutingInfo
// ovoids lots of duplications if the class is copied.
public:
GRouterRoutingInfo()
{
data_transaction_TS = 0 ; // this is not serialised.
data_item = NULL ;
receipt_item = NULL ;
}
: data_status(0)
, tunnel_status(0)
, received_time_TS(0)
, last_sent_TS(0)
, last_tunnel_request_TS(0)
, sending_attempts(0)
, routing_flags(0)
, data_item(NULL)
, receipt_item(NULL)
, data_transaction_TS(0) // this is not serialised.
{}
uint32_t data_status ; // pending, waiting, etc.
uint32_t tunnel_status ; // status of tunnel handling.

View File

@ -204,7 +204,7 @@
const std::string p3GRouter::SERVICE_INFO_APP_NAME = "Global Router" ;
p3GRouter::p3GRouter(p3ServiceControl *sc, RsGixs *is)
: p3Service(), p3Config(), mServiceControl(sc), mGixs(is), grMtx("GRouter")
: p3Service(), p3Config(), mServiceControl(sc), mTurtle(NULL), mGixs(is), grMtx("GRouter")
{
addSerialType(new RsGRouterSerialiser()) ;
@ -2292,6 +2292,8 @@ bool p3GRouter::saveList(bool& cleanup,std::list<RsItem*>& items)
{
RsGRouterRoutingInfoItem *item = new RsGRouterRoutingInfoItem ;
#warning: Cppcheck(cstyleCast): C-style pointer casting
// cppcheck-suppress cstyleCast
*(GRouterRoutingInfo*)item = it->second ; // copy all members
item->data_item = it->second.data_item->duplicate() ; // deep copy, because we call delete on the object, and the item might be removed before we handle it in the client.

View File

@ -79,7 +79,7 @@ class GRouterDataInfo
{
// ! This class does not have a copy constructor that duplicates the incoming data buffer. This is on purpose!
public:
GRouterDataInfo()
GRouterDataInfo() : last_activity_TS(0)
{
incoming_data_buffer = NULL ;
}
@ -339,7 +339,7 @@ private:
p3ServiceControl *mServiceControl ;
p3turtle *mTurtle ;
RsGixs *mGixs ;
p3LinkMgr *mLinkMgr ;
//p3LinkMgr *mLinkMgr ;
// Multi-thread protection mutex.
//

View File

@ -48,7 +48,7 @@ struct GxsTokenQueueItem
class GxsTokenQueue
{
public:
GxsTokenQueue(RsGenExchange *gxs) :
explicit GxsTokenQueue(RsGenExchange *gxs) :
mGenExchange(gxs), mQueueMtx("GxsTokenQueueMtx") {}
bool queueRequest(uint32_t token, uint32_t req_type);

View File

@ -82,6 +82,7 @@ RsGenExchange::RsGenExchange(RsGeneralDataService *gds, RsNetworkExchangeService
mLastClean((int)time(NULL) - (int)(RSRandom::random_u32() % MSG_CLEANUP_PERIOD)), // this helps unsynchronising the checks for the different services
mMsgCleanUp(NULL),
mChecking(false),
mCheckStarted(false),
mLastCheck((int)time(NULL) - (int)(RSRandom::random_u32() % INTEGRITY_CHECK_PERIOD) + 120), // this helps unsynchronising the checks for the different services, with 2 min security to avoid checking right away before statistics come up.
mIntegrityCheck(NULL),
SIGN_MAX_WAITING_TIME(60),
@ -1234,7 +1235,7 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token,
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::getMsgMeta(): retrieving meta data for token " << token << std::endl;
#endif
std::list<RsGxsMsgMetaData*> metaL;
//std::list<RsGxsMsgMetaData*> metaL;
GxsMsgMetaResult result;
bool ok = mDataAccess->getMsgSummary(token, result);
@ -2168,15 +2169,13 @@ void RsGenExchange::publishMsgs()
uint32_t size = mSerialiser->size(msgItem);
char* mData = new char[size];
bool serialOk = false;
// for fatal sign creation
bool createOk = false;
// if sign requests to try later
bool tryLater = false;
serialOk = mSerialiser->serialise(msgItem, mData, &size);
bool serialOk = mSerialiser->serialise(msgItem, mData, &size);
if(serialOk)
{
@ -2266,6 +2265,8 @@ void RsGenExchange::publishMsgs()
char* metaDataBuff = new char[size];
bool s = msg->metaData->serialise(metaDataBuff, &size);
s &= msg->meta.setBinData(metaDataBuff, size);
if (!s)
std::cerr << "(WW) Can't serialise or set bin data" << std::endl;
msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED;
msgId = msg->msgId;

View File

@ -176,7 +176,7 @@ public:
class GixsReputation
{
public:
GixsReputation() {}
GixsReputation() :reputation_level(0) {}
RsGxsId id;
uint32_t reputation_level ;

View File

@ -37,7 +37,7 @@ typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter;
class RsGxsDataAccess : public RsTokenService
{
public:
RsGxsDataAccess(RsGeneralDataService* ds);
explicit RsGxsDataAccess(RsGeneralDataService* ds);
virtual ~RsGxsDataAccess() ;
public:

View File

@ -293,7 +293,7 @@ private:
enum CheckState { CheckStart, CheckChecking };
public:
GxsTransIntegrityCleanupThread(RsGeneralDataService *const dataService): mDs(dataService),mMtx("GxsTransIntegrityCheck") { mDone=false;}
explicit GxsTransIntegrityCleanupThread(RsGeneralDataService *const dataService): mDs(dataService),mMtx("GxsTransIntegrityCheck") { mDone=false;}
bool isDone();
void run();

View File

@ -39,7 +39,7 @@ public:
class RsGxsTransBaseMsgItem : public RsGxsMsgItem
{
public:
RsGxsTransBaseMsgItem(GxsTransItemsSubtypes subtype) :
explicit RsGxsTransBaseMsgItem(GxsTransItemsSubtypes subtype) :
RsGxsMsgItem( RS_SERVICE_TYPE_GXS_TRANS,
static_cast<uint8_t>(subtype) ), mailId(0) {}

View File

@ -124,7 +124,7 @@ static const uint32_t GXS_TUNNEL_AES_KEY_SIZE = 16 ;
class p3GxsTunnelService: public RsGxsTunnelService, public RsTurtleClientService, public p3Service
{
public:
p3GxsTunnelService(RsGixs *pids) ;
explicit p3GxsTunnelService(RsGixs *pids) ;
virtual void connectToTurtleRouter(p3turtle *) ;
// Creates the invite if the public key of the distant peer is available.

View File

@ -53,7 +53,7 @@ typedef uint64_t GxsTunnelDHSessionId ;
class RsGxsTunnelItem: public RsItem
{
public:
RsGxsTunnelItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GXS_TUNNEL,item_subtype)
explicit RsGxsTunnelItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GXS_TUNNEL,item_subtype)
{
setPriorityLevel(QOS_PRIORITY_RS_CHAT_ITEM) ;
}
@ -72,8 +72,8 @@ class RsGxsTunnelItem: public RsItem
class RsGxsTunnelDataItem: public RsGxsTunnelItem
{
public:
RsGxsTunnelDataItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA) { data=NULL ;data_size=0;service_id=0;unique_item_counter=0; }
RsGxsTunnelDataItem(uint8_t subtype) :RsGxsTunnelItem(subtype) { data=NULL ;data_size=0; }
RsGxsTunnelDataItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA), unique_item_counter(0), flags(0), service_id(0), data_size(0), data(NULL) {}
explicit RsGxsTunnelDataItem(uint8_t subtype) :RsGxsTunnelItem(subtype) , unique_item_counter(0), flags(0), service_id(0), data_size(0), data(NULL) {}
virtual ~RsGxsTunnelDataItem() {}
virtual void clear() {}
@ -108,7 +108,7 @@ class RsGxsTunnelStatusItem: public RsGxsTunnelItem
class RsGxsTunnelDataAckItem: public RsGxsTunnelItem
{
public:
RsGxsTunnelDataAckItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA_ACK) {}
RsGxsTunnelDataAckItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA_ACK), unique_item_counter(0) {}
RsGxsTunnelDataAckItem(void *data,uint32_t size) ; // deserialization
virtual ~RsGxsTunnelDataAckItem() {}
@ -125,7 +125,7 @@ class RsGxsTunnelDataAckItem: public RsGxsTunnelItem
class RsGxsTunnelDHPublicKeyItem: public RsGxsTunnelItem
{
public:
RsGxsTunnelDHPublicKeyItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY) {}
RsGxsTunnelDHPublicKeyItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY), public_key(NULL) {}
RsGxsTunnelDHPublicKeyItem(void *data,uint32_t size) ; // deserialization
virtual ~RsGxsTunnelDHPublicKeyItem() ;
@ -141,8 +141,8 @@ class RsGxsTunnelDHPublicKeyItem: public RsGxsTunnelItem
private:
// make the object non copy-able
RsGxsTunnelDHPublicKeyItem(const RsGxsTunnelDHPublicKeyItem&) : RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY) {}
const RsGxsTunnelDHPublicKeyItem& operator=(const RsGxsTunnelDHPublicKeyItem&) { return *this ;}
RsGxsTunnelDHPublicKeyItem(const RsGxsTunnelDHPublicKeyItem&) : RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY), public_key(NULL) {}
const RsGxsTunnelDHPublicKeyItem& operator=(const RsGxsTunnelDHPublicKeyItem&) { public_key = NULL; return *this ;}
};
class RsGxsTunnelSerialiser: public RsServiceSerializer