* 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:
drbob 2008-04-03 12:51:28 +00:00
parent d69c2f72f1
commit 99aab9cea4
7 changed files with 81 additions and 36 deletions

View File

@ -32,6 +32,10 @@
#include "pqi/pqidebug.h"
const int pqihandlerzone = 34283;
/****
#define DEBUG_TICK 1
#define RSITEM_DEBUG 1
****/
pqihandler::pqihandler(SecurityPolicy *Global)
{
@ -65,12 +69,18 @@ int pqihandler::tick()
{
if (0 < ((it -> second) -> pqi) -> tick())
{
#ifdef DEBUG_TICK
std::cerr << "pqihandler::tick() moreToTick from mod()" << std::endl;
#endif
moreToTick = 1;
}
}
// get the items, and queue them correctly
if (0 < GetItems())
{
#ifdef DEBUG_TICK
std::cerr << "pqihandler::tick() moreToTick from GetItems()" << std::endl;
#endif
moreToTick = 1;
}
@ -303,6 +313,7 @@ int pqihandler::GetItems()
// if yes... attempt to read.
while((item = (mod -> pqi) -> GetItem()) != NULL)
{
#ifdef RSITEM_DEBUG
std::ostringstream out;
out << "pqihandler::GetItems() Incoming Item ";
out << " from: " << mod -> pqi << std::endl;
@ -310,6 +321,7 @@ int pqihandler::GetItems()
pqioutput(PQL_DEBUG_BASIC,
pqihandlerzone, out.str());
#endif
if (item->PeerId() != (mod->pqi)->PeerId())
{

View File

@ -31,6 +31,9 @@
const int pqipersongrpzone = 354;
/****
#define DEBUG_TICK 1
****/
// handle the tunnel services.
int pqipersongrp::tickServiceRecv()
@ -108,13 +111,32 @@ int pqipersongrp::tick()
}
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()

View File

@ -40,6 +40,12 @@ const int pqistreamerzone = 8221;
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)
:PQInterface(id), rsSerialiser(rss), bio(bio_in), bio_flags(bio_flags_in),
pkt_wpending(NULL),
@ -146,12 +152,14 @@ pqistreamer::~pqistreamer()
// Get/Send Items.
int pqistreamer::SendItem(RsItem *si)
{
#ifdef RSITEM_DEBUG
{
std::ostringstream out;
out << "pqistreamer::SendItem():" << std::endl;
si -> print(out);
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
}
#endif
return queue_outpqi(si);
}

View File

@ -32,6 +32,10 @@
#include <sys/time.h>
#include <time.h>
/****
#define DEBUG_TICK 1
****/
RsServer::RsServer(RsIface &i, NotifyBase &callback)
:RsControl(i, callback)
{
@ -47,23 +51,6 @@ RsServer::~RsServer()
----> 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
#include <time.h>
#include <sys/timeb.h>
@ -91,7 +78,7 @@ void RsServer::run()
double timeDelta = 0.25;
double minTimeDelta = 0.1; // 25;
double maxTimeDelta = 2.0;
double maxTimeDelta = 1.0;
double kickLimit = 0.5;
double avgTickRate = timeDelta;
@ -118,17 +105,21 @@ void RsServer::run()
/* for the fast ticked stuff */
if (delta > timeDelta)
{
//std::cerr << "Delta: " << delta << std::endl;
//std::cerr << "Time Delta: " << timeDelta << std::endl;
//std::cerr << "Avg Tick Rate: " << avgTickRate << std::endl;
#ifdef DEBUG_TICK
std::cerr << "Delta: " << delta << std::endl;
std::cerr << "Time Delta: " << timeDelta << std::endl;
std::cerr << "Avg Tick Rate: " << avgTickRate << std::endl;
#endif
lastts = ts;
/******************************** RUN SERVER *****************/
lockRsCore();
// std::cerr << "RsServer::run() Lock() -> Run()" << std::endl;
int moreToTick = server -> tick();
#ifdef DEBUG_TICK
std::cerr << "RsServer::run() server->tick(): moreToTick: " << moreToTick << std::endl;
#endif
unlockRsCore();
@ -187,7 +178,9 @@ void RsServer::run()
// Update All Every 5 Seconds.
// 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!
//std::cerr << "RsServer::run() UpdateAllCerts()" << std::endl;
@ -222,7 +215,6 @@ void RsServer::run()
mRanking->tick();
/* force saving test */
#if 0
std::string opt;
std::string val = "VALUE";
@ -262,13 +254,6 @@ void RsServer::run()
} // end of slow tick.
} // 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;
}

View File

@ -70,6 +70,12 @@ RsTlvBinaryData::RsTlvBinaryData(uint16_t t)
return;
}
RsTlvBinaryData::~RsTlvBinaryData()
{
TlvClear();
}
/// used to allocate memory andinitialize binary data member
bool RsTlvBinaryData::setBinData(void *data, uint16_t size)
{

View File

@ -63,7 +63,7 @@ class RsTlvBinaryData: public RsTlvItem
{
public:
RsTlvBinaryData(uint16_t t);
virtual ~RsTlvBinaryData() { return;}
virtual ~RsTlvBinaryData();
virtual uint16_t TlvSize();
virtual void TlvClear(); /*! Initialize fields to empty legal values ( "0", "", etc) */
/// Serialise.

View File

@ -53,7 +53,10 @@
const int fldxsrvrzone = 47659;
/****
#define SERVER_DEBUG 1
#define DEBUG_TICK 1
****/
filedexserver::filedexserver()
:p3Config(CONFIG_TYPE_FSERVER),
@ -100,16 +103,25 @@ int filedexserver::tick()
if (0 < pqisi -> tick())
{
moreToTick = 1;
#ifdef DEBUG_TICK
std::cerr << "filedexserver::tick() moreToTick from pqisi" << std::endl;
#endif
}
if (0 < handleInputQueues())
{
moreToTick = 1;
#ifdef DEBUG_TICK
std::cerr << "filedexserver::tick() moreToTick from InputQueues" << std::endl;
#endif
}
if (0 < handleOutputQueues())
{
moreToTick = 1;
#ifdef DEBUG_TICK
std::cerr << "filedexserver::tick() moreToTick from OutputQueues" << std::endl;
#endif
}
return moreToTick;
}