mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-30 09:13:40 -05:00
started updating debug info in gxsnetservice
This commit is contained in:
parent
dcdf9df0a4
commit
9843c1fb34
@ -36,11 +36,14 @@
|
|||||||
#include "pgp/pgpauxutils.h"
|
#include "pgp/pgpauxutils.h"
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* #define NXS_NET_DEBUG 1
|
* Use the following defines to debug:
|
||||||
|
NXS_NET_DEBUG_0 shows group update high level information
|
||||||
|
NXS_NET_DEBUG_1 shows group update low level info (including transaction details)
|
||||||
|
NXS_NET_DEBUG_2 bandwidth information
|
||||||
***/
|
***/
|
||||||
// #define NXS_NET_DEBUG 1
|
#define NXS_NET_DEBUG_0 1
|
||||||
// #define NXS_NET_DEBUG_0 1
|
#define NXS_NET_DEBUG_1 1
|
||||||
// #define NXS_NET_DEBUG_1 1
|
#define NXS_NET_DEBUG_2 1
|
||||||
|
|
||||||
#define GIXS_CUT_OFF 0
|
#define GIXS_CUT_OFF 0
|
||||||
|
|
||||||
@ -56,6 +59,35 @@
|
|||||||
#define MAX_REQLIST_SIZE 20 // No more than 20 items per msg request list => creates smaller transactions that are less likely to be cancelled.
|
#define MAX_REQLIST_SIZE 20 // No more than 20 items per msg request list => creates smaller transactions that are less likely to be cancelled.
|
||||||
#define TRANSAC_TIMEOUT 2000 // In seconds. Has been increased to avoid epidemic transaction cancelling due to overloaded outqueues.
|
#define TRANSAC_TIMEOUT 2000 // In seconds. Has been increased to avoid epidemic transaction cancelling due to overloaded outqueues.
|
||||||
|
|
||||||
|
// Debug system to allow to print only for some IDs (group, Peer, etc)
|
||||||
|
|
||||||
|
#if defined(NXS_NET_DEBUG_0) || defined(NXS_NET_DEBUG_1) || defined(NXS_NET_DEBUG_2)
|
||||||
|
|
||||||
|
static const RsPeerId peer_to_print = RsPeerId(std::string("")) ;// use this to limit print to this peer id only
|
||||||
|
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ;// use this to allow to this group id only
|
||||||
|
static const uint32_t service_to_print = 0 ; // use this to allow to this service id only
|
||||||
|
|
||||||
|
class nullstream: public std::ostream {};
|
||||||
|
|
||||||
|
static std::ostream& gxsnetdebug(const RsPeerId& peer_id,const RsGxsGroupId& grp_id,uint32_t service_type)
|
||||||
|
{
|
||||||
|
static nullstream null ;
|
||||||
|
|
||||||
|
if((peer_to_print.isNull() || peer_id.isNull() || peer_id == peer_to_print)
|
||||||
|
&& (group_id_to_print.isNull() || grp_id.isNull() || grp_id == group_id_to_print)
|
||||||
|
&& (service_to_print==0 || service_type == 0 || service_type == service_to_print))
|
||||||
|
return std::cerr ;
|
||||||
|
else
|
||||||
|
return null ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GXSNETDEBUG___ gxsnetdebug(RsPeerId(),RsGxsGroupId(),mServiceInfo.mServiceType)
|
||||||
|
#define GXSNETDEBUG_P_(peer_id ) gxsnetdebug(peer_id ,RsGxsGroupId(),mServiceInfo.mServiceType)
|
||||||
|
#define GXSNETDEBUG__G( group_id) gxsnetdebug(RsPeerId(),group_id ,mServiceInfo.mServiceType)
|
||||||
|
#define GXSNETDEBUG_PG(peer_id,group_id) gxsnetdebug(peer_id ,group_id ,mServiceInfo.mServiceType)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
const uint32_t RsGxsNetService::FRAGMENT_SIZE = 150000;
|
const uint32_t RsGxsNetService::FRAGMENT_SIZE = 150000;
|
||||||
|
|
||||||
RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
|
RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
|
||||||
@ -142,7 +174,7 @@ public:
|
|||||||
total_record += bw ;
|
total_record += bw ;
|
||||||
++total_events ;
|
++total_events ;
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_2
|
||||||
std::cerr << "bandwidthRecorder::recordEvent() Recording event time=" << now << ". bw=" << bw << std::endl;
|
std::cerr << "bandwidthRecorder::recordEvent() Recording event time=" << now << ". bw=" << bw << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -156,7 +188,7 @@ public:
|
|||||||
// Apply a small temporal convolution.
|
// Apply a small temporal convolution.
|
||||||
estimated_required_bandwidth = 0.75*estimated_required_bandwidth + 0.25 * speed ;
|
estimated_required_bandwidth = 0.75*estimated_required_bandwidth + 0.25 * speed ;
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_2
|
||||||
std::cerr << std::dec << " " << total_record << " Bytes (" << total_events << " items)"
|
std::cerr << std::dec << " " << total_record << " Bytes (" << total_events << " items)"
|
||||||
<< " received in " << now - last_event_record << " seconds. Speed: " << speed << " KBytes/sec" << std::endl;
|
<< " received in " << now - last_event_record << " seconds. Speed: " << speed << " KBytes/sec" << std::endl;
|
||||||
std::cerr << " instantaneous speed = " << speed << " KB/s" << std::endl;
|
std::cerr << " instantaneous speed = " << speed << " KB/s" << std::endl;
|
||||||
@ -182,7 +214,7 @@ public:
|
|||||||
RsConfigDataRates rates ;
|
RsConfigDataRates rates ;
|
||||||
rsConfig->getTotalBandwidthRates(rates) ;
|
rsConfig->getTotalBandwidthRates(rates) ;
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_2
|
||||||
std::cerr << std::dec << std::endl;
|
std::cerr << std::dec << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -198,7 +230,7 @@ public:
|
|||||||
|
|
||||||
float sending_probability = std::min(outqueue_factor,max_bandwidth_factor) ;
|
float sending_probability = std::min(outqueue_factor,max_bandwidth_factor) ;
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_2
|
||||||
std::cerr << "bandwidthRecorder::computeCurrentSendingProbability()" << std::endl;
|
std::cerr << "bandwidthRecorder::computeCurrentSendingProbability()" << std::endl;
|
||||||
std::cerr << " current required bandwidth : " << estimated_required_bandwidth << " KB/s" << std::endl;
|
std::cerr << " current required bandwidth : " << estimated_required_bandwidth << " KB/s" << std::endl;
|
||||||
std::cerr << " max_bandwidth_factor : " << max_bandwidth_factor << std::endl;
|
std::cerr << " max_bandwidth_factor : " << max_bandwidth_factor << std::endl;
|
||||||
@ -227,7 +259,7 @@ RsMutex NxsBandwidthRecorder::mtx("Bandwidth recorder") ; // Protects the
|
|||||||
void RsGxsNetService::syncWithPeers()
|
void RsGxsNetService::syncWithPeers()
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
std::cerr << "RsGxsNetService::syncWithPeers() this=" << (void*)this << ". serviceInfo=" << mServiceInfo << std::endl;
|
GXSNETDEBUG___ << "RsGxsNetService::syncWithPeers() this=" << (void*)this << ". serviceInfo=" << mServiceInfo << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static RsNxsSerialiser ser(mServType) ; // this is used to estimate bandwidth.
|
static RsNxsSerialiser ser(mServType) ; // this is used to estimate bandwidth.
|
||||||
@ -264,7 +296,7 @@ void RsGxsNetService::syncWithPeers()
|
|||||||
NxsBandwidthRecorder::recordEvent(mServType,grp) ;
|
NxsBandwidthRecorder::recordEvent(mServType,grp) ;
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
std::cerr << " sending RsNxsSyncGrp item to peer id: " << *sit << " ts=" << updateTS << std::endl;
|
GXSNETDEBUG_P_(*sit) << " sending RsNxsSyncGrp item to peer id: " << *sit << " ts=" << updateTS << std::endl;
|
||||||
#endif
|
#endif
|
||||||
sendItem(grp);
|
sendItem(grp);
|
||||||
}
|
}
|
||||||
@ -300,7 +332,7 @@ void RsGxsNetService::syncWithPeers()
|
|||||||
sit = peers.begin();
|
sit = peers.begin();
|
||||||
|
|
||||||
float sending_probability = NxsBandwidthRecorder::computeCurrentSendingProbability() ;
|
float sending_probability = NxsBandwidthRecorder::computeCurrentSendingProbability() ;
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_2
|
||||||
std::cerr << " syncWithPeers(): Sending probability = " << sending_probability << std::endl;
|
std::cerr << " syncWithPeers(): Sending probability = " << sending_probability << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -323,7 +355,7 @@ void RsGxsNetService::syncWithPeers()
|
|||||||
mui = cit->second;
|
mui = cit->second;
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
std::cerr << " syncing messages with peer " << peerId << std::endl;
|
GXSNETDEBUG_P_(peerId) << " syncing messages with peer " << peerId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GrpMetaMap::const_iterator mmit = toRequest.begin();
|
GrpMetaMap::const_iterator mmit = toRequest.begin();
|
||||||
@ -358,14 +390,14 @@ void RsGxsNetService::syncWithPeers()
|
|||||||
{
|
{
|
||||||
sendItem(msg);
|
sendItem(msg);
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
std::cerr << " sending RsNxsSyncMsg req for grpId=" << grpId << " to peer " << *sit << ", last TS=" << std::dec<< time(NULL) - updateTS << " secs ago." << std::endl;
|
GXSNETDEBUG_PG(*sit,grpId) << " sending RsNxsSyncMsg req for grpId=" << grpId << " to peer " << *sit << ", last TS=" << std::dec<< time(NULL) - updateTS << " secs ago." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete msg ;
|
delete msg ;
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
std::cerr << " cancel RsNxsSyncMsg req for grpId=" << grpId << " to peer " << *sit << ": not enough bandwidth." << std::endl;
|
GXSNETDEBUG_PG(*sit,grpId) << " cancel RsNxsSyncMsg req for grpId=" << grpId << " to peer " << *sit << ": not enough bandwidth." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,7 +422,7 @@ void RsGxsNetService::subscribeStatusChanged(const RsGxsGroupId& grpId,bool subs
|
|||||||
// gets requested once again, for a proper update.
|
// gets requested once again, for a proper update.
|
||||||
|
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
std::cerr << "Changing subscribe status for grp " << grpId << " to " << subscribed << ": reseting all msg time stamps." << std::endl;
|
GXSNETDEBUG__G(grpId) << "Changing subscribe status for grp " << grpId << " to " << subscribed << ": reseting all msg time stamps." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
for(ClientMsgMap::iterator it(mClientMsgUpdateMap.begin());it!=mClientMsgUpdateMap.end();++it)
|
for(ClientMsgMap::iterator it(mClientMsgUpdateMap.begin());it!=mClientMsgUpdateMap.end();++it)
|
||||||
{
|
{
|
||||||
@ -550,8 +582,8 @@ struct GrpFragCollate
|
|||||||
|
|
||||||
void RsGxsNetService::locked_createTransactionFromPending( MsgRespPending* msgPend)
|
void RsGxsNetService::locked_createTransactionFromPending( MsgRespPending* msgPend)
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << "locked_createTransactionFromPending()" << std::endl;
|
GXSNETDEBUG_P_(msgPend->mPeerId) << "locked_createTransactionFromPending()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
MsgAuthorV::const_iterator cit = msgPend->mMsgAuthV.begin();
|
MsgAuthorV::const_iterator cit = msgPend->mMsgAuthV.begin();
|
||||||
std::list<RsNxsItem*> reqList;
|
std::list<RsNxsItem*> reqList;
|
||||||
@ -571,23 +603,23 @@ void RsGxsNetService::locked_createTransactionFromPending( MsgRespPending* msgPe
|
|||||||
msgItem->PeerId(msgPend->mPeerId);
|
msgItem->PeerId(msgPend->mPeerId);
|
||||||
reqList.push_back(msgItem);
|
reqList.push_back(msgItem);
|
||||||
}
|
}
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
else
|
else
|
||||||
std::cerr << " entry failed vetting: grpId=" << entry.mGrpId << ", msgId=" << entry.mMsgId << ", peerId=" << msgPend->mPeerId << std::endl;
|
GXSNETDEBUG_PG(msgPend->mPeerId,entry.mGrpId) << " entry failed vetting: grpId=" << entry.mGrpId << ", msgId=" << entry.mMsgId << ", peerId=" << msgPend->mPeerId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!reqList.empty())
|
if(!reqList.empty())
|
||||||
locked_pushMsgTransactionFromList(reqList, msgPend->mPeerId, transN);
|
locked_pushMsgTransactionFromList(reqList, msgPend->mPeerId, transN);
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << " added " << reqList.size() << " items to transaction." << std::endl;
|
GXSNETDEBUG_P_(msgPend->mPeerId) << " added " << reqList.size() << " items to transaction." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsNetService::locked_createTransactionFromPending(GrpRespPending* grpPend)
|
void RsGxsNetService::locked_createTransactionFromPending(GrpRespPending* grpPend)
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << "locked_createTransactionFromPending() from peer " << grpPend->mPeerId << std::endl;
|
GXSNETDEBUG_P_(grpPend->mPeerId) << "locked_createTransactionFromPending() from peer " << grpPend->mPeerId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
GrpAuthorV::const_iterator cit = grpPend->mGrpAuthV.begin();
|
GrpAuthorV::const_iterator cit = grpPend->mGrpAuthV.begin();
|
||||||
std::list<RsNxsItem*> reqList;
|
std::list<RsNxsItem*> reqList;
|
||||||
@ -598,8 +630,8 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpRespPending* grpPen
|
|||||||
|
|
||||||
if(entry.mPassedVetting)
|
if(entry.mPassedVetting)
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << " entry Group Id: " << entry.mGrpId << " PASSED" << std::endl;
|
GXSNETDEBUG_PG(grpPend->mPeerId,entry.mGrpId) << " entry Group Id: " << entry.mGrpId << " PASSED" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
RsNxsSyncGrpItem* msgItem = new RsNxsSyncGrpItem(mServType);
|
RsNxsSyncGrpItem* msgItem = new RsNxsSyncGrpItem(mServType);
|
||||||
msgItem->grpId = entry.mGrpId;
|
msgItem->grpId = entry.mGrpId;
|
||||||
@ -609,9 +641,9 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpRespPending* grpPen
|
|||||||
msgItem->PeerId(grpPend->mPeerId);
|
msgItem->PeerId(grpPend->mPeerId);
|
||||||
reqList.push_back(msgItem);
|
reqList.push_back(msgItem);
|
||||||
}
|
}
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
else
|
else
|
||||||
std::cerr << " entry failed vetting: grpId=" << entry.mGrpId << ", peerId=" << grpPend->mPeerId << std::endl;
|
GXSNETDEBUG_PG(grpPend->mPeerId,entry.mGrpId) << " entry failed vetting: grpId=" << entry.mGrpId << ", peerId=" << grpPend->mPeerId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,8 +654,8 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpRespPending* grpPen
|
|||||||
|
|
||||||
void RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVetting* grpPend)
|
void RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVetting* grpPend)
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << "locked_createTransactionFromPending(GrpCircleIdReq)" << std::endl;
|
GXSNETDEBUG_P_(grpPend->mPeerId) << "locked_createTransactionFromPending(GrpCircleIdReq)" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::vector<GrpIdCircleVet>::iterator cit = grpPend->mGrpCircleV.begin();
|
std::vector<GrpIdCircleVet>::iterator cit = grpPend->mGrpCircleV.begin();
|
||||||
uint32_t transN = locked_getTransactionId();
|
uint32_t transN = locked_getTransactionId();
|
||||||
@ -633,8 +665,8 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVett
|
|||||||
const GrpIdCircleVet& entry = *cit;
|
const GrpIdCircleVet& entry = *cit;
|
||||||
if(entry.mCleared)
|
if(entry.mCleared)
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << " Group Id: " << entry.mGroupId << " PASSED" << std::endl;
|
GXSNETDEBUG_PG(grpPend->mPeerId,entry.mGroupId) << " Group Id: " << entry.mGroupId << " PASSED" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
RsNxsSyncGrpItem* gItem = new
|
RsNxsSyncGrpItem* gItem = new
|
||||||
RsNxsSyncGrpItem(mServType);
|
RsNxsSyncGrpItem(mServType);
|
||||||
@ -647,9 +679,9 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVett
|
|||||||
// why it authorId not set here???
|
// why it authorId not set here???
|
||||||
itemL.push_back(gItem);
|
itemL.push_back(gItem);
|
||||||
}
|
}
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
else
|
else
|
||||||
std::cerr << " Group Id: " << entry.mGroupId << " FAILED" << std::endl;
|
GXSNETDEBUG_PG(grpPend->mPeerId,entry.mGroupId) << " Group Id: " << entry.mGroupId << " FAILED" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,8 +954,7 @@ void RsGxsNetService::recvNxsItemQueue()
|
|||||||
while(NULL != (item=recvItem()))
|
while(NULL != (item=recvItem()))
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG_1
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << "RsGxsNetService Item:" << (void*)item << std::endl ;
|
GXSNETDEBUG_P_(item->PeerId()) << "RsGxsNetService Item:" << (void*)item << std::endl ;
|
||||||
//item->print(std::cerr);
|
|
||||||
#endif
|
#endif
|
||||||
// RsNxsItem needs dynamic_cast, since they have derived siblings.
|
// RsNxsItem needs dynamic_cast, since they have derived siblings.
|
||||||
//
|
//
|
||||||
@ -933,8 +964,8 @@ void RsGxsNetService::recvNxsItemQueue()
|
|||||||
// a live transaction has a non zero value
|
// a live transaction has a non zero value
|
||||||
if(ni->transactionNumber != 0)
|
if(ni->transactionNumber != 0)
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG
|
#ifdef NXS_NET_DEBUG_1
|
||||||
std::cerr << " recvNxsItemQueue() handlingTransaction, transN " << ni->transactionNumber << std::endl;
|
GXSNETDEBUG_P_(item->PeerId()) << " recvNxsItemQueue() handlingTransaction, transN " << ni->transactionNumber << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!handleTransaction(ni))
|
if(!handleTransaction(ni))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user