mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
More bugfixes for file transfer stuff.
* Completed 2 basic tests (ftserver1test & ftserver2test) * Updated test notes. * debugging stderr output. * fixed return code in ftfilesearch.cc * corrected ftcontroller run() to call fttransfermodule::tick() * fixed ONLINE status for OwnId (ftcontroller too) * corrected message sources for test harness. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@705 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
08285b512d
commit
7b7446c5b5
@ -12,10 +12,10 @@ RSOBJ = ftdata.o ftfileprovider.o ftfilecreator.o ftextralist.o \
|
||||
ftcontroller.o pqitestor.o
|
||||
|
||||
|
||||
TESTOBJ = ftfileprovidertest.o ftfilecreatortest.o ftextralisttest.o ftdataplextest.o ftserver1test.o
|
||||
TESTOBJ = ftfileprovidertest.o ftfilecreatortest.o ftextralisttest.o ftdataplextest.o ftserver1test.o ftserver2test.o
|
||||
|
||||
|
||||
TESTS = ftfileprovidertest ftfilecreatortest ftextralisttest ftdataplextest ftserver1test
|
||||
TESTS = ftfileprovidertest ftfilecreatortest ftextralisttest ftdataplextest ftserver1test ftserver2test
|
||||
|
||||
all: librs tests
|
||||
|
||||
@ -34,6 +34,9 @@ ftdataplextest : ftdataplextest.o
|
||||
ftserver1test : ftserver1test.o
|
||||
$(CC) $(CFLAGS) -o ftserver1test ftserver1test.o $(LIBS)
|
||||
|
||||
ftserver2test : ftserver2test.o
|
||||
$(CC) $(CFLAGS) -o ftserver2test ftserver2test.o $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -35,4 +35,20 @@ Tests.
|
||||
5) FileIndex Store loading.
|
||||
6) Basic Search.
|
||||
|
||||
ftserver2test.cc
|
||||
==================
|
||||
|
||||
Test out the ExtraList functions.
|
||||
Demonstrates the use of libretroshare/src/util/utest.h
|
||||
|
||||
Tests.
|
||||
1) Load ExtraList path OK
|
||||
2) Hashing of ExtraList File OK
|
||||
3) ExtraHashDone. OK
|
||||
4) Local Search for ExtraList Data. OK
|
||||
5) Remote Search of ExtraList (should Fail) OK
|
||||
6) Transfer of ExtraList File (Local) TODO
|
||||
7) Transfer of ExtraList File (Remote) TODO
|
||||
|
||||
|
||||
|
||||
|
@ -83,6 +83,11 @@ void ftController::setFtSearch(ftSearch *search)
|
||||
void ftController::run()
|
||||
{
|
||||
/* check the queues */
|
||||
|
||||
while(1)
|
||||
{
|
||||
sleep(1);
|
||||
|
||||
std::cerr << "ftController::run()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
@ -98,6 +103,7 @@ void ftController::run()
|
||||
(it->second.mTransfer)->tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -223,17 +229,30 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
||||
tm->setFileSources(srcIds);
|
||||
|
||||
/* get current state for transfer module */
|
||||
std::string ownId = mConnMgr->getOwnId();
|
||||
for(it = srcIds.begin(); it != srcIds.end(); it++)
|
||||
{
|
||||
if (mConnMgr->isOnline(*it))
|
||||
if (*it == ownId)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::FileRequest()";
|
||||
std::cerr << *it << " is Self - set high rate";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
//tm->setPeerState(*it, RS_FILE_RATE_FAST |
|
||||
// RS_FILE_PEER_ONLINE, 100000);
|
||||
tm->setPeerState(*it, PQIPEER_IDLE, 10000);
|
||||
}
|
||||
else if (mConnMgr->isOnline(*it))
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::FileRequest()";
|
||||
std::cerr << *it << " is Online";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
tm->setPeerState(*it, RS_FILE_RATE_TRICKLE |
|
||||
RS_FILE_PEER_ONLINE, 10000);
|
||||
//tm->setPeerState(*it, RS_FILE_RATE_TRICKLE |
|
||||
// RS_FILE_PEER_ONLINE, 10000);
|
||||
tm->setPeerState(*it, PQIPEER_IDLE, 10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -242,7 +261,8 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
||||
std::cerr << *it << " is Offline";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
tm->setPeerState(*it, RS_FILE_PEER_OFFLINE, 10000);
|
||||
//tm->setPeerState(*it, RS_FILE_PEER_OFFLINE, 10000);
|
||||
tm->setPeerState(*it, PQIPEER_NOT_ONLINE, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
const uint32_t MAX_SEARCHS = 24; /* lower 24 bits of hint */
|
||||
|
||||
#define DEBUG_SEARCH 1
|
||||
|
||||
ftFileSearch::ftFileSearch()
|
||||
:mSearchs(MAX_SEARCHS)
|
||||
{
|
||||
@ -41,8 +43,8 @@ bool ftFileSearch::addSearchMode(ftSearch *search, uint32_t hintflags)
|
||||
{
|
||||
hintflags &= 0x00ffffff;
|
||||
|
||||
#ifndef DEBUG_SEARCH
|
||||
std::cerr << "ftSearchDummy::addSearchMode() : " << hintflags;
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::addSearchMode() : " << hintflags;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -55,8 +57,8 @@ bool ftFileSearch::addSearchMode(ftSearch *search, uint32_t hintflags)
|
||||
/* has the flag */
|
||||
mSearchs[i] = search;
|
||||
|
||||
#ifndef DEBUG_SEARCH
|
||||
std::cerr << "ftSearchDummy::addSearchMode() to slot ";
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::addSearchMode() to slot ";
|
||||
std::cerr << i;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -65,8 +67,8 @@ bool ftFileSearch::addSearchMode(ftSearch *search, uint32_t hintflags)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEBUG_SEARCH
|
||||
std::cerr << "ftSearchDummy::addSearchMode() Failed";
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::addSearchMode() Failed";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -77,7 +79,7 @@ bool ftFileSearch::search(std::string hash, uint64_t size, uint32_t hintflags, F
|
||||
{
|
||||
uint32_t hints, i;
|
||||
|
||||
#ifndef DEBUG_SEARCH
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search(" << hash << ", " << size;
|
||||
std::cerr << ", " << hintflags << ");";
|
||||
std::cerr << std::endl;
|
||||
@ -92,15 +94,28 @@ bool ftFileSearch::search(std::string hash, uint64_t size, uint32_t hintflags, F
|
||||
ftSearch *search = mSearchs[i];
|
||||
if (search)
|
||||
{
|
||||
#ifndef DEBUG_SEARCH
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() SLOT: ";
|
||||
std::cerr << i;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if (search->search(hash, size, hintflags, info))
|
||||
{
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() SLOT: ";
|
||||
std::cerr << i << " success!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() SLOT: ";
|
||||
std::cerr << i << " no luck";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,15 +123,15 @@ bool ftFileSearch::search(std::string hash, uint64_t size, uint32_t hintflags, F
|
||||
/* if we haven't found it by now! - check if SPEC_ONLY flag is set */
|
||||
if (hintflags & RS_FILE_HINTS_SPEC_ONLY)
|
||||
{
|
||||
#ifndef DEBUG_SEARCH
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() SPEC_ONLY: Failed";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef DEBUG_SEARCH
|
||||
std::cerr << "ftSearchDummy::search() Searching Others:";
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() Searching Others (no SPEC ONLY):";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -136,14 +151,28 @@ bool ftFileSearch::search(std::string hash, uint64_t size, uint32_t hintflags, F
|
||||
if (search)
|
||||
{
|
||||
|
||||
#ifndef DEBUG_SEARCH
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() SLOT: " << i;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if (search->search(hash, size, hintflags, info))
|
||||
{
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() SLOT: ";
|
||||
std::cerr << i << " success!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftFileSearch::search() SLOT: ";
|
||||
std::cerr << i << " no luck";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/* found nothing */
|
||||
@ -153,7 +182,7 @@ bool ftFileSearch::search(std::string hash, uint64_t size, uint32_t hintflags, F
|
||||
|
||||
bool ftSearchDummy::search(std::string hash, uint64_t size, uint32_t hintflags, FileInfo &info) const
|
||||
{
|
||||
#ifndef DEBUG_SEARCH
|
||||
#ifdef DEBUG_SEARCH
|
||||
std::cerr << "ftSearchDummy::search(" << hash << ", " << size;
|
||||
std::cerr << ", " << hintflags << ");";
|
||||
std::cerr << std::endl;
|
||||
|
@ -119,14 +119,12 @@ void ftServer::SetupFtServer(NotifyBase *cb)
|
||||
CachePair cp(mFiMon, mFiStore, CacheId(RS_SERVICE_TYPE_FILE_INDEX, 0));
|
||||
mCacheStrapper -> addCachePair(cp);
|
||||
|
||||
|
||||
/* complete search setup */
|
||||
mFtSearch->addSearchMode(mCacheStrapper, RS_FILE_HINTS_CACHE);
|
||||
mFtSearch->addSearchMode(mFtExtra, RS_FILE_HINTS_EXTRA);
|
||||
mFtSearch->addSearchMode(mFiMon, RS_FILE_HINTS_LOCAL);
|
||||
mFtSearch->addSearchMode(mFiStore, RS_FILE_HINTS_REMOTE);
|
||||
|
||||
|
||||
mConnMgr->addMonitor(mFtController);
|
||||
mConnMgr->addMonitor(mCacheStrapper);
|
||||
|
||||
@ -257,7 +255,7 @@ bool ftServer::FileDetails(std::string hash, uint32_t hintflags, FileInfo &info)
|
||||
|
||||
if (!found)
|
||||
{
|
||||
mFtSearch->search(hash, 0, hintflags, info);
|
||||
found = mFtSearch->search(hash, 0, hintflags, info);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
376
libretroshare/src/ft/ftserver2test.cc
Normal file
376
libretroshare/src/ft/ftserver2test.cc
Normal file
@ -0,0 +1,376 @@
|
||||
/*
|
||||
* libretroshare/src/ft: ftserver1test.cc
|
||||
*
|
||||
* File Transfer for RetroShare.
|
||||
*
|
||||
* Copyright 2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* ftServer2Test - Demonstrates how to check for test stuff.
|
||||
*/
|
||||
|
||||
#include "ft/ftserver.h"
|
||||
|
||||
#include "ft/ftextralist.h"
|
||||
#include "ft/ftdatamultiplex.h"
|
||||
#include "ft/ftfilesearch.h"
|
||||
|
||||
#include "pqi/p3authmgr.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "ft/pqitestor.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/utest.h"
|
||||
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
class TestData
|
||||
{
|
||||
public:
|
||||
|
||||
ftServer *loadServer;
|
||||
std::list<ftServer *> otherServers;
|
||||
std::list<std::string> extraList;
|
||||
};
|
||||
|
||||
|
||||
extern "C" void *do_server_test_thread(void *p);
|
||||
|
||||
|
||||
void usage(char *name)
|
||||
{
|
||||
std::cerr << "Usage: " << name << " [-sa] [-p <peerId>] [-d <debugLvl>] [-e <extrafile>] [<path> [<path2> ... ]] ";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
uint32_t period = 1;
|
||||
uint32_t debugLevel = 5;
|
||||
bool debugStderr = true;
|
||||
bool loadAll = false;
|
||||
|
||||
std::list<std::string> fileList;
|
||||
std::list<std::string> extraList;
|
||||
std::list<std::string> peerIds;
|
||||
std::map<std::string, ftServer *> mFtServers;
|
||||
std::map<std::string, p3ConnectMgr *> mConnMgrs;
|
||||
|
||||
ftServer *mLoadServer = NULL;
|
||||
std::list<ftServer *> mOtherServers;
|
||||
std::list<std::string>::iterator eit;
|
||||
|
||||
while(-1 != (c = getopt(argc, argv, "asd:p:e:")))
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'p':
|
||||
peerIds.push_back(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
debugLevel = atoi(optarg);
|
||||
break;
|
||||
case 's':
|
||||
debugStderr = true;
|
||||
break;
|
||||
case 'e':
|
||||
extraList.push_back(optarg);
|
||||
break;
|
||||
case 'a':
|
||||
loadAll = true;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* do logging */
|
||||
setOutputLevel(debugLevel);
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
std::cerr << "Missing Shared Directories" << std::endl;
|
||||
usage(argv[0]);
|
||||
}
|
||||
|
||||
for(; optind < argc; optind++)
|
||||
{
|
||||
std::cerr << "Adding: " << argv[optind] << std::endl;
|
||||
fileList.push_back(std::string(argv[optind]));
|
||||
}
|
||||
|
||||
/* We need to setup a series 2 - 4 different ftServers....
|
||||
*
|
||||
* Each one needs:
|
||||
*
|
||||
*
|
||||
* A List of peerIds...
|
||||
*/
|
||||
|
||||
std::list<std::string>::const_iterator it, jit;
|
||||
|
||||
std::list<pqiAuthDetails> baseFriendList, friendList;
|
||||
std::list<pqiAuthDetails>::iterator fit;
|
||||
|
||||
P3Hub *testHub = new P3Hub();
|
||||
testHub->start();
|
||||
|
||||
/* Setup Base Friend Info */
|
||||
for(it = peerIds.begin(); it != peerIds.end(); it++)
|
||||
{
|
||||
pqiAuthDetails pad;
|
||||
pad.id = *it;
|
||||
pad.name = *it;
|
||||
pad.trustLvl = 5;
|
||||
pad.ownsign = true;
|
||||
pad.trusted = false;
|
||||
|
||||
baseFriendList.push_back(pad);
|
||||
|
||||
std::cerr << "ftserver1test::setup peer: " << *it;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
std::ostringstream pname;
|
||||
pname << "/tmp/rstst-" << time(NULL);
|
||||
|
||||
std::string basepath = pname.str();
|
||||
RsDirUtil::checkCreateDirectory(basepath);
|
||||
|
||||
|
||||
|
||||
for(it = peerIds.begin(); it != peerIds.end(); it++)
|
||||
{
|
||||
friendList = baseFriendList;
|
||||
/* remove current one */
|
||||
for(fit = friendList.begin(); fit != friendList.end(); fit++)
|
||||
{
|
||||
if (fit->id == *it)
|
||||
{
|
||||
friendList.erase(fit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
p3AuthMgr *authMgr = new p3DummyAuthMgr(*it, friendList);
|
||||
p3ConnectMgr *connMgr = new p3ConnectMgr(authMgr);
|
||||
mConnMgrs[*it] = connMgr;
|
||||
|
||||
|
||||
for(fit = friendList.begin(); fit != friendList.end(); fit++)
|
||||
{
|
||||
/* add as peer to authMgr */
|
||||
connMgr->addFriend(fit->id);
|
||||
}
|
||||
|
||||
P3Pipe *pipe = new P3Pipe(); //(*it);
|
||||
|
||||
/* add server */
|
||||
ftServer *server;
|
||||
server = new ftServer(authMgr, connMgr);
|
||||
mFtServers[*it] = server;
|
||||
if (!mLoadServer)
|
||||
{
|
||||
mLoadServer = server;
|
||||
}
|
||||
else
|
||||
{
|
||||
mOtherServers.push_back(server);
|
||||
}
|
||||
|
||||
|
||||
server->setP3Interface(pipe);
|
||||
|
||||
std::string configpath = basepath + "/" + *it;
|
||||
RsDirUtil::checkCreateDirectory(configpath);
|
||||
|
||||
std::string cachepath = configpath + "/cache";
|
||||
RsDirUtil::checkCreateDirectory(cachepath);
|
||||
|
||||
std::string localpath = cachepath + "/local";
|
||||
RsDirUtil::checkCreateDirectory(localpath);
|
||||
|
||||
std::string remotepath = cachepath + "/remote";
|
||||
RsDirUtil::checkCreateDirectory(remotepath);
|
||||
|
||||
server->setConfigDirectory(configpath);
|
||||
|
||||
NotifyBase *base = NULL;
|
||||
server->SetupFtServer(base);
|
||||
|
||||
testHub->addP3Pipe(*it, pipe, connMgr);
|
||||
server->StartupThreads();
|
||||
|
||||
/* setup any extra bits */
|
||||
if (loadAll)
|
||||
{
|
||||
server->setSharedDirectories(fileList);
|
||||
for(eit = extraList.begin(); eit != extraList.end(); eit++)
|
||||
{
|
||||
server->ExtraFileHash(*eit, 3600, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (mLoadServer)
|
||||
{
|
||||
mLoadServer->setSharedDirectories(fileList);
|
||||
for(eit = extraList.begin(); eit != extraList.end(); eit++)
|
||||
{
|
||||
mLoadServer->ExtraFileHash(*eit, 3600, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* stick your real test here */
|
||||
std::map<std::string, ftServer *>::iterator sit;
|
||||
std::map<std::string, p3ConnectMgr *>::iterator cit;
|
||||
|
||||
/* Start up test thread */
|
||||
pthread_t tid;
|
||||
TestData *mFt = new TestData;
|
||||
|
||||
/* set data */
|
||||
mFt->loadServer = mLoadServer;
|
||||
mFt->otherServers = mOtherServers;
|
||||
mFt->extraList = extraList;
|
||||
|
||||
void *data = (void *) mFt;
|
||||
pthread_create(&tid, 0, &do_server_test_thread, data);
|
||||
pthread_detach(tid); /* so memory is reclaimed in linux */
|
||||
|
||||
while(1)
|
||||
{
|
||||
std::cerr << "ftserver2test::sleep()";
|
||||
std::cerr << std::endl;
|
||||
sleep(1);
|
||||
|
||||
/* tick the connmgrs */
|
||||
for(sit = mFtServers.begin(); sit != mFtServers.end(); sit++)
|
||||
{
|
||||
/* update */
|
||||
(sit->second)->tick();
|
||||
}
|
||||
|
||||
for(cit = mConnMgrs.begin(); cit != mConnMgrs.end(); cit++)
|
||||
{
|
||||
/* update */
|
||||
(cit->second)->tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* So our actual test can run here.....
|
||||
*
|
||||
*/
|
||||
|
||||
INITTEST();
|
||||
|
||||
void *do_server_test_thread(void *data)
|
||||
{
|
||||
TestData *mFt = (TestData *) data;
|
||||
|
||||
std::cerr << "do_server_test_thread() running";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/************************* TEST 1 **********************
|
||||
* Check that the extra List has been processed.
|
||||
*/
|
||||
time_t start = time(NULL);
|
||||
|
||||
FileInfo info, info2;
|
||||
time_t now = time(NULL);
|
||||
std::list<std::string>::iterator eit;
|
||||
for(eit = mFt->extraList.begin(); eit != mFt->extraList.end(); eit++)
|
||||
{
|
||||
while(!mFt->loadServer->ExtraFileStatus(*eit, info))
|
||||
{
|
||||
|
||||
/* max of 30 seconds */
|
||||
now = time(NULL);
|
||||
if (now - start > 30)
|
||||
{
|
||||
/* FAIL */
|
||||
REPORT2( false, "Extra File Hashing");
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
/* Got ExtraFileStatus */
|
||||
REPORT("Successfully Found ExtraFile");
|
||||
|
||||
/* now we can try a search (should succeed) */
|
||||
uint32_t hintflags = 0;
|
||||
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
|
||||
{
|
||||
CHECK(info2.hash == info.hash);
|
||||
CHECK(info2.size == info.size);
|
||||
CHECK(info2.fname == info.fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
REPORT2( false, "Search for Extra File (Basic)");
|
||||
}
|
||||
|
||||
/* search with flags (should succeed) */
|
||||
hintflags = RS_FILE_HINTS_EXTRA;
|
||||
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
|
||||
{
|
||||
CHECK(info2.hash == info.hash);
|
||||
CHECK(info2.size == info.size);
|
||||
CHECK(info2.fname == info.fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
REPORT2( false, "Search for Extra File (Extra Flag)");
|
||||
}
|
||||
|
||||
/* search with other flags (should fail) */
|
||||
hintflags = RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY;
|
||||
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
|
||||
{
|
||||
REPORT2( false, "Search for Extra File (Fail Flags)");
|
||||
}
|
||||
else
|
||||
{
|
||||
REPORT("Search for Extra File (Fail Flags)");
|
||||
}
|
||||
|
||||
/* if we try to download it ... should just find existing one*/
|
||||
|
||||
REPORT("Testing with Extra File");
|
||||
}
|
||||
|
||||
FINALREPORT("ExtraList Hashing, Searching and Downloading");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -131,16 +131,32 @@ bool ftTransferModule::recvFileData(std::string peerId, uint64_t offset,
|
||||
|
||||
void ftTransferModule::requestData(std::string peerId, uint64_t offset, uint32_t chunk_size)
|
||||
{
|
||||
std::cerr << "ftTransferModule::requestData()";
|
||||
std::cerr << " peerId: " << peerId;
|
||||
std::cerr << " offset: " << offset;
|
||||
std::cerr << " chunk_size: " << chunk_size;
|
||||
std::cerr << std::endl;
|
||||
|
||||
mMultiplexor->sendDataRequest(peerId, mHash, mSize, offset,chunk_size);
|
||||
}
|
||||
|
||||
bool ftTransferModule::getChunk(uint64_t &offset, uint32_t &chunk_size)
|
||||
{
|
||||
std::cerr << "ftTransferModule::getChunk()";
|
||||
std::cerr << " offset: " << offset;
|
||||
std::cerr << " chunk_size: " << chunk_size;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return mFileCreator->getMissingChunk(offset, chunk_size);
|
||||
}
|
||||
|
||||
bool ftTransferModule::storeData(uint64_t offset, uint32_t chunk_size,void *data)
|
||||
{
|
||||
std::cerr << "ftTransferModule::storeData()";
|
||||
std::cerr << " offset: " << offset;
|
||||
std::cerr << " chunk_size: " << chunk_size;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return mFileCreator -> addFileData(offset, chunk_size, data);
|
||||
}
|
||||
|
||||
@ -150,6 +166,7 @@ void ftTransferModule::queryInactive()
|
||||
std::ostringstream out;
|
||||
out<<"ftTransferModule::queryInactive()";
|
||||
out<<std:endl;
|
||||
std::cerr << out.str();
|
||||
#endif
|
||||
|
||||
int ts = time(NULL);
|
||||
|
@ -55,8 +55,8 @@ void P3Hub::addP3Pipe(std::string id, P3Pipe *pqi, p3ConnectMgr *mgr)
|
||||
void P3Hub::run()
|
||||
{
|
||||
RsItem *item;
|
||||
std::list<RsItem *> recvdQ;
|
||||
std::list<RsItem *>::iterator lit;
|
||||
std::list<std::pair<std::string, RsItem *> > recvdQ;
|
||||
std::list<std::pair<std::string, RsItem *> >::iterator lit;
|
||||
while(1)
|
||||
{
|
||||
std::cerr << "P3Hub::run()";
|
||||
@ -73,26 +73,38 @@ void P3Hub::run()
|
||||
item->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
|
||||
recvdQ.push_back(item);
|
||||
|
||||
recvdQ.push_back(make_pair(it->first, item));
|
||||
}
|
||||
}
|
||||
|
||||
/* now send out */
|
||||
for(lit = recvdQ.begin(); lit != recvdQ.end(); lit++)
|
||||
{
|
||||
std::string pId = (*lit)->PeerId();
|
||||
if (mPeers.end() == (it = mPeers.find(pId)))
|
||||
std::string srcId = lit->first;
|
||||
std::string destId = (lit->second)->PeerId();
|
||||
if (mPeers.end() == (it = mPeers.find(destId)))
|
||||
{
|
||||
std::cerr << "Failed to Find destination: " << pId;
|
||||
std::cerr << "Failed to Find destination: " << destId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Deleting Packet";
|
||||
std::cerr << std::endl;
|
||||
|
||||
delete (lit->second);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* now we have dest, set source Id */
|
||||
(lit->second)->PeerId(srcId);
|
||||
std::cerr << "P3Hub::run() sending msg to: ";
|
||||
std::cerr << it->first;
|
||||
std::cerr << std::endl;
|
||||
(*lit)->print(std::cerr, 10);
|
||||
(lit->second)->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
|
||||
(it->second).mPQI->PushRecvdItem(*lit);
|
||||
(it->second).mPQI->PushRecvdItem(lit->second);
|
||||
}
|
||||
}
|
||||
|
||||
recvdQ.clear();
|
||||
|
@ -1211,6 +1211,9 @@ bool p3ConnectMgr::isOnline(std::string id)
|
||||
std::cerr << "p3ConnectMgr::isOnline(" << id;
|
||||
std::cerr << ") is Not Friend";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3ConnectMgr::isOnline() OwnId: ";
|
||||
std::cerr << mAuthMgr->OwnId();
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* not a friend */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user