mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-03-06 05:36:10 -05:00
* Memory Leak fixed in BinaryData.
* Fixed up Variable Ticking -> max = 1.0 sec now. * Removed debug output which was massively increasing CPU load. * Removed some old code from p3face-server.cc git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@461 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d69c2f72f1
commit
99aab9cea4
@ -32,6 +32,10 @@
|
|||||||
#include "pqi/pqidebug.h"
|
#include "pqi/pqidebug.h"
|
||||||
const int pqihandlerzone = 34283;
|
const int pqihandlerzone = 34283;
|
||||||
|
|
||||||
|
/****
|
||||||
|
#define DEBUG_TICK 1
|
||||||
|
#define RSITEM_DEBUG 1
|
||||||
|
****/
|
||||||
|
|
||||||
pqihandler::pqihandler(SecurityPolicy *Global)
|
pqihandler::pqihandler(SecurityPolicy *Global)
|
||||||
{
|
{
|
||||||
@ -65,12 +69,18 @@ int pqihandler::tick()
|
|||||||
{
|
{
|
||||||
if (0 < ((it -> second) -> pqi) -> tick())
|
if (0 < ((it -> second) -> pqi) -> tick())
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "pqihandler::tick() moreToTick from mod()" << std::endl;
|
||||||
|
#endif
|
||||||
moreToTick = 1;
|
moreToTick = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get the items, and queue them correctly
|
// get the items, and queue them correctly
|
||||||
if (0 < GetItems())
|
if (0 < GetItems())
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "pqihandler::tick() moreToTick from GetItems()" << std::endl;
|
||||||
|
#endif
|
||||||
moreToTick = 1;
|
moreToTick = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,6 +313,7 @@ int pqihandler::GetItems()
|
|||||||
// if yes... attempt to read.
|
// if yes... attempt to read.
|
||||||
while((item = (mod -> pqi) -> GetItem()) != NULL)
|
while((item = (mod -> pqi) -> GetItem()) != NULL)
|
||||||
{
|
{
|
||||||
|
#ifdef RSITEM_DEBUG
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "pqihandler::GetItems() Incoming Item ";
|
out << "pqihandler::GetItems() Incoming Item ";
|
||||||
out << " from: " << mod -> pqi << std::endl;
|
out << " from: " << mod -> pqi << std::endl;
|
||||||
@ -310,6 +321,7 @@ int pqihandler::GetItems()
|
|||||||
|
|
||||||
pqioutput(PQL_DEBUG_BASIC,
|
pqioutput(PQL_DEBUG_BASIC,
|
||||||
pqihandlerzone, out.str());
|
pqihandlerzone, out.str());
|
||||||
|
#endif
|
||||||
|
|
||||||
if (item->PeerId() != (mod->pqi)->PeerId())
|
if (item->PeerId() != (mod->pqi)->PeerId())
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
const int pqipersongrpzone = 354;
|
const int pqipersongrpzone = 354;
|
||||||
|
|
||||||
|
/****
|
||||||
|
#define DEBUG_TICK 1
|
||||||
|
****/
|
||||||
|
|
||||||
// handle the tunnel services.
|
// handle the tunnel services.
|
||||||
int pqipersongrp::tickServiceRecv()
|
int pqipersongrp::tickServiceRecv()
|
||||||
@ -108,13 +111,32 @@ int pqipersongrp::tick()
|
|||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (tickServiceSend()) i = 1;
|
if (tickServiceSend())
|
||||||
|
{
|
||||||
|
i = 1;
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "pqipersongrp::tick() moreToTick from tickServiceSend()" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (pqihandler::tick()) i = 1; /* does actual Send/Recv */
|
if (pqihandler::tick()) /* does actual Send/Recv */
|
||||||
|
{
|
||||||
|
i = 1;
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "pqipersongrp::tick() moreToTick from pqihandler::tick()" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (tickServiceRecv()) i = 1;
|
|
||||||
|
|
||||||
return 1;
|
if (tickServiceRecv())
|
||||||
|
{
|
||||||
|
i = 1;
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "pqipersongrp::tick() moreToTick from tickServiceRecv()" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pqipersongrp::status()
|
int pqipersongrp::status()
|
||||||
|
@ -40,6 +40,12 @@ const int pqistreamerzone = 8221;
|
|||||||
|
|
||||||
const int PQISTREAM_ABS_MAX = 100000000; /* 100 MB/sec (actually per loop) */
|
const int PQISTREAM_ABS_MAX = 100000000; /* 100 MB/sec (actually per loop) */
|
||||||
|
|
||||||
|
/* This removes the print statements (which hammer pqidebug) */
|
||||||
|
/***
|
||||||
|
#define RSITEM_DEBUG 1
|
||||||
|
***/
|
||||||
|
|
||||||
|
|
||||||
pqistreamer::pqistreamer(RsSerialiser *rss, std::string id, BinInterface *bio_in, int bio_flags_in)
|
pqistreamer::pqistreamer(RsSerialiser *rss, std::string id, BinInterface *bio_in, int bio_flags_in)
|
||||||
:PQInterface(id), rsSerialiser(rss), bio(bio_in), bio_flags(bio_flags_in),
|
:PQInterface(id), rsSerialiser(rss), bio(bio_in), bio_flags(bio_flags_in),
|
||||||
pkt_wpending(NULL),
|
pkt_wpending(NULL),
|
||||||
@ -146,12 +152,14 @@ pqistreamer::~pqistreamer()
|
|||||||
// Get/Send Items.
|
// Get/Send Items.
|
||||||
int pqistreamer::SendItem(RsItem *si)
|
int pqistreamer::SendItem(RsItem *si)
|
||||||
{
|
{
|
||||||
|
#ifdef RSITEM_DEBUG
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "pqistreamer::SendItem():" << std::endl;
|
out << "pqistreamer::SendItem():" << std::endl;
|
||||||
si -> print(out);
|
si -> print(out);
|
||||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return queue_outpqi(si);
|
return queue_outpqi(si);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,10 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
/****
|
||||||
|
#define DEBUG_TICK 1
|
||||||
|
****/
|
||||||
|
|
||||||
RsServer::RsServer(RsIface &i, NotifyBase &callback)
|
RsServer::RsServer(RsIface &i, NotifyBase &callback)
|
||||||
:RsControl(i, callback)
|
:RsControl(i, callback)
|
||||||
{
|
{
|
||||||
@ -47,23 +51,6 @@ RsServer::~RsServer()
|
|||||||
----> MUST BE LOCKED!
|
----> MUST BE LOCKED!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if 0
|
|
||||||
cert *RsServer::intFindCert(RsCertId id)
|
|
||||||
{
|
|
||||||
certsign cs;
|
|
||||||
convert_to_certsign(id, cs);
|
|
||||||
return sslr -> findcertsign(cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
RsCertId RsServer::intGetCertId(cert *c)
|
|
||||||
{
|
|
||||||
certsign cs;
|
|
||||||
sslr -> getcertsign(c, cs);
|
|
||||||
RsCertId id = convert_to_str(cs);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WINDOWS_SYS
|
#ifdef WINDOWS_SYS
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
@ -91,7 +78,7 @@ void RsServer::run()
|
|||||||
|
|
||||||
double timeDelta = 0.25;
|
double timeDelta = 0.25;
|
||||||
double minTimeDelta = 0.1; // 25;
|
double minTimeDelta = 0.1; // 25;
|
||||||
double maxTimeDelta = 2.0;
|
double maxTimeDelta = 1.0;
|
||||||
double kickLimit = 0.5;
|
double kickLimit = 0.5;
|
||||||
|
|
||||||
double avgTickRate = timeDelta;
|
double avgTickRate = timeDelta;
|
||||||
@ -118,17 +105,21 @@ void RsServer::run()
|
|||||||
/* for the fast ticked stuff */
|
/* for the fast ticked stuff */
|
||||||
if (delta > timeDelta)
|
if (delta > timeDelta)
|
||||||
{
|
{
|
||||||
//std::cerr << "Delta: " << delta << std::endl;
|
#ifdef DEBUG_TICK
|
||||||
//std::cerr << "Time Delta: " << timeDelta << std::endl;
|
std::cerr << "Delta: " << delta << std::endl;
|
||||||
//std::cerr << "Avg Tick Rate: " << avgTickRate << std::endl;
|
std::cerr << "Time Delta: " << timeDelta << std::endl;
|
||||||
|
std::cerr << "Avg Tick Rate: " << avgTickRate << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
lastts = ts;
|
lastts = ts;
|
||||||
|
|
||||||
/******************************** RUN SERVER *****************/
|
/******************************** RUN SERVER *****************/
|
||||||
lockRsCore();
|
lockRsCore();
|
||||||
|
|
||||||
// std::cerr << "RsServer::run() Lock() -> Run()" << std::endl;
|
|
||||||
int moreToTick = server -> tick();
|
int moreToTick = server -> tick();
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "RsServer::run() server->tick(): moreToTick: " << moreToTick << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
unlockRsCore();
|
unlockRsCore();
|
||||||
|
|
||||||
@ -187,7 +178,9 @@ void RsServer::run()
|
|||||||
|
|
||||||
// Update All Every 5 Seconds.
|
// Update All Every 5 Seconds.
|
||||||
// These Update Functions do the locking themselves.
|
// These Update Functions do the locking themselves.
|
||||||
//std::cerr << "RsServer::run() Updates()" << std::endl;
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "RsServer::run() Updates()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// These two have been completed!
|
// These two have been completed!
|
||||||
//std::cerr << "RsServer::run() UpdateAllCerts()" << std::endl;
|
//std::cerr << "RsServer::run() UpdateAllCerts()" << std::endl;
|
||||||
@ -222,7 +215,6 @@ void RsServer::run()
|
|||||||
mRanking->tick();
|
mRanking->tick();
|
||||||
|
|
||||||
|
|
||||||
/* force saving test */
|
|
||||||
#if 0
|
#if 0
|
||||||
std::string opt;
|
std::string opt;
|
||||||
std::string val = "VALUE";
|
std::string val = "VALUE";
|
||||||
@ -262,13 +254,6 @@ void RsServer::run()
|
|||||||
} // end of slow tick.
|
} // end of slow tick.
|
||||||
|
|
||||||
} // end of only once a second.
|
} // end of only once a second.
|
||||||
|
|
||||||
// update graphics.. ( but only if gui is visible )
|
|
||||||
// This is also triggered in slow tick...
|
|
||||||
//if ((ui->main_win->shown()) || (ui->chatter_window->shown()))
|
|
||||||
{
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,12 @@ RsTlvBinaryData::RsTlvBinaryData(uint16_t t)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsTlvBinaryData::~RsTlvBinaryData()
|
||||||
|
{
|
||||||
|
TlvClear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// used to allocate memory andinitialize binary data member
|
/// used to allocate memory andinitialize binary data member
|
||||||
bool RsTlvBinaryData::setBinData(void *data, uint16_t size)
|
bool RsTlvBinaryData::setBinData(void *data, uint16_t size)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ class RsTlvBinaryData: public RsTlvItem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsTlvBinaryData(uint16_t t);
|
RsTlvBinaryData(uint16_t t);
|
||||||
virtual ~RsTlvBinaryData() { return;}
|
virtual ~RsTlvBinaryData();
|
||||||
virtual uint16_t TlvSize();
|
virtual uint16_t TlvSize();
|
||||||
virtual void TlvClear(); /*! Initialize fields to empty legal values ( "0", "", etc) */
|
virtual void TlvClear(); /*! Initialize fields to empty legal values ( "0", "", etc) */
|
||||||
/// Serialise.
|
/// Serialise.
|
||||||
|
@ -53,7 +53,10 @@
|
|||||||
|
|
||||||
const int fldxsrvrzone = 47659;
|
const int fldxsrvrzone = 47659;
|
||||||
|
|
||||||
|
/****
|
||||||
#define SERVER_DEBUG 1
|
#define SERVER_DEBUG 1
|
||||||
|
#define DEBUG_TICK 1
|
||||||
|
****/
|
||||||
|
|
||||||
filedexserver::filedexserver()
|
filedexserver::filedexserver()
|
||||||
:p3Config(CONFIG_TYPE_FSERVER),
|
:p3Config(CONFIG_TYPE_FSERVER),
|
||||||
@ -100,16 +103,25 @@ int filedexserver::tick()
|
|||||||
if (0 < pqisi -> tick())
|
if (0 < pqisi -> tick())
|
||||||
{
|
{
|
||||||
moreToTick = 1;
|
moreToTick = 1;
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "filedexserver::tick() moreToTick from pqisi" << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < handleInputQueues())
|
if (0 < handleInputQueues())
|
||||||
{
|
{
|
||||||
moreToTick = 1;
|
moreToTick = 1;
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "filedexserver::tick() moreToTick from InputQueues" << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < handleOutputQueues())
|
if (0 < handleOutputQueues())
|
||||||
{
|
{
|
||||||
moreToTick = 1;
|
moreToTick = 1;
|
||||||
|
#ifdef DEBUG_TICK
|
||||||
|
std::cerr << "filedexserver::tick() moreToTick from OutputQueues" << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return moreToTick;
|
return moreToTick;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user