* HACK: fixed mem issues with file data - not ideal

* removed more debug: filedata prints.
 * removed rank/photo/games from setup for release (#define RS_RELEASE)



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@464 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-04-03 14:34:52 +00:00
parent 0a68ec6bee
commit 6c90e1ad67
5 changed files with 49 additions and 14 deletions

View File

@ -212,7 +212,8 @@ void RsServer::run()
/* Tick slow services */
mRanking->tick();
if (mRanking)
mRanking->tick();
#if 0

View File

@ -67,6 +67,11 @@
#include "pqi/p3notify.h" // HACK - moved to pqi for compilation order.
// UNCOMMENT THIS FOR UNFINISHED SERVICES
#define RS_RELEASE 1
/**************** PQI_USE_XPGP ******************/
#if defined(PQI_USE_XPGP)
#include "pqi/authxpgp.h"
@ -525,18 +530,20 @@ int RsServer::StartupRetroShare(RsInit *config)
ad = new p3disc(mAuthMgr, mConnMgr);
msgSrv = new p3MsgService(mConnMgr);
chatSrv = new p3ChatService(mConnMgr);
p3GameLauncher *gameLauncher = new p3GameLauncher(mConnMgr);
pqih -> addService(ad);
pqih -> addService(msgSrv);
pqih -> addService(chatSrv);
pqih -> addService(gameLauncher);
/* create Cache Services */
std::string config_dir = config->basedir;
std::string localcachedir = config_dir + "/cache/local";
std::string remotecachedir = config_dir + "/cache/remote";
#ifndef RS_RELEASE
p3GameLauncher *gameLauncher = new p3GameLauncher(mConnMgr);
pqih -> addService(gameLauncher);
mRanking = new p3Ranking(mConnMgr, RS_SERVICE_TYPE_RANK,
mCacheStrapper, mCacheTransfer,
localcachedir, remotecachedir, 3600 * 24 * 30);
@ -550,6 +557,11 @@ int RsServer::StartupRetroShare(RsInit *config)
CachePair cp2(photoService, photoService, CacheId(RS_SERVICE_TYPE_PHOTO, 0));
mCacheStrapper -> addCachePair(cp2);
#else
mRanking = NULL;
#endif
/**************************************************************************/
@ -692,11 +704,17 @@ int RsServer::StartupRetroShare(RsInit *config)
/* Setup GUI Interfaces. */
rsPeers = new p3Peers(mConnMgr, mAuthMgr);
rsGameLauncher = gameLauncher;
rsRanks = new p3Rank(mRanking);
rsMsgs = new p3Msgs(mAuthMgr, msgSrv, chatSrv);
rsDisc = new p3Discovery(ad);
#ifndef RS_RELEASE
rsGameLauncher = gameLauncher;
rsPhoto = new p3Photo(photoService);
rsRanks = new p3Rank(mRanking);
#else
rsGameLauncher = NULL;
rsPhoto = NULL;
rsRanks = NULL;
#endif
/* put a welcome message in! */

View File

@ -496,14 +496,17 @@ int filedexserver::handleInputQueues()
i_init = i;
while((fr = pqisi -> GetFileRequest()) != NULL )
{
//std::cerr << "filedexserver::handleInputQueues() Recvd ftFiler Request" << std::endl;
#ifdef SERVER_DEBUG
std::cerr << "filedexserver::handleInputQueues() Recvd ftFiler Request" << std::endl;
std::ostringstream out;
if (i++ == i_init)
if (i == i_init)
{
out << "Incoming(Net) File Item:" << std::endl;
}
fr -> print(out);
pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str());
#endif
i++; /* count */
/* This bit is for debugging only! (not really needed) */
@ -521,20 +524,23 @@ int filedexserver::handleInputQueues()
while((fd = pqisi -> GetFileData()) != NULL )
{
//std::cerr << "filedexserver::handleInputQueues() Recvd ftFiler Data" << std::endl;
#ifdef SERVER_DEBUG
std::ostringstream out;
if (i++ == i_init)
if (i == i_init)
{
out << "Incoming(Net) File Data:" << std::endl;
}
fd -> print(out);
pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str());
#endif
i++; /* count */
/* incoming data */
ftFileData *ffd = new ftFileData(fd->PeerId(),
fd->fd.file.hash, fd->fd.file.filesize,
fd->fd.file_offset,
fd->fd.binData.bin_len,
fd->fd.binData.bin_data);
fd->fd.binData.bin_data, FT_FILEDATA_FLAG_NOFREE);
ftFiler->recvFileInfo(ffd);
delete fd;

View File

@ -64,28 +64,38 @@ virtual ~ftFileRequest() { return; }
uint32_t chunk;
};
const uint32_t FT_FILEDATA_FLAG_NOFREE = 0x01;
class ftFileData: public ftFileRequest
{
public:
ftFileData(std::string id_in, std::string hash_in,
uint64_t size_in, uint64_t offset_in,
uint32_t chunk_in, void *data_in)
uint32_t chunk_in, void *data_in, uint32_t flags)
:ftFileRequest(id_in, hash_in, size_in,
offset_in, chunk_in), data(data_in)
offset_in, chunk_in), data(data_in), ftFlags(flags)
{
return;
}
virtual ~ftFileData()
{
if (data)
if (ftFlags & FT_FILEDATA_FLAG_NOFREE)
{
free(data);
/* don't free */
}
else
{
if (data)
{
free(data);
}
}
data = NULL;
}
void *data;
uint32_t ftFlags;
};

View File

@ -997,7 +997,7 @@ int ftfiler::generateFileData(ftFileStatus *s, std::string id, uint64_t offset,
}
// make a FileData type.
ftFileData *fd = new ftFileData(id, s->hash, s->size, offset, tosend, data);
ftFileData *fd = new ftFileData(id, s->hash, s->size, offset, tosend, data, 0);
/* send off the packet */
out_queue.push_back(fd);