mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Enabled new File Transfer Code in libretroshare.
NB: This is not yet working. so SVN is now officially broken :( Hope to have the bugs ironed out soon. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@782 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9f68fc5393
commit
0d96b43d34
@ -14,9 +14,10 @@ librs:
|
|||||||
make -C services librs
|
make -C services librs
|
||||||
make -C dht librs
|
make -C dht librs
|
||||||
make -C upnp librs
|
make -C upnp librs
|
||||||
make -C server librs
|
make -C ft librs
|
||||||
make -C rsserver librs
|
make -C rsserver librs
|
||||||
|
|
||||||
|
# make -C server librs
|
||||||
# make -C rsiface librs
|
# make -C rsiface librs
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
@ -28,10 +29,12 @@ tests:
|
|||||||
make -C services tests
|
make -C services tests
|
||||||
make -C dht tests
|
make -C dht tests
|
||||||
make -C upnp tests
|
make -C upnp tests
|
||||||
make -C server tests
|
make -C ft tests
|
||||||
make -C rsserver tests
|
make -C rsserver tests
|
||||||
make -C rsiface tests
|
make -C rsiface tests
|
||||||
|
|
||||||
|
# make -C server tests
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
make -C util clean
|
make -C util clean
|
||||||
make -C tcponudp clean
|
make -C tcponudp clean
|
||||||
@ -41,10 +44,12 @@ clean:
|
|||||||
make -C services clean
|
make -C services clean
|
||||||
make -C dht clean
|
make -C dht clean
|
||||||
make -C upnp clean
|
make -C upnp clean
|
||||||
make -C server clean
|
make -C ft clean
|
||||||
make -C rsserver clean
|
make -C rsserver clean
|
||||||
make -C rsiface clean
|
make -C rsiface clean
|
||||||
|
|
||||||
|
# make -C server clean
|
||||||
|
|
||||||
clobber:
|
clobber:
|
||||||
make -C util clobber
|
make -C util clobber
|
||||||
make -C tcponudp clobber
|
make -C tcponudp clobber
|
||||||
@ -55,7 +60,9 @@ clobber:
|
|||||||
make -C dht clobber
|
make -C dht clobber
|
||||||
make -C upnp clobber
|
make -C upnp clobber
|
||||||
make -C server clobber
|
make -C server clobber
|
||||||
|
make -C ft clobber
|
||||||
make -C rsserver clobber
|
make -C rsserver clobber
|
||||||
make -C rsiface clobber
|
make -C rsiface clobber
|
||||||
-$(RM) lib/libretroshare.a
|
-$(RM) lib/libretroshare.a
|
||||||
|
|
||||||
|
# make -C server clobber
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
* #define CS_DEBUG 1
|
* #define CS_DEBUG 1
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#define CS_DEBUG 1
|
|
||||||
|
|
||||||
bool operator<(const CacheId &a, const CacheId &b)
|
bool operator<(const CacheId &a, const CacheId &b)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
/***********
|
/***********
|
||||||
* #define FIM_DEBUG 1
|
* #define FIM_DEBUG 1
|
||||||
***********/
|
***********/
|
||||||
|
#define FIM_DEBUG 1
|
||||||
|
|
||||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, std::string cachedir, std::string pid)
|
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, std::string cachedir, std::string pid)
|
||||||
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid),
|
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid),
|
||||||
@ -596,6 +597,17 @@ void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
|
|||||||
{
|
{
|
||||||
fiMutex.lock(); { /* LOCKED DIRS */
|
fiMutex.lock(); { /* LOCKED DIRS */
|
||||||
|
|
||||||
|
#ifdef FIM_DEBUG
|
||||||
|
std::list<std::string>::iterator it;
|
||||||
|
std::cerr << "FileIndexMonitor::setSharedDirectories() :\n";
|
||||||
|
for(it = dirs.begin(); it != dirs.end(); it++)
|
||||||
|
{
|
||||||
|
std::cerr << "\t" << *it;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
pendingDirs = true;
|
pendingDirs = true;
|
||||||
pendingDirList = dirs;
|
pendingDirList = dirs;
|
||||||
|
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
* #define FI_DEBUG 1
|
* #define FI_DEBUG 1
|
||||||
****/
|
****/
|
||||||
|
|
||||||
|
#define FI_DEBUG 1
|
||||||
|
#define FI_DEBUG_ALL 1
|
||||||
|
|
||||||
|
|
||||||
DirEntry::~DirEntry()
|
DirEntry::~DirEntry()
|
||||||
{
|
{
|
||||||
@ -609,7 +612,7 @@ int FileIndex::removeOldDirectory(std::string fpath, std::string name, time_t
|
|||||||
{
|
{
|
||||||
/* path is to parent */
|
/* path is to parent */
|
||||||
#ifdef FI_DEBUG_ALL
|
#ifdef FI_DEBUG_ALL
|
||||||
std::cerr << "FileIndex::removeOldDir() Path: \"";
|
std::cerr << "FileIndex::removeOldDirectory() Path: \"";
|
||||||
std::cerr << fpath << "\"" << " + \"" << name << "\"";
|
std::cerr << fpath << "\"" << " + \"" << name << "\"";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -617,11 +620,21 @@ int FileIndex::removeOldDirectory(std::string fpath, std::string name, time_t
|
|||||||
/* because of this find - we cannot get a child of
|
/* because of this find - we cannot get a child of
|
||||||
* root (which is what we want!)
|
* root (which is what we want!)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DirEntry *parent = root->findDirectory(fpath);
|
DirEntry *parent = root->findDirectory(fpath);
|
||||||
|
/* for root directory case ... no subdir. */
|
||||||
|
if (fpath == "")
|
||||||
|
{
|
||||||
|
#ifdef FI_DEBUG
|
||||||
|
std::cerr << "FileIndex::removeOldDirectory() removing a root dir";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
parent = root;
|
||||||
|
}
|
||||||
|
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
#ifdef FI_DEBUG
|
#ifdef FI_DEBUG
|
||||||
std::cerr << "FileIndex::removeOldDir() NULL parent";
|
std::cerr << "FileIndex::removeOldDirectory() NULL parent";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -96,8 +96,10 @@ void ftController::run()
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::cerr << "ftController::run()";
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << std::endl;
|
//std::cerr << "ftController::run()";
|
||||||
|
//std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* tick the transferModules */
|
/* tick the transferModules */
|
||||||
std::list<std::string> done;
|
std::list<std::string> done;
|
||||||
@ -254,6 +256,7 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
|||||||
/* check if we have the file */
|
/* check if we have the file */
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
|
std::list<TransferInfo>::iterator pit;
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController::FileRequest(" << fname << ",";
|
std::cerr << "ftController::FileRequest(" << fname << ",";
|
||||||
@ -313,17 +316,17 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* if the sources don't exist already - add in */
|
/* if the sources don't exist already - add in */
|
||||||
for(it = info.peerIds.begin(); it != info.peerIds.end(); it++)
|
for(pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
||||||
{
|
{
|
||||||
std::cerr << "\tSource: " << *it;
|
std::cerr << "\tSource: " << pit->peerId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
if (srcIds.end() == std::find(
|
if (srcIds.end() == std::find(
|
||||||
srcIds.begin(), srcIds.end(), *it))
|
srcIds.begin(), srcIds.end(), pit->peerId))
|
||||||
{
|
{
|
||||||
srcIds.push_back(*it);
|
srcIds.push_back(pit->peerId);
|
||||||
|
|
||||||
std::cerr << "\tAdding in: " << *it;
|
std::cerr << "\tAdding in: " << pit->peerId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,6 +566,75 @@ bool ftController::FileDetails(std::string hash, FileInfo &info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* extract details */
|
/* extract details */
|
||||||
|
info.hash = hash;
|
||||||
|
info.fname = it->second.mName;
|
||||||
|
|
||||||
|
/* get list of sources from transferModule */
|
||||||
|
std::list<std::string> peerIds;
|
||||||
|
std::list<std::string>::iterator pit;
|
||||||
|
|
||||||
|
it->second.mTransfer->getFileSources(peerIds);
|
||||||
|
|
||||||
|
double totalRate;
|
||||||
|
uint32_t tfRate;
|
||||||
|
uint32_t state;
|
||||||
|
|
||||||
|
bool isDownloading = false;
|
||||||
|
bool isSuspended = false;
|
||||||
|
|
||||||
|
for(pit = peerIds.begin(); pit != peerIds.end(); pit++)
|
||||||
|
{
|
||||||
|
if (it->second.mTransfer->getPeerState(*pit, state, tfRate))
|
||||||
|
{
|
||||||
|
TransferInfo ti;
|
||||||
|
switch(state)
|
||||||
|
{
|
||||||
|
case PQIPEER_INIT:
|
||||||
|
ti.status = FT_STATE_OKAY;
|
||||||
|
break;
|
||||||
|
case PQIPEER_NOT_ONLINE:
|
||||||
|
ti.status = FT_STATE_WAITING;
|
||||||
|
break;
|
||||||
|
case PQIPEER_DOWNLOADING:
|
||||||
|
isDownloading = true;
|
||||||
|
ti.status = FT_STATE_DOWNLOADING;
|
||||||
|
break;
|
||||||
|
case PQIPEER_IDLE:
|
||||||
|
ti.status = FT_STATE_OKAY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case PQIPEER_SUSPEND:
|
||||||
|
isSuspended = true;
|
||||||
|
ti.status = FT_STATE_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ti.tfRate = tfRate / 1024.0;
|
||||||
|
ti.peerId = *pit;
|
||||||
|
info.peers.push_back(ti);
|
||||||
|
totalRate += tfRate / 1024.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((it->second).mCreator->finished())
|
||||||
|
{
|
||||||
|
info.downloadStatus = FT_STATE_COMPLETE;
|
||||||
|
}
|
||||||
|
else if (isDownloading)
|
||||||
|
{
|
||||||
|
info.downloadStatus = FT_STATE_DOWNLOADING;
|
||||||
|
}
|
||||||
|
else if (isSuspended)
|
||||||
|
{
|
||||||
|
info.downloadStatus = FT_STATE_FAILED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info.downloadStatus = FT_STATE_WAITING;
|
||||||
|
}
|
||||||
|
info.tfRate = totalRate;
|
||||||
|
info.size = (it->second).mSize;
|
||||||
|
info.transfered = (it->second).mCreator->getRecvd();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -91,11 +91,21 @@ bool ftFiStore::search(std::string hash, uint64_t size, uint32_t hintflags, File
|
|||||||
info.fname = it->name;
|
info.fname = it->name;
|
||||||
info.size = it->size;
|
info.size = it->size;
|
||||||
info.hash = it->hash;
|
info.hash = it->hash;
|
||||||
|
|
||||||
}
|
}
|
||||||
info.peerIds.push_back(it->id);
|
|
||||||
|
TransferInfo ti;
|
||||||
|
ti.peerId = it->id;
|
||||||
|
ti.name = it->name;
|
||||||
|
ti.tfRate = 0;
|
||||||
|
info.peers.push_back(ti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**** DEPENDS ON SOURCES!
|
||||||
|
info.downloadStatus = FT_STATE_COMPLETE:
|
||||||
|
****/
|
||||||
|
|
||||||
/* if the first flag is cleared, we've definitely
|
/* if the first flag is cleared, we've definitely
|
||||||
* had a full match!.
|
* had a full match!.
|
||||||
*/
|
*/
|
||||||
|
@ -44,8 +44,8 @@ void ftExtraList::run()
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ELIST
|
#ifdef DEBUG_ELIST
|
||||||
std::cerr << "ftExtraList::run() Iteration";
|
//std::cerr << "ftExtraList::run() Iteration";
|
||||||
std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
* #define FILE_DEBUG 1
|
* #define FILE_DEBUG 1
|
||||||
******/
|
******/
|
||||||
|
|
||||||
|
#define FILE_DEBUG 1
|
||||||
|
|
||||||
#define CHUNK_MAX_AGE 30
|
#define CHUNK_MAX_AGE 30
|
||||||
|
|
||||||
|
|
||||||
@ -42,12 +44,15 @@ hash, uint64_t recvd): ftFileProvider(path,size,hash)
|
|||||||
bool ftFileCreator::getFileData(uint64_t offset,
|
bool ftFileCreator::getFileData(uint64_t offset,
|
||||||
uint32_t chunk_size, void *data)
|
uint32_t chunk_size, void *data)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
|
||||||
if (offset + chunk_size > mStart)
|
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
|
if (offset + chunk_size > mStart)
|
||||||
|
{
|
||||||
/* don't have the data */
|
/* don't have the data */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ftFileProvider::getFileData(offset, chunk_size, data);
|
return ftFileProvider::getFileData(offset, chunk_size, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +69,7 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
|
|||||||
std::cerr << offset;
|
std::cerr << offset;
|
||||||
std::cerr << ", " << chunk_size;
|
std::cerr << ", " << chunk_size;
|
||||||
std::cerr << ", " << data << ")";
|
std::cerr << ", " << data << ")";
|
||||||
|
std::cerr << " this: " << this;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* dodgey checking outside of mutex...
|
/* dodgey checking outside of mutex...
|
||||||
@ -123,7 +129,7 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
|
|||||||
/*
|
/*
|
||||||
* Notify ftFileChunker about chunks received
|
* Notify ftFileChunker about chunks received
|
||||||
*/
|
*/
|
||||||
notifyReceived(offset,chunk_size);
|
locked_notifyReceived(offset,chunk_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME HANDLE COMPLETION HERE - Any better way?
|
* FIXME HANDLE COMPLETION HERE - Any better way?
|
||||||
@ -136,6 +142,7 @@ int ftFileCreator::initializeFileAttrs()
|
|||||||
{
|
{
|
||||||
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: ";
|
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: ";
|
||||||
std::cerr << file_name;
|
std::cerr << file_name;
|
||||||
|
std::cerr << " this: " << this;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -195,9 +202,15 @@ ftFileCreator::~ftFileCreator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ftFileCreator::notifyReceived(uint64_t offset, uint32_t chunk_size)
|
int ftFileCreator::locked_notifyReceived(uint64_t offset, uint32_t chunk_size)
|
||||||
{
|
{
|
||||||
/* ALREADY LOCKED */
|
/* ALREADY LOCKED */
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
|
std::cerr << "ftFileCreator::locked_notifyReceived( " << offset;
|
||||||
|
std::cerr << ", " << chunk_size << " )";
|
||||||
|
std::cerr << " this: " << this;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* find the chunk */
|
/* find the chunk */
|
||||||
std::map<uint64_t, ftChunk>::iterator it;
|
std::map<uint64_t, ftChunk>::iterator it;
|
||||||
@ -205,6 +218,13 @@ int ftFileCreator::notifyReceived(uint64_t offset, uint32_t chunk_size)
|
|||||||
bool isFirst = false;
|
bool isFirst = false;
|
||||||
if (it == mChunks.end())
|
if (it == mChunks.end())
|
||||||
{
|
{
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
|
std::cerr << "ftFileCreator::locked_notifyReceived() ";
|
||||||
|
std::cerr << " Failed to match to existing chunk - ignoring";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
locked_printChunkMap();
|
||||||
|
#endif
|
||||||
return 0; /* ignoring */
|
return 0; /* ignoring */
|
||||||
}
|
}
|
||||||
else if (it == mChunks.begin())
|
else if (it == mChunks.begin())
|
||||||
@ -246,14 +266,21 @@ int ftFileCreator::notifyReceived(uint64_t offset, uint32_t chunk_size)
|
|||||||
bool ftFileCreator::getMissingChunk(uint64_t &offset, uint32_t &chunk)
|
bool ftFileCreator::getMissingChunk(uint64_t &offset, uint32_t &chunk)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
std::cerr << "ffc::getMissingChunk(...,"<< chunk << ")"<< std::endl;
|
#ifdef FILE_DEBUG
|
||||||
|
std::cerr << "ffc::getMissingChunk(...,"<< chunk << ")";
|
||||||
|
std::cerr << " this: " << this;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
locked_printChunkMap();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* check start point */
|
/* check start point */
|
||||||
|
|
||||||
if (mStart == mSize)
|
if (mStart == mSize)
|
||||||
{
|
{
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ffc::getMissingChunk() File Done";
|
std::cerr << "ffc::getMissingChunk() File Done";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +294,10 @@ bool ftFileCreator::getMissingChunk(uint64_t &offset, uint32_t &chunk)
|
|||||||
/* very simple algorithm */
|
/* very simple algorithm */
|
||||||
if (it->second.ts < old)
|
if (it->second.ts < old)
|
||||||
{
|
{
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ffc::getMissingChunk() ReAlloc";
|
std::cerr << "ffc::getMissingChunk() ReAlloc";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* retry this one */
|
/* retry this one */
|
||||||
it->second.ts = ts;
|
it->second.ts = ts;
|
||||||
@ -279,10 +308,12 @@ bool ftFileCreator::getMissingChunk(uint64_t &offset, uint32_t &chunk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ffc::getMissingChunk() new Alloc";
|
std::cerr << "ffc::getMissingChunk() new Alloc";
|
||||||
std::cerr << " mStart: " << mStart << " mEnd: " << mEnd;
|
std::cerr << " mStart: " << mStart << " mEnd: " << mEnd;
|
||||||
std::cerr << "mSize: " << mSize;
|
std::cerr << "mSize: " << mSize;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* else allocate a new chunk */
|
/* else allocate a new chunk */
|
||||||
if (mSize - mEnd < chunk)
|
if (mSize - mEnd < chunk)
|
||||||
@ -293,12 +324,48 @@ bool ftFileCreator::getMissingChunk(uint64_t &offset, uint32_t &chunk)
|
|||||||
|
|
||||||
if (chunk > 0)
|
if (chunk > 0)
|
||||||
{
|
{
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
|
std::cerr << "ffc::getMissingChunk() Allocated " << chunk;
|
||||||
|
std::cerr << " offset: " << offset;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << " mStart: " << mStart << " mEnd: " << mEnd;
|
||||||
|
std::cerr << "mSize: " << mSize;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
mChunks[offset] = ftChunk(offset, chunk, ts);
|
mChunks[offset] = ftChunk(offset, chunk, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; /* cos more data to get */
|
return true; /* cos more data to get */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ftFileCreator::locked_printChunkMap()
|
||||||
|
{
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
|
std::cerr << "ftFileCreator::locked_printChunkMap()";
|
||||||
|
std::cerr << " this: " << this;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* check start point */
|
||||||
|
std::cerr << "Size: " << mSize << " Start: " << mStart << " End: " << mEnd;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "\tOutstanding Chunks (in the middle)";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
std::map<uint64_t, ftChunk>::iterator it;
|
||||||
|
time_t ts = time(NULL);
|
||||||
|
for(it = mChunks.begin(); it != mChunks.end(); it++)
|
||||||
|
{
|
||||||
|
std::cerr << "\tChunk [" << it->second.offset << "] size: ";
|
||||||
|
std::cerr << it->second.chunk;
|
||||||
|
std::cerr << " Age: " << ts - it->second.ts;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
*
|
*
|
||||||
* ftChunk methods
|
* ftChunk methods
|
||||||
|
@ -63,7 +63,8 @@ virtual int initializeFileAttrs();
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int notifyReceived(uint64_t offset, uint32_t chunk_size);
|
bool locked_printChunkMap();
|
||||||
|
int locked_notifyReceived(uint64_t offset, uint32_t chunk_size);
|
||||||
/*
|
/*
|
||||||
* structure to track missing chunks
|
* structure to track missing chunks
|
||||||
*/
|
*/
|
||||||
|
@ -452,7 +452,9 @@ bool ftServer::sendDataRequest(std::string peerId, std::string hash,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t MAX_FT_CHUNK = 32 * 1024; /* 32K */
|
//const uint32_t MAX_FT_CHUNK = 32 * 1024; /* 32K */
|
||||||
|
//const uint32_t MAX_FT_CHUNK = 16 * 1024; /* 16K */
|
||||||
|
const uint32_t MAX_FT_CHUNK = 8 * 1024; /* 16K */
|
||||||
|
|
||||||
/* Server Send */
|
/* Server Send */
|
||||||
bool ftServer::sendData(std::string peerId, std::string hash, uint64_t size,
|
bool ftServer::sendData(std::string peerId, std::string hash, uint64_t size,
|
||||||
@ -467,8 +469,8 @@ bool ftServer::sendData(std::string peerId, std::string hash, uint64_t size,
|
|||||||
#ifdef SERVER_DEBUG
|
#ifdef SERVER_DEBUG
|
||||||
std::cerr << "ftServer::sendData() to " << peerId << std::endl;
|
std::cerr << "ftServer::sendData() to " << peerId << std::endl;
|
||||||
std::cerr << "hash: " << hash;
|
std::cerr << "hash: " << hash;
|
||||||
std::cerr << " offset: " << offset;
|
std::cerr << " offset: " << baseoffset;
|
||||||
std::cerr << " chunk: " << chunk;
|
std::cerr << " chunk: " << chunksize;
|
||||||
std::cerr << " data: " << data;
|
std::cerr << " data: " << data;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -527,6 +529,10 @@ bool ftServer::sendData(std::string peerId, std::string hash, uint64_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* NB: The rsCore lock must be activated before calling this.
|
||||||
|
* This Lock should be moved lower into the system...
|
||||||
|
* most likely destination is in ftServer.
|
||||||
|
*/
|
||||||
int ftServer::tick()
|
int ftServer::tick()
|
||||||
{
|
{
|
||||||
rslog(RSL_DEBUG_BASIC, ftserverzone,
|
rslog(RSL_DEBUG_BASIC, ftserverzone,
|
||||||
@ -586,7 +592,7 @@ bool ftServer::handleCacheData()
|
|||||||
int i_init = 0;
|
int i_init = 0;
|
||||||
|
|
||||||
#ifdef SERVER_DEBUG
|
#ifdef SERVER_DEBUG
|
||||||
std::cerr << "ftServer::handleCacheData()" << std::endl;
|
//std::cerr << "ftServer::handleCacheData()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
while((ci = mP3iface -> GetSearchResult()) != NULL)
|
while((ci = mP3iface -> GetSearchResult()) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ int main(int argc, char **argv)
|
|||||||
std::list<pqiAuthDetails>::iterator fit;
|
std::list<pqiAuthDetails>::iterator fit;
|
||||||
|
|
||||||
std::cerr << "Point 3" << std::endl;
|
std::cerr << "Point 3" << std::endl;
|
||||||
P3Hub *testHub = new P3Hub();
|
P3Hub *testHub = new P3Hub(0, NULL);
|
||||||
testHub->start();
|
testHub->start();
|
||||||
std::cerr << "Point 4" << std::endl;
|
std::cerr << "Point 4" << std::endl;
|
||||||
|
|
||||||
|
@ -165,7 +165,16 @@ int main(int argc, char **argv)
|
|||||||
std::list<pqiAuthDetails> baseFriendList, friendList;
|
std::list<pqiAuthDetails> baseFriendList, friendList;
|
||||||
std::list<pqiAuthDetails>::iterator fit;
|
std::list<pqiAuthDetails>::iterator fit;
|
||||||
|
|
||||||
P3Hub *testHub = new P3Hub();
|
|
||||||
|
/* Add in serialiser */
|
||||||
|
|
||||||
|
RsSerialiser *rss = new RsSerialiser();
|
||||||
|
rss->addSerialType(new RsFileItemSerialiser());
|
||||||
|
rss->addSerialType(new RsCacheItemSerialiser());
|
||||||
|
rss->addSerialType(new RsServiceSerialiser());
|
||||||
|
|
||||||
|
|
||||||
|
P3Hub *testHub = new P3Hub(0, rss);
|
||||||
testHub->start();
|
testHub->start();
|
||||||
|
|
||||||
/* Setup Base Friend Info */
|
/* Setup Base Friend Info */
|
||||||
|
@ -175,7 +175,14 @@ int main(int argc, char **argv)
|
|||||||
std::list<pqiAuthDetails> baseFriendList, friendList;
|
std::list<pqiAuthDetails> baseFriendList, friendList;
|
||||||
std::list<pqiAuthDetails>::iterator fit;
|
std::list<pqiAuthDetails>::iterator fit;
|
||||||
|
|
||||||
P3Hub *testHub = new P3Hub();
|
/* Add in Serialiser Test
|
||||||
|
*/
|
||||||
|
RsSerialiser *rss = new RsSerialiser();
|
||||||
|
rss->addSerialType(new RsFileItemSerialiser());
|
||||||
|
rss->addSerialType(new RsCacheItemSerialiser());
|
||||||
|
rss->addSerialType(new RsServiceSerialiser());
|
||||||
|
|
||||||
|
P3Hub *testHub = new P3Hub(0, rss);
|
||||||
testHub->start();
|
testHub->start();
|
||||||
|
|
||||||
/* Setup Base Friend Info */
|
/* Setup Base Friend Info */
|
||||||
@ -317,8 +324,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
std::cerr << "ftserver2test::sleep()";
|
//std::cerr << "ftserver3test::sleep()";
|
||||||
std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* tick the connmgrs */
|
/* tick the connmgrs */
|
||||||
@ -372,7 +379,7 @@ void *do_server_test_thread(void *data)
|
|||||||
std::string oId = oServer->OwnId();
|
std::string oId = oServer->OwnId();
|
||||||
|
|
||||||
/* create Expression */
|
/* create Expression */
|
||||||
uint64_t minFileSize = 10000;
|
uint64_t minFileSize = 100000;
|
||||||
//SizeExpression se(Greater, minFileSize);
|
//SizeExpression se(Greater, minFileSize);
|
||||||
SizeExpression se(Smaller, minFileSize);
|
SizeExpression se(Smaller, minFileSize);
|
||||||
Expression *expr = &se;
|
Expression *expr = &se;
|
||||||
@ -437,9 +444,9 @@ void *do_server_test_thread(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Give it a while to transfer */
|
/* Give it a while to transfer */
|
||||||
for(int i = 0; i < 10; i++)
|
for(int i = 0; i < 300; i++)
|
||||||
{
|
{
|
||||||
std::cerr << "Waiting 10 seconds to transfer";
|
std::cerr << "Waited " << i * 10 << " seconds for transfer";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,15 @@
|
|||||||
* #define FT_DEBUG 1
|
* #define FT_DEBUG 1
|
||||||
******/
|
******/
|
||||||
|
|
||||||
|
#define FT_DEBUG 1
|
||||||
|
|
||||||
#include "fttransfermodule.h"
|
#include "fttransfermodule.h"
|
||||||
|
|
||||||
ftTransferModule::ftTransferModule(ftFileCreator *fc, ftDataMultiplex *dm, ftController *c)
|
ftTransferModule::ftTransferModule(ftFileCreator *fc, ftDataMultiplex *dm, ftController *c)
|
||||||
:mFileCreator(fc), mMultiplexor(dm), mFtController(c), mFlag(0)
|
:mFileCreator(fc), mMultiplexor(dm), mFtController(c), mFlag(0)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
mHash = mFileCreator->getHash();
|
mHash = mFileCreator->getHash();
|
||||||
mSize = mFileCreator->getFileSize();
|
mSize = mFileCreator->getFileSize();
|
||||||
mFileStatus.hash = mHash;
|
mFileStatus.hash = mHash;
|
||||||
@ -45,8 +49,11 @@ ftTransferModule::ftTransferModule(ftFileCreator *fc, ftDataMultiplex *dm, ftCon
|
|||||||
ftTransferModule::~ftTransferModule()
|
ftTransferModule::~ftTransferModule()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
bool ftTransferModule::setFileSources(std::list<std::string> peerIds)
|
bool ftTransferModule::setFileSources(std::list<std::string> peerIds)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
mFileSources.clear();
|
mFileSources.clear();
|
||||||
|
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
@ -73,8 +80,20 @@ bool ftTransferModule::setFileSources(std::list<std::string> peerIds)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ftTransferModule::getFileSources(std::list<std::string> &peerIds)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
std::map<std::string,peerInfo>::iterator it;
|
||||||
|
for(it = mFileSources.begin(); it != mFileSources.end(); it++)
|
||||||
|
{
|
||||||
|
peerIds.push_back(it->first);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ftTransferModule::setPeerState(std::string peerId,uint32_t state,uint32_t maxRate)
|
bool ftTransferModule::setPeerState(std::string peerId,uint32_t state,uint32_t maxRate)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
std::cerr << "ftTransferModule::setPeerState()";
|
std::cerr << "ftTransferModule::setPeerState()";
|
||||||
std::cerr << " peerId: " << peerId;
|
std::cerr << " peerId: " << peerId;
|
||||||
@ -108,8 +127,30 @@ bool ftTransferModule::setPeerState(std::string peerId,uint32_t state,uint32_t m
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ftTransferModule::getPeerState(std::string peerId,uint32_t &state,uint32_t &tfRate)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
std::map<std::string,peerInfo>::iterator mit;
|
||||||
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
|
if (mit == mFileSources.end()) return false;
|
||||||
|
|
||||||
|
state = (mit->second).state;
|
||||||
|
tfRate = (uint32_t) (mit->second).actualRate;
|
||||||
|
|
||||||
|
#ifdef FT_DEBUG
|
||||||
|
std::cerr << "ftTransferModule::getPeerState()";
|
||||||
|
std::cerr << " peerId: " << peerId;
|
||||||
|
std::cerr << " state: " << state;
|
||||||
|
std::cerr << " tfRate: " << tfRate << std::endl;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ftTransferModule::getDataRate(std::string peerId)
|
uint32_t ftTransferModule::getDataRate(std::string peerId)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
std::map<std::string,peerInfo>::iterator mit;
|
std::map<std::string,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
if (mit == mFileSources.end())
|
if (mit == mFileSources.end())
|
||||||
@ -139,6 +180,9 @@ bool ftTransferModule::recvFileData(std::string peerId, uint64_t offset,
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
std::map<std::string,peerInfo>::iterator mit;
|
std::map<std::string,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
@ -176,7 +220,7 @@ bool ftTransferModule::recvFileData(std::string peerId, uint64_t offset,
|
|||||||
|
|
||||||
(mit->second).receivedSize += chunk_size;
|
(mit->second).receivedSize += chunk_size;
|
||||||
(mit->second).state = PQIPEER_IDLE;
|
(mit->second).state = PQIPEER_IDLE;
|
||||||
|
} /***** STACK MUTEX END ****/
|
||||||
return storeData(offset, chunk_size, data);
|
return storeData(offset, chunk_size, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,6 +290,10 @@ bool ftTransferModule::storeData(uint64_t offset, uint32_t chunk_size,void *data
|
|||||||
|
|
||||||
bool ftTransferModule::queryInactive()
|
bool ftTransferModule::queryInactive()
|
||||||
{
|
{
|
||||||
|
/* NB: Not sure about this lock... might cause deadlock.
|
||||||
|
*/
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
std::cerr << "ftTransferModule::queryInactive()" << std::endl;
|
std::cerr << "ftTransferModule::queryInactive()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -291,12 +339,20 @@ bool ftTransferModule::queryInactive()
|
|||||||
//file response received or peer side is just ready for download
|
//file response received or peer side is just ready for download
|
||||||
case PQIPEER_IDLE:
|
case PQIPEER_IDLE:
|
||||||
pInfo->actualRate = pInfo->chunkSize/(ts-(pInfo->lastTS));
|
pInfo->actualRate = pInfo->chunkSize/(ts-(pInfo->lastTS));
|
||||||
if (pInfo->actualRate < pInfo->desiredRate/2)
|
|
||||||
{
|
if (pInfo->actualRate < pInfo->desiredRate)
|
||||||
req_size = pInfo->chunkSize * 2 ;
|
{
|
||||||
|
if (pInfo->actualRate < pInfo->desiredRate/2)
|
||||||
|
{
|
||||||
|
req_size = pInfo->chunkSize * 2 ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
req_size = (uint32_t ) (pInfo->chunkSize * 1.1) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
req_size = (uint32_t ) (pInfo->chunkSize * 0.9) ;
|
req_size = (uint32_t ) (pInfo->chunkSize * 0.9) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +392,8 @@ bool ftTransferModule::queryInactive()
|
|||||||
|
|
||||||
bool ftTransferModule::pauseTransfer()
|
bool ftTransferModule::pauseTransfer()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
std::map<std::string,peerInfo>::iterator mit;
|
std::map<std::string,peerInfo>::iterator mit;
|
||||||
for(mit = mOnlinePeers.begin(); mit != mOnlinePeers.end(); mit++)
|
for(mit = mOnlinePeers.begin(); mit != mOnlinePeers.end(); mit++)
|
||||||
@ -350,6 +408,7 @@ bool ftTransferModule::pauseTransfer()
|
|||||||
|
|
||||||
bool ftTransferModule::resumeTransfer()
|
bool ftTransferModule::resumeTransfer()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
/*
|
/*
|
||||||
std::map<std::string,peerInfo>::iterator mit;
|
std::map<std::string,peerInfo>::iterator mit;
|
||||||
for(mit = mOnlinePeers.begin(); mit != mOnlinePeers.end(); mit++)
|
for(mit = mOnlinePeers.begin(); mit != mOnlinePeers.end(); mit++)
|
||||||
@ -364,6 +423,7 @@ bool ftTransferModule::resumeTransfer()
|
|||||||
|
|
||||||
bool ftTransferModule::cancelTransfer()
|
bool ftTransferModule::cancelTransfer()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
mFileStatus.stat=ftFileStatus::PQIFILE_FAIL_CANCEL;
|
mFileStatus.stat=ftFileStatus::PQIFILE_FAIL_CANCEL;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -388,7 +448,14 @@ int ftTransferModule::tick()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
queryInactive();
|
queryInactive();
|
||||||
switch (mFlag)
|
|
||||||
|
uint32_t flags = 0;
|
||||||
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
flags = mFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (flags)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
adjustSpeed();
|
adjustSpeed();
|
||||||
@ -409,12 +476,30 @@ int ftTransferModule::tick()
|
|||||||
|
|
||||||
void ftTransferModule::adjustSpeed()
|
void ftTransferModule::adjustSpeed()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
std::map<std::string,peerInfo>::iterator mit;
|
std::map<std::string,peerInfo>::iterator mit;
|
||||||
|
|
||||||
|
#ifdef FT_DEBUG
|
||||||
|
std::cerr << "ftTransferModule::adjustSpeed()";
|
||||||
|
std::cerr << " Initial Desired Rate: " << desiredRate << " Actual Rate: " << actualRate;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(mit = mFileSources.begin(); mit != mFileSources.end(); mit++)
|
for(mit = mFileSources.begin(); mit != mFileSources.end(); mit++)
|
||||||
{
|
{
|
||||||
if (((mit->second).state == PQIPEER_DOWNLOADING)
|
if (((mit->second).state == PQIPEER_DOWNLOADING)
|
||||||
|| ((mit->second).state == PQIPEER_IDLE))
|
|| ((mit->second).state == PQIPEER_IDLE))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef FT_DEBUG
|
||||||
|
std::cerr << "ftTransferModule::adjustSpeed()";
|
||||||
|
std::cerr << "\t" << mit->first << " Desired Rate: " << desiredRate << " Actual Rate: " << actualRate;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((actualRate < desiredRate) && ((mit->second).actualRate >= (mit->second).desiredRate))
|
if ((actualRate < desiredRate) && ((mit->second).actualRate >= (mit->second).desiredRate))
|
||||||
{
|
{
|
||||||
(mit->second).desiredRate *= 1.1;
|
(mit->second).desiredRate *= 1.1;
|
||||||
@ -426,6 +511,11 @@ void ftTransferModule::adjustSpeed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef FT_DEBUG
|
||||||
|
std::cerr << "ftTransferModule::adjustSpeed()";
|
||||||
|
std::cerr << " Initial Desired Rate: " << desiredRate << " Actual Rate: " << actualRate;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,8 @@ public:
|
|||||||
//interface to download controller
|
//interface to download controller
|
||||||
bool setFileSources(std::list<std::string> peerIds);
|
bool setFileSources(std::list<std::string> peerIds);
|
||||||
bool setPeerState(std::string peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
bool setPeerState(std::string peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
||||||
|
bool getFileSources(std::list<std::string> &peerIds);
|
||||||
|
bool getPeerState(std::string peerId,uint32_t &state,uint32_t &tfRate);
|
||||||
uint32_t getDataRate(std::string peerId);
|
uint32_t getDataRate(std::string peerId);
|
||||||
bool pauseTransfer();
|
bool pauseTransfer();
|
||||||
bool resumeTransfer();
|
bool resumeTransfer();
|
||||||
|
@ -27,11 +27,18 @@
|
|||||||
#include "pqi/p3connmgr.h"
|
#include "pqi/p3connmgr.h"
|
||||||
|
|
||||||
/******
|
/******
|
||||||
*#define HUB_DEBUG
|
*#define HUB_DEBUG 1
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
P3Hub::P3Hub()
|
#define HUB_DEBUG 1
|
||||||
|
|
||||||
|
P3Hub::P3Hub(uint32_t flags, RsSerialiser *rss)
|
||||||
|
:mSerialiser(rss), mUseSerialiser(false)
|
||||||
{
|
{
|
||||||
|
if (rss)
|
||||||
|
{
|
||||||
|
mUseSerialiser = true;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +64,54 @@ void P3Hub::addP3Pipe(std::string id, P3Pipe *pqi, p3ConnectMgr *mgr)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsItem *P3Hub::SerialiserPass(RsItem *inItem)
|
||||||
|
{
|
||||||
|
/* pass through serialiser */
|
||||||
|
|
||||||
|
RsItem *item = NULL;
|
||||||
|
|
||||||
|
uint32_t pktsize = mSerialiser->size(inItem);
|
||||||
|
void *ptr = malloc(pktsize);
|
||||||
|
|
||||||
|
#ifdef HUB_DEBUG
|
||||||
|
std::cerr << "P3Hub::SerialiserPass() Expected Size: " << pktsize;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!mSerialiser->serialise(inItem, ptr, &pktsize))
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef HUB_DEBUG
|
||||||
|
std::cerr << "P3Hub::SerialiserPass() serialise Failed";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef HUB_DEBUG
|
||||||
|
std::cerr << "P3Hub::SerialiserPass() serialise success, size: " << pktsize;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
item = mSerialiser->deserialise(ptr, &pktsize);
|
||||||
|
item->PeerId(inItem->PeerId());
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
#ifdef HUB_DEBUG
|
||||||
|
std::cerr << "P3Hub::SerialiserPass() deSerialise Failed";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete inItem;
|
||||||
|
free(ptr);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void P3Hub::run()
|
void P3Hub::run()
|
||||||
{
|
{
|
||||||
@ -89,8 +144,16 @@ void P3Hub::run()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (mUseSerialiser)
|
||||||
recvdQ.push_back(make_pair(it->first, item));
|
{
|
||||||
|
item = SerialiserPass(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* serialiser might hav munched it. */
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
recvdQ.push_back(make_pair(it->first, item));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +67,18 @@ class P3Hub: public RsThread
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
P3Hub();
|
P3Hub(uint32_t flags, RsSerialiser *rss);
|
||||||
void addP3Pipe(std::string id, P3Pipe *, p3ConnectMgr *mgr);
|
void addP3Pipe(std::string id, P3Pipe *, p3ConnectMgr *mgr);
|
||||||
|
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
RsItem* SerialiserPass(RsItem *inItem);
|
||||||
|
|
||||||
std::map<std::string, hubItem> mPeers;
|
std::map<std::string, hubItem> mPeers;
|
||||||
|
RsSerialiser *mSerialiser;
|
||||||
|
bool mUseSerialiser;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,6 @@ const uint32_t MAX_UPNP_INIT = 10; /* seconds UPnP timeout */
|
|||||||
* #define P3CONNMGR_NO_AUTO_CONNECTION 1
|
* #define P3CONNMGR_NO_AUTO_CONNECTION 1
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#define CONN_DEBUG 1
|
|
||||||
|
|
||||||
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 2; /* 2 Seconds? is it be enough! */
|
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 2; /* 2 Seconds? is it be enough! */
|
||||||
const uint32_t P3CONNMGR_UDP_DHT_DELAY = DHT_NOTIFY_PERIOD + 60; /* + 1 minute for DHT POST */
|
const uint32_t P3CONNMGR_UDP_DHT_DELAY = DHT_NOTIFY_PERIOD + 60; /* + 1 minute for DHT POST */
|
||||||
|
@ -540,21 +540,25 @@ int pqistreamer::handleincoming()
|
|||||||
std::string title =
|
std::string title =
|
||||||
"Warning: Bad Packet Read";
|
"Warning: Bad Packet Read";
|
||||||
|
|
||||||
std::string msg;
|
std::ostringstream msgout;
|
||||||
msg += " **** WARNING **** \n";
|
msgout << " **** WARNING **** \n";
|
||||||
msg += "Retroshare has caught a BAD Packet Read";
|
msgout << "Retroshare has caught a BAD Packet Read";
|
||||||
msg += "\n";
|
msgout << "\n";
|
||||||
msg += "This is normally caused by connecting to an";
|
msgout << "This is normally caused by connecting to an";
|
||||||
msg += " OLD version of Retroshare";
|
msgout << " OLD version of Retroshare";
|
||||||
msg += "\n";
|
msgout << "\n";
|
||||||
msg += "\n";
|
msgout << "(M:" << maxlen << " B:" << blen << " E:" << extralen << ")\n";
|
||||||
msg += "Please get your friends to upgrade to the latest version";
|
msgout << "\n";
|
||||||
msg += "\n";
|
msgout << "\n";
|
||||||
msg += "\n";
|
msgout << "Please get your friends to upgrade to the latest version";
|
||||||
msg += "If you are sure the error was not caused by an old version";
|
msgout << "\n";
|
||||||
msg += "\n";
|
msgout << "\n";
|
||||||
msg += "Please report the problem to Retroshare's developers";
|
msgout << "If you are sure the error was not caused by an old version";
|
||||||
msg += "\n";
|
msgout << "\n";
|
||||||
|
msgout << "Please report the problem to Retroshare's developers";
|
||||||
|
msgout << "\n";
|
||||||
|
|
||||||
|
std::string msg = msgout.str();
|
||||||
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||||
}
|
}
|
||||||
bio->close();
|
bio->close();
|
||||||
@ -580,13 +584,17 @@ int pqistreamer::handleincoming()
|
|||||||
std::string title =
|
std::string title =
|
||||||
"Warning: Error Completing Read";
|
"Warning: Error Completing Read";
|
||||||
|
|
||||||
std::string msg;
|
std::ostringstream msgout;
|
||||||
msg += " **** WARNING **** \n";
|
msgout << " **** WARNING **** \n";
|
||||||
msg += "Retroshare has experienced an unexpected Read ERROR";
|
msgout << "Retroshare has experienced an unexpected Read ERROR";
|
||||||
msg += "\n";
|
msgout << "\n";
|
||||||
msg += "Please contact the developers.";
|
msgout << "(M:" << maxlen << " B:" << blen;
|
||||||
msg += "\n";
|
msgout << " E:" << extralen << " R:" << tmplen << ")\n";
|
||||||
|
msgout << "\n";
|
||||||
|
msgout << "Please contact the developers.";
|
||||||
|
msgout << "\n";
|
||||||
|
|
||||||
|
std::string msg = msgout.str();
|
||||||
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||||
}
|
}
|
||||||
bio->close();
|
bio->close();
|
||||||
|
@ -37,6 +37,22 @@ typedef std::string RsChanId;
|
|||||||
typedef std::string RsMsgId;
|
typedef std::string RsMsgId;
|
||||||
typedef std::string RsAuthId;
|
typedef std::string RsAuthId;
|
||||||
|
|
||||||
|
const uint32_t FT_STATE_FAILED = 0x0000;
|
||||||
|
const uint32_t FT_STATE_OKAY = 0x0001;
|
||||||
|
const uint32_t FT_STATE_WAITING = 0x0002;
|
||||||
|
const uint32_t FT_STATE_DOWNLOADING = 0x0003;
|
||||||
|
const uint32_t FT_STATE_COMPLETE = 0x0004;
|
||||||
|
|
||||||
|
class TransferInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**** Need Some of these Fields ****/
|
||||||
|
std::string peerId;
|
||||||
|
std::string name; /* if has alternative name? */
|
||||||
|
double tfRate; /* kbytes */
|
||||||
|
int status; /* FT_STATE_... */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class FileInfo
|
class FileInfo
|
||||||
{
|
{
|
||||||
@ -75,37 +91,13 @@ static const int kRsFiStatusDone = 2;
|
|||||||
double rank;
|
double rank;
|
||||||
int age;
|
int age;
|
||||||
|
|
||||||
/* Old FileTransferInfo Entries */
|
/* Transfer Stuff */
|
||||||
public:
|
uint64_t transfered;
|
||||||
std::string source;
|
double tfRate; /* in kbytes */
|
||||||
std::list<std::string> peerIds;
|
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
||||||
int transfered;
|
std::list<TransferInfo> peers;
|
||||||
double tfRate; /* kbytes */
|
|
||||||
bool download;
|
|
||||||
int downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
|
||||||
|
|
||||||
/* ENTRIES USED BY SFI ***
|
|
||||||
*
|
|
||||||
* path,
|
|
||||||
* fname,
|
|
||||||
* hash,
|
|
||||||
* size,
|
|
||||||
* avail,
|
|
||||||
*
|
|
||||||
* source?
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileTransferInfo: public FileInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FileTransferInfo() { return; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ RSOBJ = p3peers.o \
|
|||||||
p3face-startup.o \
|
p3face-startup.o \
|
||||||
p3face-msgs.o \
|
p3face-msgs.o \
|
||||||
rsiface.o \
|
rsiface.o \
|
||||||
p3files.o \
|
|
||||||
rstypes.o
|
rstypes.o
|
||||||
|
|
||||||
|
# p3files.o \
|
||||||
# p3face-file.o \
|
# p3face-file.o \
|
||||||
# pqistrings.o \
|
# pqistrings.o \
|
||||||
# p3face-people.o
|
# p3face-people.o
|
||||||
|
@ -155,7 +155,11 @@ int RsServer::UpdateAllConfig()
|
|||||||
void RsServer::ConfigFinalSave()
|
void RsServer::ConfigFinalSave()
|
||||||
{
|
{
|
||||||
/* force saving of transfers */
|
/* force saving of transfers */
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
server->saveFileTransferStatus();
|
server->saveFileTransferStatus();
|
||||||
|
#else
|
||||||
|
//ftserver->saveFileTransferStatus();
|
||||||
|
#endif
|
||||||
|
|
||||||
mAuthMgr->FinalSaveCertificates();
|
mAuthMgr->FinalSaveCertificates();
|
||||||
mConfigMgr->completeConfiguration();
|
mConfigMgr->completeConfiguration();
|
||||||
|
@ -26,7 +26,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
|
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
#include "rsserver/p3files.h" // TMP FOR HACK!
|
#include "rsserver/p3files.h" // TMP FOR HACK!
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "tcponudp/tou.h"
|
#include "tcponudp/tou.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -117,9 +121,14 @@ void RsServer::run()
|
|||||||
/******************************** RUN SERVER *****************/
|
/******************************** RUN SERVER *****************/
|
||||||
lockRsCore();
|
lockRsCore();
|
||||||
|
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
int moreToTick = server -> tick();
|
int moreToTick = server -> tick();
|
||||||
|
#else
|
||||||
|
int moreToTick = ftserver -> tick();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_TICK
|
#ifdef DEBUG_TICK
|
||||||
std::cerr << "RsServer::run() server->tick(): moreToTick: " << moreToTick << std::endl;
|
std::cerr << "RsServer::run() ftserver->tick(): moreToTick: " << moreToTick << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unlockRsCore();
|
unlockRsCore();
|
||||||
@ -191,6 +200,8 @@ void RsServer::run()
|
|||||||
|
|
||||||
// currently Dummy Functions.
|
// currently Dummy Functions.
|
||||||
//std::cerr << "RsServer::run() UpdateAllTransfers()" << std::endl;
|
//std::cerr << "RsServer::run() UpdateAllTransfers()" << std::endl;
|
||||||
|
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
//
|
//
|
||||||
// TMP HACK.
|
// TMP HACK.
|
||||||
p3Files *p3f = (p3Files *) rsFiles;
|
p3Files *p3f = (p3Files *) rsFiles;
|
||||||
@ -198,6 +209,7 @@ void RsServer::run()
|
|||||||
{
|
{
|
||||||
p3f -> UpdateAllTransfers();
|
p3f -> UpdateAllTransfers();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//std::cerr << "RsServer::run() ";
|
//std::cerr << "RsServer::run() ";
|
||||||
//std::cerr << "UpdateRemotePeople()"<<std::endl;
|
//std::cerr << "UpdateRemotePeople()"<<std::endl;
|
||||||
@ -247,7 +259,11 @@ void RsServer::run()
|
|||||||
loop = 0;
|
loop = 0;
|
||||||
|
|
||||||
/* force saving FileTransferStatus */
|
/* force saving FileTransferStatus */
|
||||||
server->saveFileTransferStatus();
|
#ifdef USE_OLD_FT
|
||||||
|
ftserver->saveFileTransferStatus();
|
||||||
|
#else
|
||||||
|
//ftserver->saveFileTransferStatus();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* see if we need to resave certs */
|
/* see if we need to resave certs */
|
||||||
mAuthMgr->CheckSaveCertificates();
|
mAuthMgr->CheckSaveCertificates();
|
||||||
|
@ -28,8 +28,19 @@
|
|||||||
//#include <getopt.h>
|
//#include <getopt.h>
|
||||||
|
|
||||||
#include "dbase/cachestrapper.h"
|
#include "dbase/cachestrapper.h"
|
||||||
#include "server/ftfiler.h"
|
#ifdef USE_OLD_FT
|
||||||
#include "server/filedexserver.h"
|
#include "server/ftfiler.h"
|
||||||
|
#include "server/filedexserver.h"
|
||||||
|
#else
|
||||||
|
#include "ft/ftserver.h"
|
||||||
|
#include "ft/ftcontroller.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* global variable now points straight to
|
||||||
|
* ft/ code so variable defined here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
RsFiles *rsFiles = NULL;
|
||||||
|
|
||||||
#include "pqi/pqipersongrp.h"
|
#include "pqi/pqipersongrp.h"
|
||||||
#include "pqi/pqisslpersongrp.h"
|
#include "pqi/pqisslpersongrp.h"
|
||||||
@ -520,15 +531,18 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||||||
std::string certConfigFile = config->basedir.c_str();
|
std::string certConfigFile = config->basedir.c_str();
|
||||||
std::string certNeighDir = config->basedir.c_str();
|
std::string certNeighDir = config->basedir.c_str();
|
||||||
std::string emergencySaveDir = config->basedir.c_str();
|
std::string emergencySaveDir = config->basedir.c_str();
|
||||||
|
std::string emergencyPartialsDir = config->basedir.c_str();
|
||||||
if (certConfigFile != "")
|
if (certConfigFile != "")
|
||||||
{
|
{
|
||||||
certConfigFile += "/";
|
certConfigFile += "/";
|
||||||
certNeighDir += "/";
|
certNeighDir += "/";
|
||||||
emergencySaveDir += "/";
|
emergencySaveDir += "/";
|
||||||
|
emergencyPartialsDir += "/";
|
||||||
}
|
}
|
||||||
certConfigFile += configConfFile;
|
certConfigFile += configConfFile;
|
||||||
certNeighDir += configCertDir;
|
certNeighDir += configCertDir;
|
||||||
emergencySaveDir += "Downloads";
|
emergencySaveDir += "Downloads";
|
||||||
|
emergencyPartialsDir += "Partials";
|
||||||
|
|
||||||
/* if we've loaded an old format file! */
|
/* if we've loaded an old format file! */
|
||||||
bool oldFormat = false;
|
bool oldFormat = false;
|
||||||
@ -549,13 +563,14 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||||||
pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
|
pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
|
||||||
p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, config->basedir);
|
p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, config->basedir);
|
||||||
|
|
||||||
CacheStrapper *mCacheStrapper = new CacheStrapper(mAuthMgr, mConnMgr);
|
|
||||||
ftfiler *mCacheTransfer = new ftfiler(mCacheStrapper);
|
|
||||||
|
|
||||||
SecurityPolicy *none = secpolicy_create();
|
SecurityPolicy *none = secpolicy_create();
|
||||||
pqih = new pqisslpersongrp(none, flags);
|
pqih = new pqisslpersongrp(none, flags);
|
||||||
//pqih = new pqipersongrpDummy(none, flags);
|
//pqih = new pqipersongrpDummy(none, flags);
|
||||||
|
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
|
CacheStrapper *mCacheStrapper = new CacheStrapper(mAuthMgr, mConnMgr);
|
||||||
|
ftfiler *mCacheTransfer = new ftfiler(mCacheStrapper);
|
||||||
|
|
||||||
// filedex server.
|
// filedex server.
|
||||||
server = new filedexserver();
|
server = new filedexserver();
|
||||||
server->setConfigDir(config->basedir.c_str());
|
server->setConfigDir(config->basedir.c_str());
|
||||||
@ -571,6 +586,25 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||||||
|
|
||||||
rsFiles = new p3Files(server, this, mAuthMgr);
|
rsFiles = new p3Files(server, this, mAuthMgr);
|
||||||
|
|
||||||
|
#else
|
||||||
|
/****** New Ft Server **** !!! */
|
||||||
|
ftserver = new ftServer(mAuthMgr, mConnMgr);
|
||||||
|
ftserver->setP3Interface(pqih);
|
||||||
|
ftserver->setConfigDirectory(config->basedir);
|
||||||
|
|
||||||
|
ftserver->SetupFtServer(&(getNotify()));
|
||||||
|
CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper();
|
||||||
|
CacheTransfer *mCacheTransfer = ftserver->getCacheTransfer();
|
||||||
|
|
||||||
|
/* setup any extra bits (Default Paths) */
|
||||||
|
ftserver->setPartialsDirectory(emergencyPartialsDir);
|
||||||
|
ftserver->setDownloadDirectory(emergencySaveDir);
|
||||||
|
|
||||||
|
/* This should be set by config ... there is no default */
|
||||||
|
//ftserver->setSharedDirectories(fileList);
|
||||||
|
|
||||||
|
rsFiles = ftserver;
|
||||||
|
#endif
|
||||||
|
|
||||||
mConfigMgr = new p3ConfigMgr(mAuthMgr, config->basedir, "rs-v0.4.cfg", "rs-v0.4.sgn");
|
mConfigMgr = new p3ConfigMgr(mAuthMgr, config->basedir, "rs-v0.4.cfg", "rs-v0.4.sgn");
|
||||||
mGeneralConfig = new p3GeneralConfig();
|
mGeneralConfig = new p3GeneralConfig();
|
||||||
@ -649,9 +683,22 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||||||
mConnMgr->addMonitor(ad);
|
mConnMgr->addMonitor(ad);
|
||||||
mConnMgr->addMonitor(msgSrv);
|
mConnMgr->addMonitor(msgSrv);
|
||||||
|
|
||||||
|
/* must also add the controller as a Monitor...
|
||||||
|
* a little hack to get it to work.
|
||||||
|
*/
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
|
#else
|
||||||
|
mConnMgr->addMonitor(((ftController *) mCacheTransfer));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
mConfigMgr->addConfiguration("server.cfg", server);
|
mConfigMgr->addConfiguration("server.cfg", server);
|
||||||
|
#else
|
||||||
|
//mConfigMgr->addConfiguration("ftserver.cfg", ftserver);
|
||||||
|
#endif
|
||||||
mConfigMgr->addConfiguration("peers.cfg", mConnMgr);
|
mConfigMgr->addConfiguration("peers.cfg", mConnMgr);
|
||||||
mConfigMgr->addConfiguration("general.cfg", mGeneralConfig);
|
mConfigMgr->addConfiguration("general.cfg", mGeneralConfig);
|
||||||
mConfigMgr->addConfiguration("msgs.cfg", msgSrv);
|
mConfigMgr->addConfiguration("msgs.cfg", msgSrv);
|
||||||
@ -767,13 +814,12 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||||||
/* Start up Threads */
|
/* Start up Threads */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
|
#ifdef USE_OLD_FT
|
||||||
server->StartupMonitor();
|
server->StartupMonitor();
|
||||||
mDhtMgr->start();
|
#else
|
||||||
|
ftserver->StartupThreads();
|
||||||
|
|
||||||
#ifdef PQI_USE_CHANNELS
|
|
||||||
server->setP3Channel(pqih->getP3Channel());
|
|
||||||
#endif
|
#endif
|
||||||
|
mDhtMgr->start();
|
||||||
|
|
||||||
// create loopback device, and add to pqisslgrp.
|
// create loopback device, and add to pqisslgrp.
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "server/filedexserver.h"
|
//#include "server/filedexserver.h"
|
||||||
|
#include "ft/ftserver.h";
|
||||||
//#include "pqi/pqissl.h"
|
//#include "pqi/pqissl.h"
|
||||||
|
|
||||||
#include "pqi/p3cfgmgr.h"
|
#include "pqi/p3cfgmgr.h"
|
||||||
@ -156,7 +157,8 @@ int UpdateAllConfig();
|
|||||||
|
|
||||||
// The real Server Parts.
|
// The real Server Parts.
|
||||||
|
|
||||||
filedexserver *server;
|
//filedexserver *server;
|
||||||
|
ftServer *ftserver;
|
||||||
|
|
||||||
p3ConnectMgr *mConnMgr;
|
p3ConnectMgr *mConnMgr;
|
||||||
p3AuthMgr *mAuthMgr;
|
p3AuthMgr *mAuthMgr;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
RsFiles *rsFiles = NULL;
|
//RsFiles *rsFiles = NULL;
|
||||||
|
|
||||||
void p3Files::lockRsCore()
|
void p3Files::lockRsCore()
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,8 @@ LIBDIR = $(RS_TOP_DIR)/lib
|
|||||||
LIBRS = $(LIBDIR)/libretroshare.a
|
LIBRS = $(LIBDIR)/libretroshare.a
|
||||||
|
|
||||||
INCLUDE = -I $(RS_TOP_DIR)
|
INCLUDE = -I $(RS_TOP_DIR)
|
||||||
CFLAGS = -Wall -O3
|
#CFLAGS = -Wall -O3
|
||||||
|
CFLAGS = -Wall -g
|
||||||
|
|
||||||
# Flags for architecture builds.
|
# Flags for architecture builds.
|
||||||
ifdef MAC_I386_BUILD
|
ifdef MAC_I386_BUILD
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
###########################################################################
|
###########################################################################
|
||||||
#Define OS.
|
#Define OS.
|
||||||
#
|
#
|
||||||
OS = Linux
|
#OS = Linux
|
||||||
#OS = MacOSX
|
OS = MacOSX
|
||||||
#OS = Cygwin
|
#OS = Cygwin
|
||||||
#OS = Win # MinGw.
|
#OS = Win # MinGw.
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
@ -28,6 +28,14 @@
|
|||||||
#include "rsthreads.h"
|
#include "rsthreads.h"
|
||||||
#include <unistd.h> /* for usleep() */
|
#include <unistd.h> /* for usleep() */
|
||||||
|
|
||||||
|
/*******
|
||||||
|
* #define DEBUG_THREADS 1
|
||||||
|
*******/
|
||||||
|
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
#include <iostream>
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" void* rsthread_init(void* p)
|
extern "C" void* rsthread_init(void* p)
|
||||||
{
|
{
|
||||||
RsThread *thread = (RsThread *) p;
|
RsThread *thread = (RsThread *) p;
|
||||||
@ -79,6 +87,12 @@ void RsQueueThread::run()
|
|||||||
mLastWork = now;
|
mLastWork = now;
|
||||||
mLastSleep = (uint32_t)
|
mLastSleep = (uint32_t)
|
||||||
(mMinSleep + (mLastSleep - mMinSleep) / 2.0);
|
(mMinSleep + (mLastSleep - mMinSleep) / 2.0);
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
std::cerr << "RsQueueThread::run() done work: sleeping for: " << mLastSleep;
|
||||||
|
std::cerr << " ms";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -91,6 +105,11 @@ void RsQueueThread::run()
|
|||||||
{
|
{
|
||||||
mLastSleep = mMaxSleep;
|
mLastSleep = mMaxSleep;
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
std::cerr << "RsQueueThread::run() no work: sleeping for: " << mLastSleep;
|
||||||
|
std::cerr << " ms";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
Sleep(mLastSleep);
|
Sleep(mLastSleep);
|
||||||
|
Loading…
Reference in New Issue
Block a user