mirror of https://github.com/aria2/aria2
2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Untabify. Fixed one line in copyright which is longer than 80 columns. * src * testpull/1/head
parent
338e8aca09
commit
4db349c1f3
|
@ -1,3 +1,10 @@
|
|||
2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Untabify. Fixed one line in copyright which is longer than 80
|
||||
columns.
|
||||
* src
|
||||
* test
|
||||
|
||||
2009-12-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Release 1.8.0
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
void init(const unsigned char* key, size_t keyLength) {}
|
||||
|
||||
void decrypt(unsigned char* out, size_t outLength,
|
||||
const unsigned char* in, size_t inLength) {}
|
||||
const unsigned char* in, size_t inLength) {}
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
void init(const unsigned char* key, size_t keyLength) {}
|
||||
|
||||
void encrypt(unsigned char* out, size_t outLength,
|
||||
const unsigned char* in, size_t inLength) {}
|
||||
const unsigned char* in, size_t inLength) {}
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -68,11 +68,11 @@
|
|||
namespace aria2 {
|
||||
|
||||
AbstractCommand::AbstractCommand(int32_t cuid,
|
||||
const SharedHandle<Request>& req,
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const SocketHandle& s):
|
||||
const SharedHandle<Request>& req,
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const SocketHandle& s):
|
||||
Command(cuid), _requestGroup(requestGroup),
|
||||
req(req), _fileEntry(fileEntry), e(e), socket(s),
|
||||
checkSocketIsReadable(false), checkSocketIsWritable(false),
|
||||
|
@ -98,7 +98,7 @@ AbstractCommand::~AbstractCommand() {
|
|||
|
||||
bool AbstractCommand::execute() {
|
||||
logger->debug("CUID#%d - socket: read:%d, write:%d, hup:%d, err:%d",
|
||||
cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent);
|
||||
cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent);
|
||||
try {
|
||||
if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) {
|
||||
//logger->debug("CUID#%d - finished.", cuid);
|
||||
|
@ -110,19 +110,19 @@ bool AbstractCommand::execute() {
|
|||
!_requestGroup->getPieceStorage()->hasMissingUnusedPiece()) {
|
||||
SharedHandle<Request> fasterRequest = _fileEntry->findFasterRequest(req);
|
||||
if(!fasterRequest.isNull()) {
|
||||
logger->info("CUID#%d - Use faster Request hostname=%s, port=%u",
|
||||
cuid,
|
||||
fasterRequest->getHost().c_str(),
|
||||
fasterRequest->getPort());
|
||||
logger->info("CUID#%d - Use faster Request hostname=%s, port=%u",
|
||||
cuid,
|
||||
fasterRequest->getHost().c_str(),
|
||||
fasterRequest->getPort());
|
||||
|
||||
// Cancel current Request object and use faster one.
|
||||
_fileEntry->removeRequest(req);
|
||||
Command* command =
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(cuid, fasterRequest, _fileEntry, _requestGroup, e);
|
||||
e->setNoWait(true);
|
||||
e->commands.push_back(command);
|
||||
return true;
|
||||
// Cancel current Request object and use faster one.
|
||||
_fileEntry->removeRequest(req);
|
||||
Command* command =
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(cuid, fasterRequest, _fileEntry, _requestGroup, e);
|
||||
e->setNoWait(true);
|
||||
e->commands.push_back(command);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if((checkSocketIsReadable && _readEvent) ||
|
||||
|
@ -134,54 +134,54 @@ bool AbstractCommand::execute() {
|
|||
(!checkSocketIsReadable && !checkSocketIsWritable && !nameResolverCheck)) {
|
||||
checkPoint.reset();
|
||||
if(!_requestGroup->getPieceStorage().isNull()) {
|
||||
_segments.clear();
|
||||
_requestGroup->getSegmentMan()->getInFlightSegment(_segments, cuid);
|
||||
if(req.isNull() || req->getMaxPipelinedRequest() == 1 ||
|
||||
_requestGroup->getDownloadContext()->getFileEntries().size() == 1) {
|
||||
if(_segments.empty()) {
|
||||
SharedHandle<Segment> segment =
|
||||
_requestGroup->getSegmentMan()->getSegment(cuid);
|
||||
if(!segment.isNull()) {
|
||||
_segments.push_back(segment);
|
||||
}
|
||||
}
|
||||
if(_segments.empty()) {
|
||||
// TODO socket could be pooled here if pipelining is enabled...
|
||||
logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid);
|
||||
// When all segments are ignored in SegmentMan, there are
|
||||
// no URIs available, so don't retry.
|
||||
if(_requestGroup->getSegmentMan()->allSegmentsIgnored()) {
|
||||
return true;
|
||||
} else {
|
||||
return prepareForRetry(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
size_t maxSegments = req->getMaxPipelinedRequest();
|
||||
if(_segments.size() < maxSegments) {
|
||||
_requestGroup->getSegmentMan()->getSegment
|
||||
(_segments, cuid, _fileEntry, maxSegments);
|
||||
}
|
||||
if(_segments.empty()) {
|
||||
return prepareForRetry(0);
|
||||
}
|
||||
}
|
||||
_segments.clear();
|
||||
_requestGroup->getSegmentMan()->getInFlightSegment(_segments, cuid);
|
||||
if(req.isNull() || req->getMaxPipelinedRequest() == 1 ||
|
||||
_requestGroup->getDownloadContext()->getFileEntries().size() == 1) {
|
||||
if(_segments.empty()) {
|
||||
SharedHandle<Segment> segment =
|
||||
_requestGroup->getSegmentMan()->getSegment(cuid);
|
||||
if(!segment.isNull()) {
|
||||
_segments.push_back(segment);
|
||||
}
|
||||
}
|
||||
if(_segments.empty()) {
|
||||
// TODO socket could be pooled here if pipelining is enabled...
|
||||
logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid);
|
||||
// When all segments are ignored in SegmentMan, there are
|
||||
// no URIs available, so don't retry.
|
||||
if(_requestGroup->getSegmentMan()->allSegmentsIgnored()) {
|
||||
return true;
|
||||
} else {
|
||||
return prepareForRetry(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
size_t maxSegments = req->getMaxPipelinedRequest();
|
||||
if(_segments.size() < maxSegments) {
|
||||
_requestGroup->getSegmentMan()->getSegment
|
||||
(_segments, cuid, _fileEntry, maxSegments);
|
||||
}
|
||||
if(_segments.empty()) {
|
||||
return prepareForRetry(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return executeInternal();
|
||||
} else if(_errorEvent) {
|
||||
throw DL_RETRY_EX
|
||||
(StringFormat(MSG_NETWORK_PROBLEM,
|
||||
socket->getSocketError().c_str()).str());
|
||||
(StringFormat(MSG_NETWORK_PROBLEM,
|
||||
socket->getSocketError().c_str()).str());
|
||||
} else {
|
||||
if(checkPoint.elapsed(timeout)) {
|
||||
// timeout triggers ServerStat error state.
|
||||
// timeout triggers ServerStat error state.
|
||||
|
||||
SharedHandle<ServerStat> ss =
|
||||
e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
|
||||
req->getProtocol());
|
||||
ss->setError();
|
||||
SharedHandle<ServerStat> ss =
|
||||
e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
|
||||
req->getProtocol());
|
||||
ss->setError();
|
||||
|
||||
throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
|
||||
throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
|
||||
}
|
||||
e->commands.push_back(this);
|
||||
return false;
|
||||
|
@ -191,9 +191,9 @@ bool AbstractCommand::execute() {
|
|||
logger->debug(EX_EXCEPTION_CAUGHT, err);
|
||||
} else {
|
||||
logger->error(MSG_DOWNLOAD_ABORTED,
|
||||
DL_ABORT_EX2(StringFormat
|
||||
("URI=%s", req->getCurrentUrl().c_str()).str(),err),
|
||||
cuid, req->getUrl().c_str());
|
||||
DL_ABORT_EX2(StringFormat
|
||||
("URI=%s", req->getCurrentUrl().c_str()).str(),err),
|
||||
cuid, req->getUrl().c_str());
|
||||
_fileEntry->addURIResult(req->getUrl(), err.getCode());
|
||||
_requestGroup->setLastUriResult(req->getUrl(), err.getCode());
|
||||
}
|
||||
|
@ -203,9 +203,9 @@ bool AbstractCommand::execute() {
|
|||
} catch(DlRetryEx& err) {
|
||||
assert(!req.isNull());
|
||||
logger->info(MSG_RESTARTING_DOWNLOAD,
|
||||
DL_RETRY_EX2(StringFormat
|
||||
("URI=%s", req->getCurrentUrl().c_str()).str(),err),
|
||||
cuid, req->getUrl().c_str());
|
||||
DL_RETRY_EX2(StringFormat
|
||||
("URI=%s", req->getCurrentUrl().c_str()).str(),err),
|
||||
cuid, req->getUrl().c_str());
|
||||
req->addTryCount();
|
||||
req->resetRedirectCount();
|
||||
const unsigned int maxTries = getOption()->getAsInt(PREF_MAX_TRIES);
|
||||
|
@ -241,8 +241,8 @@ void AbstractCommand::tryReserved() {
|
|||
// can assume that there are no in-flight request object.
|
||||
if(entry->getLength() == 0 && entry->getRemainingUris().empty()) {
|
||||
logger->debug("CUID#%d - Not trying next request."
|
||||
" No reserved/pooled request is remaining and"
|
||||
" total length is still unknown.", cuid);
|
||||
" No reserved/pooled request is remaining and"
|
||||
" total length is still unknown.", cuid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
|
|||
if(!req.isNull()) {
|
||||
_fileEntry->poolRequest(req);
|
||||
logger->debug("CUID#%d - Pooling request URI=%s",
|
||||
cuid, req->getUrl().c_str());
|
||||
cuid, req->getUrl().c_str());
|
||||
if(!_requestGroup->getSegmentMan().isNull()) {
|
||||
_requestGroup->getSegmentMan()->recognizeSegmentFor(_fileEntry);
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
|
|||
e->commands.push_back(command);
|
||||
} else {
|
||||
SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup,
|
||||
command, wait);
|
||||
command, wait);
|
||||
e->commands.push_back(scom);
|
||||
}
|
||||
return true;
|
||||
|
@ -282,7 +282,7 @@ void AbstractCommand::onAbort() {
|
|||
if(!req.isNull()) {
|
||||
// TODO This might be a problem if the failure is caused by proxy.
|
||||
e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
|
||||
req->getProtocol())->setError();
|
||||
req->getProtocol())->setError();
|
||||
_fileEntry->removeIdenticalURI(req->getUrl());
|
||||
_fileEntry->removeRequest(req);
|
||||
}
|
||||
|
@ -307,9 +307,9 @@ void AbstractCommand::setReadCheckSocket(const SocketHandle& socket) {
|
|||
} else {
|
||||
if(checkSocketIsReadable) {
|
||||
if(readCheckTarget != socket) {
|
||||
e->deleteSocketForReadCheck(readCheckTarget, this);
|
||||
e->addSocketForReadCheck(socket, this);
|
||||
readCheckTarget = socket;
|
||||
e->deleteSocketForReadCheck(readCheckTarget, this);
|
||||
e->addSocketForReadCheck(socket, this);
|
||||
readCheckTarget = socket;
|
||||
}
|
||||
} else {
|
||||
e->addSocketForReadCheck(socket, this);
|
||||
|
@ -343,9 +343,9 @@ void AbstractCommand::setWriteCheckSocket(const SocketHandle& socket) {
|
|||
} else {
|
||||
if(checkSocketIsWritable) {
|
||||
if(writeCheckTarget != socket) {
|
||||
e->deleteSocketForWriteCheck(writeCheckTarget, this);
|
||||
e->addSocketForWriteCheck(socket, this);
|
||||
writeCheckTarget = socket;
|
||||
e->deleteSocketForWriteCheck(writeCheckTarget, this);
|
||||
e->addSocketForWriteCheck(socket, this);
|
||||
writeCheckTarget = socket;
|
||||
}
|
||||
} else {
|
||||
e->addSocketForWriteCheck(socket, this);
|
||||
|
@ -366,7 +366,7 @@ void AbstractCommand::setWriteCheckSocketIf
|
|||
}
|
||||
|
||||
static const std::string& getProxyStringFor(const std::string& proxyPref,
|
||||
const SharedHandle<Option>& option)
|
||||
const SharedHandle<Option>& option)
|
||||
{
|
||||
if(option->defined(proxyPref)) {
|
||||
return option->get(proxyPref);
|
||||
|
@ -376,7 +376,7 @@ static const std::string& getProxyStringFor(const std::string& proxyPref,
|
|||
}
|
||||
|
||||
static bool isProxyUsed(const std::string& proxyPref,
|
||||
const SharedHandle<Option>& option)
|
||||
const SharedHandle<Option>& option)
|
||||
{
|
||||
std::string proxy = getProxyStringFor(proxyPref, option);
|
||||
if(proxy.empty()) {
|
||||
|
@ -387,7 +387,7 @@ static bool isProxyUsed(const std::string& proxyPref,
|
|||
}
|
||||
|
||||
static bool isProxyRequest(const std::string& protocol,
|
||||
const SharedHandle<Option>& option)
|
||||
const SharedHandle<Option>& option)
|
||||
{
|
||||
return
|
||||
(protocol == Request::PROTO_HTTP && isProxyUsed(PREF_HTTP_PROXY, option)) ||
|
||||
|
@ -412,7 +412,7 @@ public:
|
|||
};
|
||||
|
||||
static bool inNoProxy(const SharedHandle<Request>& req,
|
||||
const std::string& noProxy)
|
||||
const std::string& noProxy)
|
||||
{
|
||||
std::vector<std::string> entries;
|
||||
util::split(noProxy, std::back_inserter(entries), ",", true);
|
||||
|
@ -421,7 +421,7 @@ static bool inNoProxy(const SharedHandle<Request>& req,
|
|||
}
|
||||
return
|
||||
std::find_if(entries.begin(), entries.end(),
|
||||
DomainMatch("."+req->getHost())) != entries.end();
|
||||
DomainMatch("."+req->getHost())) != entries.end();
|
||||
}
|
||||
|
||||
bool AbstractCommand::isProxyDefined() const
|
||||
|
@ -431,7 +431,7 @@ bool AbstractCommand::isProxyDefined() const
|
|||
}
|
||||
|
||||
static const std::string& getProxyString(const SharedHandle<Request>& req,
|
||||
const SharedHandle<Option>& option)
|
||||
const SharedHandle<Option>& option)
|
||||
{
|
||||
if(req->getProtocol() == Request::PROTO_HTTP) {
|
||||
return getProxyStringFor(PREF_HTTP_PROXY, option);
|
||||
|
@ -486,11 +486,11 @@ bool AbstractCommand::asyncResolveHostname()
|
|||
case AsyncNameResolver::STATUS_ERROR:
|
||||
if(!isProxyRequest(req->getProtocol(), getOption())) {
|
||||
e->_requestGroupMan->getOrCreateServerStat
|
||||
(req->getHost(), req->getProtocol())->setError();
|
||||
(req->getHost(), req->getProtocol())->setError();
|
||||
}
|
||||
throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED, cuid,
|
||||
_asyncNameResolver->getHostname().c_str(),
|
||||
_asyncNameResolver->getError().c_str()).str());
|
||||
_asyncNameResolver->getHostname().c_str(),
|
||||
_asyncNameResolver->getError().c_str()).str());
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -548,24 +548,24 @@ bool AbstractCommand::checkIfConnectionEstablished
|
|||
// See also InitiateConnectionCommand::executeInternal()
|
||||
e->markBadIPAddress(connectedHostname, connectedAddr, connectedPort);
|
||||
if(!e->findCachedIPAddress(connectedHostname, connectedPort).empty()) {
|
||||
logger->info(MSG_CONNECT_FAILED_AND_RETRY,
|
||||
cuid, connectedAddr.c_str(), connectedPort);
|
||||
Command* command =
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(cuid, req, _fileEntry, _requestGroup, e);
|
||||
e->setNoWait(true);
|
||||
e->commands.push_back(command);
|
||||
return false;
|
||||
logger->info(MSG_CONNECT_FAILED_AND_RETRY,
|
||||
cuid, connectedAddr.c_str(), connectedPort);
|
||||
Command* command =
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(cuid, req, _fileEntry, _requestGroup, e);
|
||||
e->setNoWait(true);
|
||||
e->commands.push_back(command);
|
||||
return false;
|
||||
}
|
||||
e->removeCachedIPAddress(connectedHostname, connectedPort);
|
||||
// Don't set error if proxy server is used and its method is GET.
|
||||
if(resolveProxyMethod(req->getProtocol()) != V_GET ||
|
||||
!isProxyRequest(req->getProtocol(), getOption())) {
|
||||
e->_requestGroupMan->getOrCreateServerStat
|
||||
(req->getHost(), req->getProtocol())->setError();
|
||||
!isProxyRequest(req->getProtocol(), getOption())) {
|
||||
e->_requestGroupMan->getOrCreateServerStat
|
||||
(req->getHost(), req->getProtocol())->setError();
|
||||
}
|
||||
throw DL_RETRY_EX
|
||||
(StringFormat(MSG_ESTABLISHING_CONNECTION_FAILED, error.c_str()).str());
|
||||
(StringFormat(MSG_ESTABLISHING_CONNECTION_FAILED, error.c_str()).str());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -153,9 +153,9 @@ private:
|
|||
#endif // ENABLE_ASYNC_DNS
|
||||
public:
|
||||
AbstractCommand(int32_t cuid, const SharedHandle<Request>& req,
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup, DownloadEngine* e,
|
||||
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>());
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup, DownloadEngine* e,
|
||||
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>());
|
||||
|
||||
virtual ~AbstractCommand();
|
||||
bool execute();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -110,9 +110,9 @@ void AbstractDiskWriter::createFile(int addFlags)
|
|||
assert(!_filename.empty());
|
||||
util::mkdirs(File(_filename).getDirname());
|
||||
if((fd = open(_filename.c_str(), O_CREAT|O_RDWR|O_TRUNC|O_BINARY|addFlags,
|
||||
OPEN_MODE)) < 0) {
|
||||
OPEN_MODE)) < 0) {
|
||||
throw DL_ABORT_EX(StringFormat(EX_FILE_OPEN,
|
||||
_filename.c_str(), strerror(errno)).str());
|
||||
_filename.c_str(), strerror(errno)).str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,10 +153,10 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len, off_t
|
|||
// DownloadFailureException and abort download instantly.
|
||||
if(errno == ENOSPC) {
|
||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||
(StringFormat(EX_FILE_WRITE, _filename.c_str(), strerror(errno)).str());
|
||||
(StringFormat(EX_FILE_WRITE, _filename.c_str(), strerror(errno)).str());
|
||||
}
|
||||
throw DL_ABORT_EX(StringFormat(EX_FILE_WRITE,
|
||||
_filename.c_str(), strerror(errno)).str());
|
||||
_filename.c_str(), strerror(errno)).str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len, off_t offs
|
|||
seek(offset);
|
||||
if((ret = readDataInternal(data, len)) < 0) {
|
||||
throw DL_ABORT_EX(StringFormat(EX_FILE_READ,
|
||||
_filename.c_str(), strerror(errno)).str());
|
||||
_filename.c_str(), strerror(errno)).str());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -183,12 +183,12 @@ void AbstractDiskWriter::truncate(uint64_t length)
|
|||
seek(length);
|
||||
if(SetEndOfFile(handle) == 0) {
|
||||
throw DL_ABORT_EX(StringFormat("SetEndOfFile failed. cause: %s",
|
||||
GetLastError()).str());
|
||||
GetLastError()).str());
|
||||
}
|
||||
#else
|
||||
if(ftruncate(fd, length) == -1) {
|
||||
throw DL_ABORT_EX(StringFormat("ftruncate failed. cause: %s",
|
||||
strerror(errno)).str());
|
||||
strerror(errno)).str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void AbstractDiskWriter::allocate(off_t offset, uint64_t length)
|
|||
int r = posix_fallocate(fd, offset, length);
|
||||
if(r != 0) {
|
||||
throw DL_ABORT_EX(StringFormat("posix_fallocate failed. cause: %s",
|
||||
strerror(r)).str());
|
||||
strerror(r)).str());
|
||||
}
|
||||
}
|
||||
#endif // HAVE_POSIX_FALLOCATE
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -55,12 +55,12 @@ protected:
|
|||
virtual bool executeInternal();
|
||||
public:
|
||||
AbstractProxyRequestCommand(int cuid,
|
||||
const SharedHandle<Request>& req,
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const SharedHandle<Request>& proxyRequest,
|
||||
const SharedHandle<SocketCore>& s);
|
||||
const SharedHandle<Request>& req,
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const SharedHandle<Request>& proxyRequest,
|
||||
const SharedHandle<SocketCore>& s);
|
||||
|
||||
virtual ~AbstractProxyRequestCommand();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -103,7 +103,7 @@ FileAllocationIteratorHandle AbstractSingleDiskAdaptor::fileAllocationIterator()
|
|||
#endif // HAVE_POSIX_FALLOCATE
|
||||
{
|
||||
SingleFileAllocationIteratorHandle h
|
||||
(new SingleFileAllocationIterator(this, size(), totalLength));
|
||||
(new SingleFileAllocationIterator(this, size(), totalLength));
|
||||
h->init();
|
||||
return h;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
virtual void openExistingFile();
|
||||
|
||||
virtual void writeData(const unsigned char* data, size_t len,
|
||||
off_t offset);
|
||||
off_t offset);
|
||||
|
||||
virtual ssize_t readData(unsigned char* data, size_t len, off_t offset);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -86,7 +86,7 @@ bool ActivePeerConnectionCommand::execute() {
|
|||
if(_requestGroup->getDownloadContext()->
|
||||
getAttribute(bittorrent::BITTORRENT).containsKey(bittorrent::METADATA)) {
|
||||
thresholdSpeed =
|
||||
_requestGroup->getOption()->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT);
|
||||
_requestGroup->getOption()->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT);
|
||||
} else {
|
||||
thresholdSpeed = 0;
|
||||
}
|
||||
|
@ -95,31 +95,31 @@ bool ActivePeerConnectionCommand::execute() {
|
|||
}
|
||||
if(// for seeder state
|
||||
(_pieceStorage->downloadFinished() && _btRuntime->lessThanMaxPeers() &&
|
||||
(maxUploadLimit == 0 || tstat.getUploadSpeed() < maxUploadLimit*0.8)) ||
|
||||
(maxUploadLimit == 0 || tstat.getUploadSpeed() < maxUploadLimit*0.8)) ||
|
||||
// for leecher state
|
||||
(!_pieceStorage->downloadFinished() &&
|
||||
(tstat.getDownloadSpeed() < thresholdSpeed ||
|
||||
_btRuntime->lessThanMinPeers()))) {
|
||||
(tstat.getDownloadSpeed() < thresholdSpeed ||
|
||||
_btRuntime->lessThanMinPeers()))) {
|
||||
|
||||
unsigned int numConnection = 0;
|
||||
if(_pieceStorage->downloadFinished()) {
|
||||
if(_btRuntime->getMaxPeers() > _btRuntime->getConnections()) {
|
||||
numConnection =
|
||||
std::min(_numNewConnection,
|
||||
_btRuntime->getMaxPeers()-_btRuntime->getConnections());
|
||||
}
|
||||
if(_btRuntime->getMaxPeers() > _btRuntime->getConnections()) {
|
||||
numConnection =
|
||||
std::min(_numNewConnection,
|
||||
_btRuntime->getMaxPeers()-_btRuntime->getConnections());
|
||||
}
|
||||
} else {
|
||||
numConnection = _numNewConnection;
|
||||
numConnection = _numNewConnection;
|
||||
}
|
||||
|
||||
for(unsigned int numAdd = numConnection;
|
||||
numAdd > 0 && _peerStorage->isPeerAvailable(); --numAdd) {
|
||||
PeerHandle peer = _peerStorage->getUnusedPeer();
|
||||
connectToPeer(peer);
|
||||
numAdd > 0 && _peerStorage->isPeerAvailable(); --numAdd) {
|
||||
PeerHandle peer = _peerStorage->getUnusedPeer();
|
||||
connectToPeer(peer);
|
||||
}
|
||||
if(_btRuntime->getConnections() == 0 &&
|
||||
!_pieceStorage->downloadFinished()) {
|
||||
_btAnnounce->overrideMinInterval(BtAnnounce::DEFAULT_ANNOUNCE_INTERVAL);
|
||||
!_pieceStorage->downloadFinished()) {
|
||||
_btAnnounce->overrideMinInterval(BtAnnounce::DEFAULT_ANNOUNCE_INTERVAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,12 +135,12 @@ void ActivePeerConnectionCommand::connectToPeer(const PeerHandle& peer)
|
|||
peer->usedBy(e->newCUID());
|
||||
PeerInitiateConnectionCommand* command =
|
||||
new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e,
|
||||
_btRuntime);
|
||||
_btRuntime);
|
||||
command->setPeerStorage(_peerStorage);
|
||||
command->setPieceStorage(_pieceStorage);
|
||||
e->commands.push_back(command);
|
||||
logger->info(MSG_CONNECTING_TO_PEER,
|
||||
cuid, peer->ipaddr.c_str());
|
||||
cuid, peer->ipaddr.c_str());
|
||||
}
|
||||
|
||||
void ActivePeerConnectionCommand::setBtRuntime
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -63,9 +63,9 @@ private:
|
|||
unsigned int _numNewConnection; // the number of the connection to establish.
|
||||
public:
|
||||
ActivePeerConnectionCommand(int cuid,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
time_t interval);
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
time_t interval);
|
||||
|
||||
virtual ~ActivePeerConnectionCommand();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -75,7 +75,7 @@ AdaptiveURISelector::~AdaptiveURISelector() {}
|
|||
std::string AdaptiveURISelector::select(FileEntry* fileEntry)
|
||||
{
|
||||
_logger->debug("AdaptiveURISelector: called %d",
|
||||
_requestGroup->getNumConnection());
|
||||
_requestGroup->getNumConnection());
|
||||
std::deque<std::string>& uris = fileEntry->getRemainingUris();
|
||||
if (uris.empty() && _requestGroup->getNumConnection() <= 1) {
|
||||
// here we know the download will fail, trying to find previously
|
||||
|
@ -101,13 +101,13 @@ void AdaptiveURISelector::mayRetryWithIncreasedTimeout(FileEntry* fileEntry)
|
|||
std::deque<URIResult> timeouts;
|
||||
fileEntry->extractURIResult(timeouts, downloadresultcode::TIME_OUT);
|
||||
std::transform(timeouts.begin(), timeouts.end(), std::back_inserter(uris),
|
||||
std::mem_fun_ref(&URIResult::getURI));
|
||||
std::mem_fun_ref(&URIResult::getURI));
|
||||
|
||||
for(std::deque<std::string>::const_iterator i = uris.begin(); i != uris.end();
|
||||
++i) {
|
||||
_logger->debug("AdaptiveURISelector: will retry server with increased"
|
||||
" timeout (%d s): %s",
|
||||
_requestGroup->getTimeout(), (*i).c_str());
|
||||
" timeout (%d s): %s",
|
||||
_requestGroup->getTimeout(), (*i).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris)
|
|||
|
||||
bool reservedContext = numPieces > 0 &&
|
||||
_nbConnections > std::min(numPieces,
|
||||
_requestGroup->getNumConcurrentCommand());
|
||||
_requestGroup->getNumConcurrentCommand());
|
||||
bool selectBest = numPieces == 0 || reservedContext;
|
||||
|
||||
if(numPieces > 0)
|
||||
|
@ -132,8 +132,8 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris)
|
|||
if(getNbTestedServers(uris) < 3) {
|
||||
std::string notTested = getFirstNotTestedUri(uris);
|
||||
if(notTested != A2STR::NIL) {
|
||||
_logger->debug("AdaptiveURISelector: choosing the first non tested"
|
||||
" mirror: %s", notTested.c_str());
|
||||
_logger->debug("AdaptiveURISelector: choosing the first non tested"
|
||||
" mirror: %s", notTested.c_str());
|
||||
--_nbServerToEvaluate;
|
||||
return notTested;
|
||||
}
|
||||
|
@ -144,20 +144,20 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris)
|
|||
std::string notTested = getFirstNotTestedUri(uris);
|
||||
if(notTested != A2STR::NIL) {
|
||||
/* Here we return the first untested mirror */
|
||||
_logger->debug("AdaptiveURISelector: choosing non tested mirror %s for"
|
||||
" connection #%d", notTested.c_str(), _nbConnections);
|
||||
_logger->debug("AdaptiveURISelector: choosing non tested mirror %s for"
|
||||
" connection #%d", notTested.c_str(), _nbConnections);
|
||||
return notTested;
|
||||
} else {
|
||||
/* Here we return a mirror which need to be tested again */
|
||||
std::string toReTest = getFirstToTestUri(uris);
|
||||
if(toReTest != A2STR::NIL) {
|
||||
_logger->debug("AdaptiveURISelector: choosing mirror %s which has not"
|
||||
" been tested recently for connection #%d",
|
||||
toReTest.c_str(), _nbConnections);
|
||||
return toReTest;
|
||||
} else {
|
||||
return getBestMirror(uris);
|
||||
}
|
||||
/* Here we return a mirror which need to be tested again */
|
||||
std::string toReTest = getFirstToTestUri(uris);
|
||||
if(toReTest != A2STR::NIL) {
|
||||
_logger->debug("AdaptiveURISelector: choosing mirror %s which has not"
|
||||
" been tested recently for connection #%d",
|
||||
toReTest.c_str(), _nbConnections);
|
||||
return toReTest;
|
||||
} else {
|
||||
return getBestMirror(uris);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -177,14 +177,14 @@ std::string AdaptiveURISelector::getBestMirror
|
|||
if (bests.size() < 2) {
|
||||
std::string uri = getMaxDownloadSpeedUri(uris);
|
||||
_logger->debug("AdaptiveURISelector: choosing the best mirror :"
|
||||
" %.2fKB/s %s (other mirrors are at least 25%% slower)",
|
||||
(float) max/1024, uri.c_str());
|
||||
" %.2fKB/s %s (other mirrors are at least 25%% slower)",
|
||||
(float) max/1024, uri.c_str());
|
||||
return uri;
|
||||
} else {
|
||||
std::string uri = selectRandomUri(bests);
|
||||
_logger->debug("AdaptiveURISelector: choosing randomly one of the best"
|
||||
" mirrors (range [%.2fKB/s, %.2fKB/s]): %s",
|
||||
(float) min/1024, (float) max/1024, uri.c_str());
|
||||
" mirrors (range [%.2fKB/s, %.2fKB/s]): %s",
|
||||
(float) min/1024, (float) max/1024, uri.c_str());
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
@ -212,11 +212,11 @@ void AdaptiveURISelector::adjustLowestSpeedLimit
|
|||
unsigned int max = getMaxDownloadSpeed(uris);
|
||||
if (max > 0 && lowest > max / 4) {
|
||||
_logger->notice("Lowering lowest-speed-limit since known max speed is too"
|
||||
" near (new:%d was:%d max:%d)", max / 4, lowest, max);
|
||||
" near (new:%d was:%d max:%d)", max / 4, lowest, max);
|
||||
command->setLowestDownloadSpeedLimit(max / 4);
|
||||
} else if (max == 0 && lowest > low_lowest) {
|
||||
_logger->notice("Lowering lowest-speed-limit since we have no clue about"
|
||||
" available speed (now:%d was:%d)", low_lowest, lowest);
|
||||
" available speed (now:%d was:%d)", low_lowest, lowest);
|
||||
command->setLowestDownloadSpeedLimit(low_lowest);
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ void AdaptiveURISelector::adjustLowestSpeedLimit
|
|||
static unsigned int getUriMaxSpeed(SharedHandle<ServerStat> ss)
|
||||
{
|
||||
return std::max(ss->getSingleConnectionAvgSpeed(),
|
||||
ss->getMultiConnectionAvgSpeed());
|
||||
ss->getMultiConnectionAvgSpeed());
|
||||
}
|
||||
|
||||
unsigned int AdaptiveURISelector::getMaxDownloadSpeed
|
||||
|
@ -265,12 +265,12 @@ std::deque<std::string> AdaptiveURISelector::getUrisBySpeed
|
|||
{
|
||||
std::deque<std::string> bests;
|
||||
for(std::deque<std::string>::const_iterator i = uris.begin();
|
||||
i != uris.end(); ++i) {
|
||||
i != uris.end(); ++i) {
|
||||
SharedHandle<ServerStat> ss = getServerStats(*i);
|
||||
if(ss.isNull())
|
||||
continue;
|
||||
if(ss->getSingleConnectionAvgSpeed() > min ||
|
||||
ss->getMultiConnectionAvgSpeed() > min) {
|
||||
ss->getMultiConnectionAvgSpeed() > min) {
|
||||
bests.push_back(*i);
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ std::string AdaptiveURISelector::getFirstToTestUri
|
|||
unsigned int counter;
|
||||
int power;
|
||||
for(std::deque<std::string>::const_iterator i = uris.begin();
|
||||
i != uris.end(); ++i) {
|
||||
i != uris.end(); ++i) {
|
||||
SharedHandle<ServerStat> ss = getServerStats(*i);
|
||||
if(ss.isNull())
|
||||
continue;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -61,11 +61,11 @@ private:
|
|||
|
||||
std::string selectOne(const std::deque<std::string>& uris);
|
||||
void adjustLowestSpeedLimit(const std::deque<std::string>& uris,
|
||||
DownloadCommand* command) const;
|
||||
DownloadCommand* command) const;
|
||||
unsigned int getMaxDownloadSpeed(const std::deque<std::string>& uris) const;
|
||||
std::string getMaxDownloadSpeedUri(const std::deque<std::string>& uris) const;
|
||||
std::deque<std::string> getUrisBySpeed(const std::deque<std::string>& uris,
|
||||
unsigned int min) const;
|
||||
unsigned int min) const;
|
||||
std::string selectRandomUri(const std::deque<std::string>& uris) const;
|
||||
std::string getFirstNotTestedUri(const std::deque<std::string>& uris) const;
|
||||
std::string getFirstToTestUri(const std::deque<std::string>& uris) const;
|
||||
|
@ -74,13 +74,13 @@ private:
|
|||
std::string getBestMirror(const std::deque<std::string>& uris) const;
|
||||
public:
|
||||
AdaptiveURISelector(const SharedHandle<ServerStatMan>& serverStatMan,
|
||||
RequestGroup* requestGroup);
|
||||
RequestGroup* requestGroup);
|
||||
|
||||
virtual ~AdaptiveURISelector();
|
||||
|
||||
virtual std::string select(FileEntry* fileEntry);
|
||||
virtual void tuneDownloadCommand(const std::deque<std::string>& uris,
|
||||
DownloadCommand* command);
|
||||
DownloadCommand* command);
|
||||
|
||||
virtual void resetCounters();
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -63,22 +63,22 @@ void AnnounceList::reconfigure(const BDE& announceList)
|
|||
{
|
||||
if(announceList.isList()) {
|
||||
for(BDE::List::const_iterator itr = announceList.listBegin();
|
||||
itr != announceList.listEnd(); ++itr) {
|
||||
itr != announceList.listEnd(); ++itr) {
|
||||
const BDE& elemList = *itr;
|
||||
if(!elemList.isList()) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
std::deque<std::string> urls;
|
||||
for(BDE::List::const_iterator elemItr = elemList.listBegin();
|
||||
elemItr != elemList.listEnd(); ++elemItr) {
|
||||
const BDE& data = *elemItr;
|
||||
if(data.isString()) {
|
||||
urls.push_back(data.s());
|
||||
}
|
||||
elemItr != elemList.listEnd(); ++elemItr) {
|
||||
const BDE& data = *elemItr;
|
||||
if(data.isString()) {
|
||||
urls.push_back(data.s());
|
||||
}
|
||||
}
|
||||
if(!urls.empty()) {
|
||||
AnnounceTierHandle tier(new AnnounceTier(urls));
|
||||
tiers.push_back(tier);
|
||||
AnnounceTierHandle tier(new AnnounceTier(urls));
|
||||
tiers.push_back(tier);
|
||||
}
|
||||
}
|
||||
resetIterator();
|
||||
|
@ -129,9 +129,9 @@ void AnnounceList::announceFailure() {
|
|||
(*currentTier)->nextEventIfAfterStarted();
|
||||
++currentTier;
|
||||
if(currentTier == tiers.end()) {
|
||||
currentTrackerInitialized = false;
|
||||
currentTrackerInitialized = false;
|
||||
} else {
|
||||
currentTracker = (*currentTier)->urls.begin();
|
||||
currentTracker = (*currentTier)->urls.begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ void AnnounceList::setCurrentTier(const AnnounceTiers::iterator& itr) {
|
|||
template<class InputIterator, class Predicate>
|
||||
InputIterator
|
||||
find_wrap_if(InputIterator first, InputIterator last,
|
||||
InputIterator current, Predicate pred) {
|
||||
InputIterator current, Predicate pred) {
|
||||
InputIterator itr = std::find_if(current, last, pred);
|
||||
if(itr == last) {
|
||||
itr = std::find_if(first, current, pred);
|
||||
|
@ -225,15 +225,15 @@ find_wrap_if(InputIterator first, InputIterator last,
|
|||
|
||||
void AnnounceList::moveToStoppedAllowedTier() {
|
||||
AnnounceTiers::iterator itr = find_wrap_if(tiers.begin(), tiers.end(),
|
||||
currentTier,
|
||||
FindStoppedAllowedTier());
|
||||
currentTier,
|
||||
FindStoppedAllowedTier());
|
||||
setCurrentTier(itr);
|
||||
}
|
||||
|
||||
void AnnounceList::moveToCompletedAllowedTier() {
|
||||
AnnounceTiers::iterator itr = find_wrap_if(tiers.begin(), tiers.end(),
|
||||
currentTier,
|
||||
FindCompletedAllowedTier());
|
||||
currentTier,
|
||||
FindCompletedAllowedTier());
|
||||
setCurrentTier(itr);
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ void AnnounceList::shuffle() {
|
|||
itr != tiers.end(); ++itr) {
|
||||
std::deque<std::string>& urls = (*itr)->urls;
|
||||
std::random_shuffle(urls.begin(), urls.end(),
|
||||
*(SimpleRandomizer::getInstance().get()));
|
||||
*(SimpleRandomizer::getInstance().get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -42,7 +42,7 @@ namespace aria2 {
|
|||
#ifdef HAVE_LIBCARES1_5
|
||||
void callback(void* arg, int status, int timeouts, struct hostent* host)
|
||||
#else
|
||||
void callback(void* arg, int status, struct hostent* host)
|
||||
void callback(void* arg, int status, struct hostent* host)
|
||||
#endif // HAVE_LIBCARES1_5
|
||||
{
|
||||
AsyncNameResolver* resolverPtr = reinterpret_cast<AsyncNameResolver*>(arg);
|
||||
|
@ -98,7 +98,7 @@ int AsyncNameResolver::getsock(sock_t* sockets) const
|
|||
{
|
||||
// TODO cast to int* might cause problem with Windows SOCKET?
|
||||
return ares_getsock(channel, reinterpret_cast<int*>(sockets),
|
||||
ARES_GETSOCK_MAXNUM);
|
||||
ARES_GETSOCK_MAXNUM);
|
||||
}
|
||||
|
||||
void AsyncNameResolver::process(ares_socket_t readfd, ares_socket_t writefd)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -64,51 +64,51 @@ AuthConfigFactory::createAuthConfig
|
|||
|
||||
if(op->getAsBool(PREF_HTTP_AUTH_CHALLENGE)) {
|
||||
if(!request->getUsername().empty()) {
|
||||
updateBasicCred(BasicCred(request->getUsername(),
|
||||
request->getPassword(),
|
||||
request->getHost(), request->getDir(), true));
|
||||
return createAuthConfig(request->getUsername(), request->getPassword());
|
||||
updateBasicCred(BasicCred(request->getUsername(),
|
||||
request->getPassword(),
|
||||
request->getHost(), request->getDir(), true));
|
||||
return createAuthConfig(request->getUsername(), request->getPassword());
|
||||
}
|
||||
std::deque<BasicCred>::const_iterator i =
|
||||
findBasicCred(request->getHost(), request->getDir());
|
||||
findBasicCred(request->getHost(), request->getDir());
|
||||
if(i == _basicCreds.end()) {
|
||||
return SharedHandle<AuthConfig>();
|
||||
return SharedHandle<AuthConfig>();
|
||||
} else {
|
||||
return createAuthConfig((*i)._user, (*i)._password);
|
||||
return createAuthConfig((*i)._user, (*i)._password);
|
||||
}
|
||||
} else {
|
||||
if(!request->getUsername().empty()) {
|
||||
return createAuthConfig(request->getUsername(), request->getPassword());
|
||||
return createAuthConfig(request->getUsername(), request->getPassword());
|
||||
} else {
|
||||
return
|
||||
createHttpAuthResolver(op)->resolveAuthConfig(request->getHost());
|
||||
return
|
||||
createHttpAuthResolver(op)->resolveAuthConfig(request->getHost());
|
||||
}
|
||||
}
|
||||
} else if(request->getProtocol() == Request::PROTO_FTP) {
|
||||
if(!request->getUsername().empty()) {
|
||||
if(request->hasPassword()) {
|
||||
return createAuthConfig(request->getUsername(), request->getPassword());
|
||||
return createAuthConfig(request->getUsername(), request->getPassword());
|
||||
} else {
|
||||
if(!op->getAsBool(PREF_NO_NETRC)) {
|
||||
// First, check we have password corresponding to host and
|
||||
// username
|
||||
NetrcAuthResolver authResolver;
|
||||
authResolver.setNetrc(_netrc);
|
||||
if(!op->getAsBool(PREF_NO_NETRC)) {
|
||||
// First, check we have password corresponding to host and
|
||||
// username
|
||||
NetrcAuthResolver authResolver;
|
||||
authResolver.setNetrc(_netrc);
|
||||
|
||||
SharedHandle<AuthConfig> ac =
|
||||
authResolver.resolveAuthConfig(request->getHost());
|
||||
if(!ac.isNull() && ac->getUser() == request->getUsername()) {
|
||||
return ac;
|
||||
}
|
||||
}
|
||||
// We don't have password for host and username. Return
|
||||
// password specified by --ftp-passwd
|
||||
return
|
||||
createAuthConfig(request->getUsername(), op->get(PREF_FTP_PASSWD));
|
||||
SharedHandle<AuthConfig> ac =
|
||||
authResolver.resolveAuthConfig(request->getHost());
|
||||
if(!ac.isNull() && ac->getUser() == request->getUsername()) {
|
||||
return ac;
|
||||
}
|
||||
}
|
||||
// We don't have password for host and username. Return
|
||||
// password specified by --ftp-passwd
|
||||
return
|
||||
createAuthConfig(request->getUsername(), op->get(PREF_FTP_PASSWD));
|
||||
}
|
||||
} else {
|
||||
return
|
||||
createFtpAuthResolver(op)->resolveAuthConfig(request->getHost());
|
||||
createFtpAuthResolver(op)->resolveAuthConfig(request->getHost());
|
||||
}
|
||||
} else {
|
||||
return SharedHandle<AuthConfig>();
|
||||
|
@ -157,7 +157,7 @@ AuthResolverHandle AuthConfigFactory::createFtpAuthResolver
|
|||
(createAuthConfig(op->get(PREF_FTP_USER), op->get(PREF_FTP_PASSWD)));
|
||||
SharedHandle<AuthConfig> defaultAuthConfig
|
||||
(new AuthConfig(AuthConfigFactory::ANONYMOUS,
|
||||
AuthConfigFactory::ARIA2USER_AT));
|
||||
AuthConfigFactory::ARIA2USER_AT));
|
||||
resolver->setDefaultAuthConfig(defaultAuthConfig);
|
||||
return resolver;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ bool AuthConfigFactory::activateBasicCred
|
|||
return false;
|
||||
} else {
|
||||
BasicCred bc(authConfig->getUser(), authConfig->getPassword(),
|
||||
host, path, true);
|
||||
host, path, true);
|
||||
i = std::lower_bound(_basicCreds.begin(), _basicCreds.end(), bc);
|
||||
_basicCreds.insert(i, bc);
|
||||
return true;
|
||||
|
@ -241,7 +241,7 @@ bool AuthConfigFactory::BasicCred::operator<(const BasicCred& cred) const
|
|||
|
||||
std::deque<AuthConfigFactory::BasicCred>::iterator
|
||||
AuthConfigFactory::findBasicCred(const std::string& host,
|
||||
const std::string& path)
|
||||
const std::string& path)
|
||||
{
|
||||
BasicCred bc("", "", host, path);
|
||||
std::deque<BasicCred>::iterator i =
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -56,7 +56,7 @@ private:
|
|||
SharedHandle<Netrc> _netrc;
|
||||
|
||||
SharedHandle<AuthConfig> createAuthConfig(const std::string& user,
|
||||
const std::string& password) const;
|
||||
const std::string& password) const;
|
||||
|
||||
SharedHandle<AuthResolver> createHttpAuthResolver(const Option* op) const;
|
||||
|
||||
|
@ -71,8 +71,8 @@ public:
|
|||
bool _activated;
|
||||
|
||||
BasicCred(const std::string& user, const std::string& password,
|
||||
const std::string& host, const std::string& path,
|
||||
bool activated = false);
|
||||
const std::string& host, const std::string& path,
|
||||
bool activated = false);
|
||||
|
||||
void activate();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -42,14 +42,14 @@ const BDE BDE::none;
|
|||
BDE::BDE():_type(TYPE_NONE), _bobject(new BObject()) {}
|
||||
|
||||
BDE::BDE(Integer integer):_type(TYPE_INTEGER),
|
||||
_bobject(new BInteger(integer)) {}
|
||||
_bobject(new BInteger(integer)) {}
|
||||
|
||||
|
||||
BDE::BDE(const std::string& string):_type(TYPE_STRING),
|
||||
_bobject(new BString(std::string(string))) {}
|
||||
_bobject(new BString(std::string(string))) {}
|
||||
|
||||
BDE::BDE(const char* cstring):_type(TYPE_STRING),
|
||||
_bobject(new BString(std::string(cstring))) {}
|
||||
_bobject(new BString(std::string(cstring))) {}
|
||||
|
||||
BDE::BDE(const char* data, size_t length):
|
||||
_type(TYPE_STRING),
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
28
src/BNode.cc
28
src/BNode.cc
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -115,7 +115,7 @@ SharedHandle<DHTBucket> BNode::findBucketFor(BNode* b, const unsigned char* key)
|
|||
|
||||
|
||||
void BNode::findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes,
|
||||
BNode* b, const unsigned char* key)
|
||||
BNode* b, const unsigned char* key)
|
||||
{
|
||||
BNode* bnode = findBNodeFor(b, key);
|
||||
if(!bnode) {
|
||||
|
@ -149,11 +149,11 @@ void BNode::findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes,
|
|||
bnode = bnode->getUp();
|
||||
} else {
|
||||
if(std::find(visited.begin(), visited.end(), firstfunc(bnode)) == visited.end()) {
|
||||
bnode = firstfunc(bnode);
|
||||
bnode = firstfunc(bnode);
|
||||
} else if(std::find(visited.begin(), visited.end(), secondfunc(bnode)) == visited.end()) {
|
||||
bnode = secondfunc(bnode);
|
||||
bnode = secondfunc(bnode);
|
||||
} else {
|
||||
bnode = bnode->getUp();
|
||||
bnode = bnode->getUp();
|
||||
}
|
||||
}
|
||||
if(!bnode) {
|
||||
|
@ -163,21 +163,21 @@ void BNode::findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes,
|
|||
{
|
||||
SharedHandle<DHTBucket> bucket = bnode->getBucket();
|
||||
if(!bucket.isNull()) {
|
||||
std::deque<SharedHandle<DHTNode> > goodNodes;
|
||||
bucket->getGoodNodes(goodNodes);
|
||||
size_t r = DHTBucket::K-nodes.size();
|
||||
if(goodNodes.size() <= r) {
|
||||
nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.end());
|
||||
} else {
|
||||
nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.begin()+r);
|
||||
}
|
||||
std::deque<SharedHandle<DHTNode> > goodNodes;
|
||||
bucket->getGoodNodes(goodNodes);
|
||||
size_t r = DHTBucket::K-nodes.size();
|
||||
if(goodNodes.size() <= r) {
|
||||
nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.end());
|
||||
} else {
|
||||
nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.begin()+r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BNode::enumerateBucket(std::deque<SharedHandle<DHTBucket> >& buckets,
|
||||
const BNode* b)
|
||||
const BNode* b)
|
||||
{
|
||||
std::deque<const BNode*> visited;
|
||||
visited.push_back(b);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -94,10 +94,10 @@ public:
|
|||
static SharedHandle<DHTBucket> findBucketFor(BNode* b, const unsigned char* key);
|
||||
|
||||
static void findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes,
|
||||
BNode* b, const unsigned char* key);
|
||||
BNode* b, const unsigned char* key);
|
||||
|
||||
static void enumerateBucket(std::deque<SharedHandle<DHTBucket> >& buckets,
|
||||
const BNode* b);
|
||||
const BNode* b);
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -67,7 +67,7 @@ static const int INDEX_TABLE[] = {
|
|||
};
|
||||
|
||||
void Base64::encode(unsigned char*& result, size_t& rlength,
|
||||
const unsigned char* src, size_t slength)
|
||||
const unsigned char* src, size_t slength)
|
||||
{
|
||||
if(slength == 0) {
|
||||
rlength = 0;
|
||||
|
@ -107,9 +107,9 @@ void Base64::encode(unsigned char*& result, size_t& rlength,
|
|||
}
|
||||
|
||||
void Base64::removeNonBase64Chars(unsigned char*& nsrc,
|
||||
size_t& nlength,
|
||||
const unsigned char* src,
|
||||
size_t slength)
|
||||
size_t& nlength,
|
||||
const unsigned char* src,
|
||||
size_t slength)
|
||||
{
|
||||
unsigned char* temp = new unsigned char[slength];
|
||||
const unsigned char* end = src+slength;
|
||||
|
@ -124,7 +124,7 @@ void Base64::removeNonBase64Chars(unsigned char*& nsrc,
|
|||
}
|
||||
|
||||
void Base64::decode(unsigned char*& result, size_t& rlength,
|
||||
const unsigned char* src, size_t slength)
|
||||
const unsigned char* src, size_t slength)
|
||||
{
|
||||
if(slength == 0) {
|
||||
rlength = 0;
|
||||
|
|
16
src/Base64.h
16
src/Base64.h
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -47,7 +47,7 @@ private:
|
|||
* Caller must delete nsrc.
|
||||
*/
|
||||
static void removeNonBase64Chars(unsigned char*& nsrc, size_t& nlength,
|
||||
const unsigned char* src, size_t slength);
|
||||
const unsigned char* src, size_t slength);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -59,13 +59,13 @@ public:
|
|||
* A caller must deallocate the memory used by result.
|
||||
*/
|
||||
static void encode(unsigned char*& result, size_t& rlength,
|
||||
const unsigned char* src, size_t slength);
|
||||
const unsigned char* src, size_t slength);
|
||||
|
||||
static void encode(unsigned char*& result, size_t& rlength,
|
||||
const char* src, size_t slength)
|
||||
const char* src, size_t slength)
|
||||
{
|
||||
encode(result, rlength, reinterpret_cast<const unsigned char*>(src),
|
||||
slength);
|
||||
slength);
|
||||
}
|
||||
|
||||
static std::string encode(const std::string& s);
|
||||
|
@ -80,13 +80,13 @@ public:
|
|||
* A caller must deallocate the memory used by result.
|
||||
*/
|
||||
static void decode(unsigned char*& result, size_t& rlength,
|
||||
const unsigned char* src, size_t slength);
|
||||
const unsigned char* src, size_t slength);
|
||||
|
||||
static void decode(unsigned char*& result, size_t& rlength,
|
||||
const char* src, size_t slength)
|
||||
const char* src, size_t slength)
|
||||
{
|
||||
decode(result, rlength, reinterpret_cast<const unsigned char*>(src),
|
||||
slength);
|
||||
slength);
|
||||
}
|
||||
|
||||
static std::string decode(const std::string& s);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -153,8 +153,8 @@ BitfieldMan::getNthBitIndex(const unsigned char bitfield, size_t nth) const
|
|||
if(bitfield & mask) {
|
||||
nth--;
|
||||
if(nth == 0) {
|
||||
index = 7-bs;
|
||||
break;
|
||||
index = 7-bs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,8 +163,8 @@ BitfieldMan::getNthBitIndex(const unsigned char bitfield, size_t nth) const
|
|||
|
||||
template<typename Array>
|
||||
bool BitfieldMan::getMissingIndexRandomly(size_t& index,
|
||||
const Array& bitfield,
|
||||
size_t bitfieldLength) const
|
||||
const Array& bitfield,
|
||||
size_t bitfieldLength) const
|
||||
{
|
||||
size_t byte = randomizer->getRandomNumber(bitfieldLength);
|
||||
for(size_t i = 0; i < bitfieldLength; ++i) {
|
||||
|
@ -247,8 +247,8 @@ bool BitfieldMan::getFirstMissingIndex(size_t& index, const Array& bitfield, siz
|
|||
size_t tindex = i*8;
|
||||
for(size_t bi = 0; bi < 8 && tindex < blocks; ++bi, mask >>= 1, ++tindex) {
|
||||
if(bits & mask) {
|
||||
index = tindex;
|
||||
return true;
|
||||
index = tindex;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ bool BitfieldMan::getFirstMissingIndex(size_t& index) const
|
|||
{
|
||||
if(filterEnabled) {
|
||||
return getFirstMissingIndex(index, ~array(bitfield)&array(filterBitfield),
|
||||
bitfieldLength);
|
||||
bitfieldLength);
|
||||
} else {
|
||||
return getFirstMissingIndex(index, ~array(bitfield), bitfieldLength);
|
||||
}
|
||||
|
@ -332,14 +332,14 @@ static bool getSparseMissingUnusedIndex
|
|||
size_t nextIndex = 0;
|
||||
while(nextIndex < blocks) {
|
||||
currentRange.startIndex =
|
||||
getStartIndex(nextIndex, bitfield, blocks);
|
||||
getStartIndex(nextIndex, bitfield, blocks);
|
||||
if(currentRange.startIndex == blocks) {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
currentRange.endIndex =
|
||||
getEndIndex(currentRange.startIndex, bitfield, blocks);
|
||||
getEndIndex(currentRange.startIndex, bitfield, blocks);
|
||||
if(maxRange < currentRange) {
|
||||
maxRange = currentRange;
|
||||
maxRange = currentRange;
|
||||
}
|
||||
nextIndex = currentRange.endIndex;
|
||||
}
|
||||
|
@ -401,8 +401,8 @@ bool BitfieldMan::getAllMissingIndexes(unsigned char* misbitfield, size_t len)
|
|||
}
|
||||
|
||||
bool BitfieldMan::getAllMissingIndexes(unsigned char* misbitfield, size_t len,
|
||||
const unsigned char* peerBitfield,
|
||||
size_t peerBitfieldLength) const
|
||||
const unsigned char* peerBitfield,
|
||||
size_t peerBitfieldLength) const
|
||||
{
|
||||
assert(len == bitfieldLength);
|
||||
if(bitfieldLength != peerBitfieldLength) {
|
||||
|
@ -420,9 +420,9 @@ bool BitfieldMan::getAllMissingIndexes(unsigned char* misbitfield, size_t len,
|
|||
}
|
||||
|
||||
bool BitfieldMan::getAllMissingUnusedIndexes(unsigned char* misbitfield,
|
||||
size_t len,
|
||||
const unsigned char* peerBitfield,
|
||||
size_t peerBitfieldLength) const
|
||||
size_t len,
|
||||
const unsigned char* peerBitfield,
|
||||
size_t peerBitfieldLength) const
|
||||
{
|
||||
assert(len == bitfieldLength);
|
||||
if(bitfieldLength != peerBitfieldLength) {
|
||||
|
@ -502,7 +502,7 @@ bool BitfieldMan::isFilteredAllBitSet() const {
|
|||
if(filterEnabled) {
|
||||
for(size_t i = 0; i < bitfieldLength; ++i) {
|
||||
if((bitfield[i]&filterBitfield[i]) != filterBitfield[i]) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -681,7 +681,7 @@ uint64_t BitfieldMan::getCompletedLength(bool useFilter) const {
|
|||
for(size_t i = 0; i < bitfieldLength; ++i) {
|
||||
temp[i] = bitfield[i];
|
||||
if(filterEnabled) {
|
||||
temp[i] &= filterBitfield[i];
|
||||
temp[i] &= filterBitfield[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -67,14 +67,14 @@ private:
|
|||
|
||||
template<typename Array>
|
||||
bool getMissingIndexRandomly(size_t& index, const Array& bitfield,
|
||||
size_t bitfieldLength) const;
|
||||
size_t bitfieldLength) const;
|
||||
template<typename Array>
|
||||
bool getFirstMissingIndex(size_t& index, const Array& bitfield, size_t bitfieldLength) const;
|
||||
|
||||
template<typename Array>
|
||||
bool getAllMissingIndexes(std::deque<size_t>& indexes,
|
||||
const Array& bitfield,
|
||||
size_t bitfieldLength) const;
|
||||
const Array& bitfield,
|
||||
size_t bitfieldLength) const;
|
||||
|
||||
bool setBitInternal(unsigned char* bitfield, size_t index, bool on);
|
||||
bool setFilterBit(size_t index);
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
size_t startIndex;
|
||||
size_t endIndex;
|
||||
Range(size_t startIndex = 0, size_t endIndex = 0):startIndex(startIndex),
|
||||
endIndex(endIndex) {}
|
||||
endIndex(endIndex) {}
|
||||
|
||||
size_t getSize() const {
|
||||
return endIndex-startIndex;
|
||||
|
@ -177,13 +177,13 @@ public:
|
|||
* affected by filter
|
||||
*/
|
||||
bool getAllMissingIndexes(unsigned char* misbitfield, size_t mislen,
|
||||
const unsigned char* bitfield, size_t len) const;
|
||||
const unsigned char* bitfield, size_t len) const;
|
||||
/**
|
||||
* affected by filter
|
||||
*/
|
||||
bool getAllMissingUnusedIndexes(unsigned char* misbitfield, size_t mislen,
|
||||
const unsigned char* bitfield,
|
||||
size_t len) const;
|
||||
const unsigned char* bitfield,
|
||||
size_t len) const;
|
||||
/**
|
||||
* affected by filter
|
||||
*/
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -51,7 +51,7 @@ void BtAllowedFastMessage::doReceivedAction() {
|
|||
if(!peer->isFastExtensionEnabled()) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("%s received while fast extension is disabled",
|
||||
toString().c_str()).str());
|
||||
toString().c_str()).str());
|
||||
}
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
* Processes the repsponse from the tracker.
|
||||
*/
|
||||
virtual void processAnnounceResponse(const unsigned char* trackerResponse,
|
||||
size_t trackerResponseLength) = 0;
|
||||
size_t trackerResponseLength) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if no more announce is needed.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
}
|
||||
|
||||
BtBitfieldMessage(const unsigned char* bitfield,
|
||||
size_t bitfieldLength):SimpleBtMessage(ID, NAME)
|
||||
size_t bitfieldLength):SimpleBtMessage(ID, NAME)
|
||||
{
|
||||
init();
|
||||
setBitfield(bitfield, bitfieldLength);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -47,15 +47,15 @@ private:
|
|||
size_t numPiece;
|
||||
public:
|
||||
BtBitfieldMessageValidator(const BtBitfieldMessage* message,
|
||||
size_t numPiece):
|
||||
size_t numPiece):
|
||||
message(message),
|
||||
numPiece(numPiece) {}
|
||||
|
||||
virtual bool validate(Errors& error) {
|
||||
// TODO
|
||||
bittorrent::checkBitfield(message->getBitfield(),
|
||||
message->getBitfieldLength(),
|
||||
numPiece);
|
||||
message->getBitfieldLength(),
|
||||
numPiece);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -50,7 +50,7 @@ BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup):
|
|||
BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {}
|
||||
|
||||
void BtCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands,
|
||||
DownloadEngine* e)
|
||||
DownloadEngine* e)
|
||||
{
|
||||
const SharedHandle<DiskAdaptor>& diskAdaptor =
|
||||
_requestGroup->getPieceStorage()->getDiskAdaptor();
|
||||
|
@ -66,7 +66,7 @@ void BtCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands,
|
|||
}
|
||||
|
||||
void BtCheckIntegrityEntry::onDownloadFinished(std::deque<Command*>& commands,
|
||||
DownloadEngine* e)
|
||||
DownloadEngine* e)
|
||||
{
|
||||
// TODO Currently,when all the checksums
|
||||
// are valid, then aira2 goes to seeding mode. Sometimes it is better
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -46,10 +46,10 @@ public:
|
|||
virtual ~BtCheckIntegrityEntry();
|
||||
|
||||
virtual void onDownloadFinished(std::deque<Command*>& commands,
|
||||
DownloadEngine* e);
|
||||
DownloadEngine* e);
|
||||
|
||||
virtual void onDownloadIncomplete(std::deque<Command*>& commands,
|
||||
DownloadEngine* e);
|
||||
DownloadEngine* e);
|
||||
};
|
||||
|
||||
typedef SharedHandle<BtCheckIntegrityEntry> BtCheckIntegrityEntryHandle;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -51,7 +51,7 @@
|
|||
namespace aria2 {
|
||||
|
||||
BtDependency::BtDependency(const RequestGroupWeakHandle& dependant,
|
||||
const RequestGroupHandle& dependee):
|
||||
const RequestGroupHandle& dependee):
|
||||
_dependant(dependant),
|
||||
_dependee(dependee),
|
||||
_logger(LogFactory::getInstance()) {}
|
||||
|
@ -68,41 +68,41 @@ bool BtDependency::resolve()
|
|||
context->setDir(_dependant->getDownloadContext()->getDir());
|
||||
try {
|
||||
DiskAdaptorHandle diskAdaptor =
|
||||
dependee->getPieceStorage()->getDiskAdaptor();
|
||||
dependee->getPieceStorage()->getDiskAdaptor();
|
||||
diskAdaptor->openExistingFile();
|
||||
std::string content = util::toString(diskAdaptor);
|
||||
if(dependee->getDownloadContext()->hasAttribute(bittorrent::BITTORRENT)) {
|
||||
const BDE& attrs =
|
||||
dependee->getDownloadContext()->getAttribute(bittorrent::BITTORRENT);
|
||||
bittorrent::loadFromMemory
|
||||
(bittorrent::metadata2Torrent(content, attrs), context, "default");
|
||||
const BDE& attrs =
|
||||
dependee->getDownloadContext()->getAttribute(bittorrent::BITTORRENT);
|
||||
bittorrent::loadFromMemory
|
||||
(bittorrent::metadata2Torrent(content, attrs), context, "default");
|
||||
} else {
|
||||
bittorrent::loadFromMemory
|
||||
(content, context, File(dependee->getFirstFilePath()).getBasename());
|
||||
bittorrent::loadFromMemory
|
||||
(content, context, File(dependee->getFirstFilePath()).getBasename());
|
||||
}
|
||||
if(context->getFileEntries().size() !=
|
||||
_dependant->getDownloadContext()->getFileEntries().size()) {
|
||||
throw DL_ABORT_EX("The number of file in torrent doesn't match to"
|
||||
" the dependent.");
|
||||
_dependant->getDownloadContext()->getFileEntries().size()) {
|
||||
throw DL_ABORT_EX("The number of file in torrent doesn't match to"
|
||||
" the dependent.");
|
||||
}
|
||||
// Copy file path in _dependant's FileEntries to newly created
|
||||
// context's FileEntries to endorse the path structure of
|
||||
// _dependant. URIs and singleHostMultiConnection are also copied.
|
||||
for(std::vector<SharedHandle<FileEntry> >::const_iterator s =
|
||||
_dependant->getDownloadContext()->getFileEntries().begin(),
|
||||
d = context->getFileEntries().begin();
|
||||
d != context->getFileEntries().end(); ++s, ++d) {
|
||||
(*d)->setPath((*s)->getPath());
|
||||
(*d)->addUris((*s)->getRemainingUris().begin(),
|
||||
(*s)->getRemainingUris().end());
|
||||
if(!(*s)->isSingleHostMultiConnectionEnabled()) {
|
||||
(*d)->disableSingleHostMultiConnection();
|
||||
}
|
||||
_dependant->getDownloadContext()->getFileEntries().begin(),
|
||||
d = context->getFileEntries().begin();
|
||||
d != context->getFileEntries().end(); ++s, ++d) {
|
||||
(*d)->setPath((*s)->getPath());
|
||||
(*d)->addUris((*s)->getRemainingUris().begin(),
|
||||
(*s)->getRemainingUris().end());
|
||||
if(!(*s)->isSingleHostMultiConnectionEnabled()) {
|
||||
(*d)->disableSingleHostMultiConnection();
|
||||
}
|
||||
}
|
||||
} catch(RecoverableException& e) {
|
||||
_logger->error(EX_EXCEPTION_CAUGHT, e);
|
||||
_logger->info("BtDependency for GID#%d failed. Go without Bt.",
|
||||
_dependant->getGID());
|
||||
_dependant->getGID());
|
||||
return true;
|
||||
}
|
||||
_logger->debug("Dependency resolved for GID#%d", _dependant->getGID());
|
||||
|
@ -113,7 +113,7 @@ bool BtDependency::resolve()
|
|||
// cut reference here
|
||||
_dependee.reset();
|
||||
_logger->debug("BtDependency for GID#%d failed. Go without Bt.",
|
||||
_dependant->getGID());
|
||||
_dependant->getGID());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -51,7 +51,7 @@ private:
|
|||
Logger* _logger;
|
||||
public:
|
||||
BtDependency(const WeakHandle<RequestGroup>& dependant,
|
||||
const SharedHandle<RequestGroup>& dependee);
|
||||
const SharedHandle<RequestGroup>& dependee);
|
||||
|
||||
virtual ~BtDependency();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -99,14 +99,14 @@ std::string BtExtendedMessage::toString() const {
|
|||
|
||||
BtExtendedMessageHandle
|
||||
BtExtendedMessage::create(const SharedHandle<ExtensionMessageFactory>& factory,
|
||||
const PeerHandle& peer,
|
||||
const unsigned char* data, size_t dataLength)
|
||||
const PeerHandle& peer,
|
||||
const unsigned char* data, size_t dataLength)
|
||||
{
|
||||
bittorrent::assertPayloadLengthGreater(1, dataLength, NAME);
|
||||
bittorrent::assertID(ID, data, NAME);
|
||||
assert(!factory.isNull());
|
||||
ExtensionMessageHandle extmsg = factory->createMessage(data+1,
|
||||
dataLength-1);
|
||||
dataLength-1);
|
||||
BtExtendedMessageHandle message(new BtExtendedMessage(extmsg));
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
size_t _msgLength;
|
||||
public:
|
||||
BtExtendedMessage(const SharedHandle<ExtensionMessage>& extensionMessage =
|
||||
SharedHandle<ExtensionMessage>());
|
||||
SharedHandle<ExtensionMessage>());
|
||||
|
||||
virtual ~BtExtendedMessage();
|
||||
|
||||
|
@ -63,10 +63,10 @@ public:
|
|||
static const std::string NAME;
|
||||
|
||||
static BtExtendedMessageHandle create
|
||||
(const SharedHandle<ExtensionMessageFactory>& factory,
|
||||
const SharedHandle<Peer>& peer,
|
||||
const unsigned char* data,
|
||||
size_t dataLength);
|
||||
(const SharedHandle<ExtensionMessageFactory>& factory,
|
||||
const SharedHandle<Peer>& peer,
|
||||
const unsigned char* data,
|
||||
size_t dataLength);
|
||||
|
||||
virtual void doReceivedAction();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -50,7 +50,7 @@ BtFileAllocationEntry::BtFileAllocationEntry(RequestGroup* requestGroup):
|
|||
BtFileAllocationEntry::~BtFileAllocationEntry() {}
|
||||
|
||||
void BtFileAllocationEntry::prepareForNextAction(std::deque<Command*>& commands,
|
||||
DownloadEngine* e)
|
||||
DownloadEngine* e)
|
||||
{
|
||||
BtSetup().setup(commands, _requestGroup, e, _requestGroup->getOption().get());
|
||||
if(!_requestGroup->downloadFinished()) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
virtual ~BtFileAllocationEntry();
|
||||
|
||||
virtual void prepareForNextAction(std::deque<Command*>& commands,
|
||||
DownloadEngine* e);
|
||||
DownloadEngine* e);
|
||||
};
|
||||
|
||||
typedef SharedHandle<BtFileAllocationEntry> BtFileAllocationEntryHandle;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -53,7 +53,7 @@ BtHandshakeMessage::BtHandshakeMessage():SimpleBtMessage(ID, NAME)
|
|||
}
|
||||
|
||||
BtHandshakeMessage::BtHandshakeMessage(const unsigned char* infoHash,
|
||||
const unsigned char* peerId):
|
||||
const unsigned char* peerId):
|
||||
SimpleBtMessage(ID, NAME)
|
||||
{
|
||||
init();
|
||||
|
@ -106,9 +106,9 @@ size_t BtHandshakeMessage::getMessageLength() {
|
|||
|
||||
std::string BtHandshakeMessage::toString() const {
|
||||
return strconcat(NAME, " peerId=",
|
||||
util::urlencode(peerId, PEER_ID_LENGTH),
|
||||
", reserved=",
|
||||
util::toHex(reserved, RESERVED_LENGTH));
|
||||
util::urlencode(peerId, PEER_ID_LENGTH),
|
||||
", reserved=",
|
||||
util::toHex(reserved, RESERVED_LENGTH));
|
||||
}
|
||||
|
||||
bool BtHandshakeMessage::isFastExtensionSupported() const {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -51,7 +51,7 @@ private:
|
|||
unsigned char infoHash[20];
|
||||
public:
|
||||
BtHandshakeMessageValidator(const BtHandshakeMessage* message,
|
||||
const unsigned char* infoHash):
|
||||
const unsigned char* infoHash):
|
||||
message(message)
|
||||
{
|
||||
memcpy(this->infoHash, infoHash, sizeof(this->infoHash));
|
||||
|
@ -61,18 +61,18 @@ public:
|
|||
// TODO
|
||||
if(message->getPstrlen() != 19) {
|
||||
throw DL_ABORT_EX(StringFormat("invalid handshake pstrlen=%u",
|
||||
message->getPstrlen()).str());
|
||||
message->getPstrlen()).str());
|
||||
}
|
||||
if(memcmp(BtHandshakeMessage::BT_PSTR, message->getPstr(), 19) != 0) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("invalid handshake pstr=%s",
|
||||
util::urlencode(message->getPstr(), 19).c_str()).str());
|
||||
(StringFormat("invalid handshake pstr=%s",
|
||||
util::urlencode(message->getPstr(), 19).c_str()).str());
|
||||
}
|
||||
if(memcmp(infoHash, message->getInfoHash(), 20) != 0) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("invalid handshake info hash: expected:%s, actual:%s",
|
||||
util::toHex(infoHash, 20).c_str(),
|
||||
util::toHex(message->getInfoHash(), 20).c_str()).str());
|
||||
(StringFormat("invalid handshake info hash: expected:%s, actual:%s",
|
||||
util::toHex(infoHash, 20).c_str(),
|
||||
util::toHex(message->getInfoHash(), 20).c_str()).str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -54,13 +54,13 @@ void BtHaveAllMessage::doReceivedAction()
|
|||
if(!peer->isFastExtensionEnabled()) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("%s received while fast extension is disabled",
|
||||
toString().c_str()).str());
|
||||
toString().c_str()).str());
|
||||
}
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
pieceStorage->subtractPieceStats(peer->getBitfield(),
|
||||
peer->getBitfieldLength());
|
||||
peer->getBitfieldLength());
|
||||
peer->setAllBitfield();
|
||||
pieceStorage->addPieceStats(peer->getBitfield(), peer->getBitfieldLength());
|
||||
if(peer->isSeeder() && pieceStorage->downloadFinished()) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -52,7 +52,7 @@ void BtHaveNoneMessage::doReceivedAction()
|
|||
if(!peer->isFastExtensionEnabled()) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("%s received while fast extension is disabled",
|
||||
toString().c_str()).str());
|
||||
toString().c_str()).str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -56,7 +56,7 @@ BtLeecherStateChoke::PeerEntry::PeerEntry
|
|||
_peer(peer), _downloadSpeed(peer->calculateDownloadSpeed(now)),
|
||||
// peer must be interested to us and sent block in the last 30 seconds
|
||||
_regularUnchoker(peer->peerInterested() &&
|
||||
!peer->getLastDownloadUpdate().elapsed(30)) {}
|
||||
!peer->getLastDownloadUpdate().elapsed(30)) {}
|
||||
|
||||
const SharedHandle<Peer>& BtLeecherStateChoke::PeerEntry::getPeer() const
|
||||
{
|
||||
|
@ -123,14 +123,14 @@ void BtLeecherStateChoke::plannedOptimisticUnchoke
|
|||
(std::deque<PeerEntry>& peerEntries)
|
||||
{
|
||||
std::for_each(peerEntries.begin(), peerEntries.end(),
|
||||
std::mem_fun_ref(&PeerEntry::disableOptUnchoking));
|
||||
std::mem_fun_ref(&PeerEntry::disableOptUnchoking));
|
||||
|
||||
std::deque<PeerEntry>::iterator i =
|
||||
std::partition(peerEntries.begin(), peerEntries.end(),
|
||||
PeerFilter(true, true));
|
||||
PeerFilter(true, true));
|
||||
if(i != peerEntries.begin()) {
|
||||
std::random_shuffle(peerEntries.begin(), i,
|
||||
*(SimpleRandomizer::getInstance().get()));
|
||||
*(SimpleRandomizer::getInstance().get()));
|
||||
(*peerEntries.begin()).enableOptUnchoking();
|
||||
_logger->info("POU: %s", (*peerEntries.begin()).getPeer()->ipaddr.c_str());
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void BtLeecherStateChoke::regularUnchoke(std::deque<PeerEntry>& peerEntries)
|
|||
{
|
||||
std::deque<PeerEntry>::iterator rest =
|
||||
std::partition(peerEntries.begin(), peerEntries.end(),
|
||||
std::mem_fun_ref(&PeerEntry::isRegularUnchoker));
|
||||
std::mem_fun_ref(&PeerEntry::isRegularUnchoker));
|
||||
|
||||
struct timeval now;
|
||||
gettimeofday(&now, 0);
|
||||
|
@ -155,8 +155,8 @@ void BtLeecherStateChoke::regularUnchoke(std::deque<PeerEntry>& peerEntries)
|
|||
for(;peerIter != rest && count; ++peerIter, --count) {
|
||||
(*peerIter).disableChokingRequired();
|
||||
_logger->info("RU: %s, dlspd=%u",
|
||||
(*peerIter).getPeer()->ipaddr.c_str(),
|
||||
(*peerIter).getDownloadSpeed());
|
||||
(*peerIter).getPeer()->ipaddr.c_str(),
|
||||
(*peerIter).getDownloadSpeed());
|
||||
if((*peerIter).getPeer()->optUnchoking()) {
|
||||
fastOptUnchoker = true;
|
||||
(*peerIter).disableOptUnchoking();
|
||||
|
@ -164,16 +164,16 @@ void BtLeecherStateChoke::regularUnchoke(std::deque<PeerEntry>& peerEntries)
|
|||
}
|
||||
if(fastOptUnchoker) {
|
||||
std::random_shuffle(peerIter, peerEntries.end(),
|
||||
*(SimpleRandomizer::getInstance().get()));
|
||||
*(SimpleRandomizer::getInstance().get()));
|
||||
for(std::deque<PeerEntry>::iterator i = peerIter; i != peerEntries.end();
|
||||
++i) {
|
||||
++i) {
|
||||
if((*i).getPeer()->peerInterested()) {
|
||||
(*i).enableOptUnchoking();
|
||||
_logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str());
|
||||
break;
|
||||
(*i).enableOptUnchoking();
|
||||
_logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str());
|
||||
break;
|
||||
} else {
|
||||
(*i).disableChokingRequired();
|
||||
_logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str());
|
||||
(*i).disableChokingRequired();
|
||||
_logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,15 +203,15 @@ BtLeecherStateChoke::executeChoke(const std::deque<SharedHandle<Peer> >& peerSet
|
|||
|
||||
std::deque<PeerEntry> peerEntries;
|
||||
std::transform(peerSet.begin(), peerSet.end(),
|
||||
std::back_inserter(peerEntries),
|
||||
BtLeecherStateChokeGenPeerEntry());
|
||||
std::back_inserter(peerEntries),
|
||||
BtLeecherStateChokeGenPeerEntry());
|
||||
|
||||
peerEntries.erase(std::remove_if(peerEntries.begin(), peerEntries.end(),
|
||||
std::mem_fun_ref(&PeerEntry::isSnubbing)),
|
||||
peerEntries.end());
|
||||
|
||||
std::mem_fun_ref(&PeerEntry::isSnubbing)),
|
||||
peerEntries.end());
|
||||
|
||||
std::for_each(peerEntries.begin(), peerEntries.end(),
|
||||
std::mem_fun_ref(&PeerEntry::enableChokingRequired));
|
||||
std::mem_fun_ref(&PeerEntry::enableChokingRequired));
|
||||
|
||||
// planned optimistic unchoke
|
||||
if(_round == 0) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
virtual SharedHandle<BtHandshakeMessage>
|
||||
createHandshakeMessage(const unsigned char* infoHash,
|
||||
const unsigned char* peerId) = 0;
|
||||
const unsigned char* peerId) = 0;
|
||||
|
||||
virtual SharedHandle<BtMessage>
|
||||
createRequestMessage(const SharedHandle<Piece>& piece, size_t blockIndex) = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -81,8 +81,8 @@ void BtPieceMessage::doReceivedAction() {
|
|||
return;
|
||||
}
|
||||
RequestSlot slot = dispatcher->getOutstandingRequest(index,
|
||||
begin,
|
||||
blockLength);
|
||||
begin,
|
||||
blockLength);
|
||||
peer->updateDownloadLength(blockLength);
|
||||
if(!RequestSlot::isNull(slot)) {
|
||||
peer->snubbing(false);
|
||||
|
@ -90,24 +90,24 @@ void BtPieceMessage::doReceivedAction() {
|
|||
PieceHandle piece = pieceStorage->getPiece(index);
|
||||
off_t offset = (off_t)index*_downloadContext->getPieceLength()+begin;
|
||||
logger->debug(MSG_PIECE_RECEIVED,
|
||||
cuid, index, begin, blockLength, offset, slot.getBlockIndex());
|
||||
cuid, index, begin, blockLength, offset, slot.getBlockIndex());
|
||||
pieceStorage->getDiskAdaptor()->writeData(block, blockLength, offset);
|
||||
piece->completeBlock(slot.getBlockIndex());
|
||||
logger->debug(MSG_PIECE_BITFIELD, cuid,
|
||||
util::toHex(piece->getBitfield(),
|
||||
piece->getBitfieldLength()).c_str());
|
||||
util::toHex(piece->getBitfield(),
|
||||
piece->getBitfieldLength()).c_str());
|
||||
piece->updateHash(begin, block, blockLength);
|
||||
dispatcher->removeOutstandingRequest(slot);
|
||||
if(piece->pieceComplete()) {
|
||||
if(checkPieceHash(piece)) {
|
||||
onNewPiece(piece);
|
||||
onNewPiece(piece);
|
||||
} else {
|
||||
onWrongPiece(piece);
|
||||
onWrongPiece(piece);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger->debug("CUID#%d - RequestSlot not found, index=%d, begin=%d",
|
||||
cuid, index, begin);
|
||||
cuid, index, begin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ const unsigned char* BtPieceMessage::getMessageHeader() {
|
|||
*/
|
||||
msgHeader = new unsigned char[MESSAGE_HEADER_LENGTH];
|
||||
bittorrent::createPeerMessageString(msgHeader, MESSAGE_HEADER_LENGTH,
|
||||
9+blockLength, ID);
|
||||
9+blockLength, ID);
|
||||
bittorrent::setIntParam(&msgHeader[5], index);
|
||||
bittorrent::setIntParam(&msgHeader[9], begin);
|
||||
}
|
||||
|
@ -141,16 +141,16 @@ void BtPieceMessage::send() {
|
|||
}
|
||||
if(!sendingInProgress) {
|
||||
logger->info(MSG_SEND_PEER_MESSAGE,
|
||||
cuid, peer->ipaddr.c_str(), peer->port,
|
||||
toString().c_str());
|
||||
cuid, peer->ipaddr.c_str(), peer->port,
|
||||
toString().c_str());
|
||||
getMessageHeader();
|
||||
peerConnection->sendMessage(msgHeader, getMessageHeaderLength());
|
||||
off_t pieceDataOffset =
|
||||
(off_t)index*_downloadContext->getPieceLength()+begin;
|
||||
size_t writtenLength = sendPieceData(pieceDataOffset, blockLength);
|
||||
logger->debug("msglength = %lu bytes",
|
||||
static_cast<unsigned long>(getMessageHeaderLength()+
|
||||
blockLength));
|
||||
static_cast<unsigned long>(getMessageHeaderLength()+
|
||||
blockLength));
|
||||
peer->updateUploadLength(writtenLength);
|
||||
} else {
|
||||
ssize_t writtenLength = peerConnection->sendPendingData();
|
||||
|
@ -172,13 +172,13 @@ size_t BtPieceMessage::sendPieceData(off_t offset, size_t length) const {
|
|||
|
||||
std::string BtPieceMessage::toString() const {
|
||||
return strconcat(NAME, " index=", util::itos(index), ", begin=",
|
||||
util::itos(begin), ", length=", util::itos(blockLength));
|
||||
util::itos(begin), ", length=", util::itos(blockLength));
|
||||
}
|
||||
|
||||
bool BtPieceMessage::checkPieceHash(const PieceHandle& piece) {
|
||||
if(piece->isHashCalculated()) {
|
||||
logger->debug("Hash is available!! index=%lu",
|
||||
static_cast<unsigned long>(piece->getIndex()));
|
||||
static_cast<unsigned long>(piece->getIndex()));
|
||||
return
|
||||
piece->getHashString()==_downloadContext->getPieceHash(piece->getIndex());
|
||||
} else {
|
||||
|
@ -224,15 +224,15 @@ void BtPieceMessage::onChokingEvent(const BtChokingEvent& event)
|
|||
!sendingInProgress &&
|
||||
!peer->isInAmAllowedIndexSet(index)) {
|
||||
logger->debug(MSG_REJECT_PIECE_CHOKED,
|
||||
cuid,
|
||||
index,
|
||||
begin,
|
||||
blockLength);
|
||||
cuid,
|
||||
index,
|
||||
begin,
|
||||
blockLength);
|
||||
|
||||
if(peer->isFastExtensionEnabled()) {
|
||||
BtMessageHandle rej = messageFactory->createRejectMessage(index,
|
||||
begin,
|
||||
blockLength);
|
||||
begin,
|
||||
blockLength);
|
||||
dispatcher->addMessageToQueue(rej);
|
||||
}
|
||||
invalidate = true;
|
||||
|
@ -248,11 +248,11 @@ void BtPieceMessage::onCancelSendingPieceEvent
|
|||
begin == event.getBegin() &&
|
||||
blockLength == event.getLength()) {
|
||||
logger->debug(MSG_REJECT_PIECE_CANCEL,
|
||||
cuid, index, begin, blockLength);
|
||||
cuid, index, begin, blockLength);
|
||||
if(peer->isFastExtensionEnabled()) {
|
||||
BtMessageHandle rej = messageFactory->createRejectMessage(index,
|
||||
begin,
|
||||
blockLength);
|
||||
begin,
|
||||
blockLength);
|
||||
dispatcher->addMessageToQueue(rej);
|
||||
}
|
||||
invalidate = true;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -48,8 +48,8 @@ private:
|
|||
size_t pieceLength;
|
||||
public:
|
||||
BtPieceMessageValidator(const BtPieceMessage* message,
|
||||
size_t numPiece,
|
||||
size_t pieceLength):
|
||||
size_t numPiece,
|
||||
size_t pieceLength):
|
||||
message(message),
|
||||
numPiece(numPiece),
|
||||
pieceLength(pieceLength) {}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
|
@ -67,7 +67,7 @@ void BtPostDownloadHandler::getNextRequestGroups
|
|||
RequestGroup* requestGroup)
|
||||
{
|
||||
_logger->debug("Generating RequestGroups for Torrent file %s",
|
||||
requestGroup->getFirstFilePath().c_str());
|
||||
requestGroup->getFirstFilePath().c_str());
|
||||
std::string content;
|
||||
try {
|
||||
requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile();
|
||||
|
@ -79,8 +79,8 @@ void BtPostDownloadHandler::getNextRequestGroups
|
|||
}
|
||||
std::deque<SharedHandle<RequestGroup> > newRgs;
|
||||
createRequestGroupForBitTorrent(newRgs, requestGroup->getOption(),
|
||||
std::deque<std::string>(),
|
||||
content);
|
||||
std::deque<std::string>(),
|
||||
content);
|
||||
requestGroup->followedBy(newRgs.begin(), newRgs.end());
|
||||
groups.insert(groups.end(), newRgs.begin(), newRgs.end());
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue