mirror of https://github.com/aria2/aria2
2010-03-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Defined cuid_t as int64_t. Removed texts containing "CUID#%D" from translatable texts because it is used in log and debugging purpose.pull/1/head
parent
322a0d1ad7
commit
de8fef01f3
43
ChangeLog
43
ChangeLog
|
@ -1,3 +1,46 @@
|
|||
2010-03-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Defined cuid_t as int64_t. Removed texts containing "CUID#%D" from
|
||||
translatable texts because it is used in log and debugging
|
||||
purpose.
|
||||
* src/AbstractCommand.cc
|
||||
* src/ActivePeerConnectionCommand.cc
|
||||
* src/BtPieceMessage.cc
|
||||
* src/CUIDCounter.h
|
||||
* src/CheckIntegrityCommand.cc
|
||||
* src/CheckIntegrityDispatcherCommand.cc
|
||||
* src/Command.h
|
||||
* src/CreateRequestCommand.cc
|
||||
* src/DHTEntryPointNameResolveCommand.cc
|
||||
* src/DefaultBtInteractive.cc
|
||||
* src/DefaultBtMessageDispatcher.cc
|
||||
* src/DownloadCommand.cc
|
||||
* src/FileAllocationCommand.cc
|
||||
* src/FileAllocationDispatcherCommand.cc
|
||||
* src/FtpConnection.cc
|
||||
* src/FtpInitiateConnectionCommand.cc
|
||||
* src/FtpNegotiationCommand.cc
|
||||
* src/HttpConnection.cc
|
||||
* src/HttpInitiateConnectionCommand.cc
|
||||
* src/HttpListenCommand.cc
|
||||
* src/HttpResponse.cc
|
||||
* src/HttpServerBodyCommand.cc
|
||||
* src/HttpServerCommand.cc
|
||||
* src/HttpServerResponseCommand.cc
|
||||
* src/InitiateConnectionCommand.cc
|
||||
* src/InitiatorMSEHandshakeCommand.cc
|
||||
* src/MSEHandshake.cc
|
||||
* src/PeerAbstractCommand.cc
|
||||
* src/PeerConnection.cc
|
||||
* src/PeerInitiateConnectionCommand.cc
|
||||
* src/PeerInteractionCommand.cc
|
||||
* src/PeerListenCommand.cc
|
||||
* src/PeerReceiveHandshakeCommand.cc
|
||||
* src/SegmentMan.cc
|
||||
* src/SimpleBtMessage.cc
|
||||
* src/TrackerWatcherCommand.cc
|
||||
* src/message.h
|
||||
|
||||
2010-03-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Use gid_t type for gid.
|
||||
|
|
|
@ -99,19 +99,19 @@ AbstractCommand::~AbstractCommand() {
|
|||
|
||||
bool AbstractCommand::execute() {
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - socket: read:%d, write:%d, hup:%d, err:%d",
|
||||
cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent);
|
||||
logger->debug("CUID#%s - socket: read:%d, write:%d, hup:%d, err:%d",
|
||||
util::itos(cuid).c_str(), _readEvent, _writeEvent, _hupEvent,
|
||||
_errorEvent);
|
||||
}
|
||||
try {
|
||||
if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) {
|
||||
//logger->debug("CUID#%d - finished.", cuid);
|
||||
return true;
|
||||
}
|
||||
if(!req.isNull() && req->removalRequested()) {
|
||||
if(logger->debug()) {
|
||||
logger->debug
|
||||
("CUID#%d - Discard original URI=%s because it is requested.",
|
||||
cuid, req->getUri().c_str());
|
||||
("CUID#%s - Discard original URI=%s because it is requested.",
|
||||
util::itos(cuid).c_str(), req->getUri().c_str());
|
||||
}
|
||||
return prepareForRetry(0);
|
||||
}
|
||||
|
@ -121,11 +121,12 @@ 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());
|
||||
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Use faster Request hostname=%s, port=%u",
|
||||
util::itos(cuid).c_str(),
|
||||
fasterRequest->getHost().c_str(),
|
||||
fasterRequest->getPort());
|
||||
}
|
||||
// Cancel current Request object and use faster one.
|
||||
_fileEntry->removeRequest(req);
|
||||
Command* command =
|
||||
|
@ -158,7 +159,9 @@ bool AbstractCommand::execute() {
|
|||
}
|
||||
if(_segments.empty()) {
|
||||
// TODO socket could be pooled here if pipelining is enabled...
|
||||
logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_NO_SEGMENT_AVAILABLE, util::itos(cuid).c_str());
|
||||
}
|
||||
// When all segments are ignored in SegmentMan, there are
|
||||
// no URIs available, so don't retry.
|
||||
if(_requestGroup->getSegmentMan()->allSegmentsIgnored()) {
|
||||
|
@ -209,7 +212,7 @@ bool AbstractCommand::execute() {
|
|||
logger->error(MSG_DOWNLOAD_ABORTED,
|
||||
DL_ABORT_EX2(StringFormat
|
||||
("URI=%s", req->getCurrentUri().c_str()).str(),err),
|
||||
cuid, req->getUri().c_str());
|
||||
util::itos(cuid).c_str(), req->getUri().c_str());
|
||||
_fileEntry->addURIResult(req->getUri(), err.getCode());
|
||||
_requestGroup->setLastUriResult(req->getUri(), err.getCode());
|
||||
}
|
||||
|
@ -218,18 +221,24 @@ bool AbstractCommand::execute() {
|
|||
return true;
|
||||
} catch(DlRetryEx& err) {
|
||||
assert(!req.isNull());
|
||||
logger->info(MSG_RESTARTING_DOWNLOAD,
|
||||
DL_RETRY_EX2(StringFormat
|
||||
("URI=%s", req->getCurrentUri().c_str()).str(),err),
|
||||
cuid, req->getUri().c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_RESTARTING_DOWNLOAD,
|
||||
DL_RETRY_EX2(StringFormat
|
||||
("URI=%s", req->getCurrentUri().c_str()).str(),
|
||||
err),
|
||||
util::itos(cuid).c_str(), req->getUri().c_str());
|
||||
}
|
||||
req->addTryCount();
|
||||
req->resetRedirectCount();
|
||||
const unsigned int maxTries = getOption()->getAsInt(PREF_MAX_TRIES);
|
||||
bool isAbort = maxTries != 0 && req->getTryCount() >= maxTries;
|
||||
if(isAbort) {
|
||||
onAbort();
|
||||
logger->info(MSG_MAX_TRY, cuid, req->getTryCount());
|
||||
logger->error(MSG_DOWNLOAD_ABORTED, err, cuid, req->getUri().c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_MAX_TRY, util::itos(cuid).c_str(), req->getTryCount());
|
||||
}
|
||||
logger->error(MSG_DOWNLOAD_ABORTED, err, util::itos(cuid).c_str(),
|
||||
req->getUri().c_str());
|
||||
_fileEntry->addURIResult(req->getUri(), err.getCode());
|
||||
_requestGroup->setLastUriResult(req->getUri(), err.getCode());
|
||||
tryReserved();
|
||||
|
@ -257,15 +266,17 @@ void AbstractCommand::tryReserved() {
|
|||
// can assume that there are no in-flight request object.
|
||||
if(entry->getLength() == 0 && entry->getRemainingUris().empty()) {
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Not trying next request."
|
||||
logger->debug("CUID#%s - Not trying next request."
|
||||
" No reserved/pooled request is remaining and"
|
||||
" total length is still unknown.", cuid);
|
||||
" total length is still unknown.",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Trying reserved/pooled request.", cuid);
|
||||
logger->debug("CUID#%s - Trying reserved/pooled request.",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
std::vector<Command*> commands;
|
||||
_requestGroup->createNextCommand(commands, e, 1);
|
||||
|
@ -280,8 +291,8 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
|
|||
if(!req.isNull()) {
|
||||
_fileEntry->poolRequest(req);
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Pooling request URI=%s",
|
||||
cuid, req->getUri().c_str());
|
||||
logger->debug("CUID#%s - Pooling request URI=%s",
|
||||
util::itos(cuid).c_str(), req->getUri().c_str());
|
||||
}
|
||||
if(!_requestGroup->getSegmentMan().isNull()) {
|
||||
_requestGroup->getSegmentMan()->recognizeSegmentFor(_fileEntry);
|
||||
|
@ -309,7 +320,7 @@ void AbstractCommand::onAbort() {
|
|||
_fileEntry->removeRequest(req);
|
||||
}
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Aborting download", cuid);
|
||||
logger->debug("CUID#%s - Aborting download", util::itos(cuid).c_str());
|
||||
}
|
||||
if(!_requestGroup->getPieceStorage().isNull()) {
|
||||
_requestGroup->getSegmentMan()->cancelSegment(cuid);
|
||||
|
@ -494,11 +505,12 @@ SharedHandle<Request> AbstractCommand::createProxyRequest() const
|
|||
proxyRequest.reset(new Request());
|
||||
if(proxyRequest->setUri(proxy)) {
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Using proxy", cuid);
|
||||
logger->debug("CUID#%s - Using proxy", util::itos(cuid).c_str());
|
||||
}
|
||||
} else {
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Failed to parse proxy string", cuid);
|
||||
logger->debug("CUID#%s - Failed to parse proxy string",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
proxyRequest.reset();
|
||||
}
|
||||
|
@ -516,7 +528,10 @@ bool AbstractCommand::isAsyncNameResolverInitialized() const
|
|||
void AbstractCommand::initAsyncNameResolver(const std::string& hostname)
|
||||
{
|
||||
_asyncNameResolver.reset(new AsyncNameResolver());
|
||||
logger->info(MSG_RESOLVING_HOSTNAME, cuid, hostname.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_RESOLVING_HOSTNAME,
|
||||
util::itos(cuid).c_str(), hostname.c_str());
|
||||
}
|
||||
_asyncNameResolver->resolve(hostname);
|
||||
setNameResolverCheck(_asyncNameResolver);
|
||||
}
|
||||
|
@ -531,7 +546,8 @@ bool AbstractCommand::asyncResolveHostname()
|
|||
e->_requestGroupMan->getOrCreateServerStat
|
||||
(req->getHost(), req->getProtocol())->setError();
|
||||
}
|
||||
throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED, cuid,
|
||||
throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED,
|
||||
util::itos(cuid).c_str(),
|
||||
_asyncNameResolver->getHostname().c_str(),
|
||||
_asyncNameResolver->getError().c_str()).str());
|
||||
default:
|
||||
|
@ -595,8 +611,11 @@ 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);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECT_FAILED_AND_RETRY,
|
||||
util::itos(cuid).c_str(),
|
||||
connectedAddr.c_str(), connectedPort);
|
||||
}
|
||||
Command* command =
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(cuid, req, _fileEntry, _requestGroup, e);
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "DownloadContext.h"
|
||||
#include "bittorrent_helper.h"
|
||||
#include "wallclock.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -140,8 +141,10 @@ void ActivePeerConnectionCommand::connectToPeer(const SharedHandle<Peer>& peer)
|
|||
command->setPeerStorage(_peerStorage);
|
||||
command->setPieceStorage(_pieceStorage);
|
||||
e->commands.push_back(command);
|
||||
logger->info(MSG_CONNECTING_TO_PEER,
|
||||
cuid, peer->ipaddr.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECTING_TO_PEER,
|
||||
util::itos(cuid).c_str(), peer->ipaddr.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void ActivePeerConnectionCommand::setBtRuntime
|
||||
|
|
|
@ -90,13 +90,13 @@ void BtPieceMessage::doReceivedAction() {
|
|||
off_t offset = (off_t)index*_downloadContext->getPieceLength()+begin;
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_PIECE_RECEIVED,
|
||||
cuid, index, begin, blockLength, offset,
|
||||
util::itos(cuid).c_str(), index, begin, blockLength, offset,
|
||||
slot.getBlockIndex());
|
||||
}
|
||||
pieceStorage->getDiskAdaptor()->writeData(block, blockLength, offset);
|
||||
piece->completeBlock(slot.getBlockIndex());
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_PIECE_BITFIELD, cuid,
|
||||
logger->debug(MSG_PIECE_BITFIELD, util::itos(cuid).c_str(),
|
||||
util::toHex(piece->getBitfield(),
|
||||
piece->getBitfieldLength()).c_str());
|
||||
}
|
||||
|
@ -111,8 +111,8 @@ void BtPieceMessage::doReceivedAction() {
|
|||
}
|
||||
} else {
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - RequestSlot not found, index=%d, begin=%d",
|
||||
cuid, index, begin);
|
||||
logger->debug("CUID#%s - RequestSlot not found, index=%d, begin=%d",
|
||||
util::itos(cuid).c_str(), index, begin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ void BtPieceMessage::send() {
|
|||
if(!sendingInProgress) {
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SEND_PEER_MESSAGE,
|
||||
cuid, peer->ipaddr.c_str(), peer->port,
|
||||
util::itos(cuid).c_str(), peer->ipaddr.c_str(), peer->port,
|
||||
toString().c_str());
|
||||
}
|
||||
unsigned char* msgHdr = createMessageHeader();
|
||||
|
@ -209,13 +209,18 @@ bool BtPieceMessage::checkPieceHash(const SharedHandle<Piece>& piece) {
|
|||
}
|
||||
|
||||
void BtPieceMessage::onNewPiece(const SharedHandle<Piece>& piece) {
|
||||
logger->info(MSG_GOT_NEW_PIECE, cuid, piece->getIndex());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_GOT_NEW_PIECE, util::itos(cuid).c_str(),piece->getIndex());
|
||||
}
|
||||
pieceStorage->completePiece(piece);
|
||||
pieceStorage->advertisePiece(cuid, piece->getIndex());
|
||||
}
|
||||
|
||||
void BtPieceMessage::onWrongPiece(const SharedHandle<Piece>& piece) {
|
||||
logger->info(MSG_GOT_WRONG_PIECE, cuid, piece->getIndex());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_GOT_WRONG_PIECE,
|
||||
util::itos(cuid).c_str(), piece->getIndex());
|
||||
}
|
||||
erasePieceOnDisk(piece);
|
||||
piece->clearAllBlock();
|
||||
piece->destroyHashContext();
|
||||
|
@ -243,7 +248,8 @@ void BtPieceMessage::onChokingEvent(const BtChokingEvent& event)
|
|||
!sendingInProgress &&
|
||||
!peer->isInAmAllowedIndexSet(index)) {
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_REJECT_PIECE_CHOKED, cuid, index, begin, blockLength);
|
||||
logger->debug(MSG_REJECT_PIECE_CHOKED,
|
||||
util::itos(cuid).c_str(), index, begin, blockLength);
|
||||
}
|
||||
if(peer->isFastExtensionEnabled()) {
|
||||
BtMessageHandle rej = messageFactory->createRejectMessage(index,
|
||||
|
@ -264,7 +270,8 @@ void BtPieceMessage::onCancelSendingPieceEvent
|
|||
begin == event.getBegin() &&
|
||||
blockLength == event.getLength()) {
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_REJECT_PIECE_CANCEL, cuid, index, begin, blockLength);
|
||||
logger->debug(MSG_REJECT_PIECE_CANCEL,
|
||||
util::itos(cuid).c_str(), index, begin, blockLength);
|
||||
}
|
||||
if(peer->isFastExtensionEnabled()) {
|
||||
BtMessageHandle rej = messageFactory->createRejectMessage(index,
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
cuid_t newID()
|
||||
{
|
||||
if(_count == INT32_MAX) {
|
||||
if(_count == INT64_MAX) {
|
||||
_count = 0;
|
||||
}
|
||||
return ++_count;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "DownloadContext.h"
|
||||
#include "a2functional.h"
|
||||
#include "RecoverableException.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -100,9 +101,10 @@ bool CheckIntegrityCommand::executeInternal()
|
|||
bool CheckIntegrityCommand::handleException(Exception& e)
|
||||
{
|
||||
_e->_checkIntegrityMan->dropPickedEntry();
|
||||
logger->error(MSG_FILE_VALIDATION_FAILURE, e, cuid);
|
||||
logger->error(MSG_FILE_VALIDATION_FAILURE, e, util::itos(cuid).c_str());
|
||||
logger->error(MSG_DOWNLOAD_NOT_COMPLETE,
|
||||
cuid, _requestGroup->getDownloadContext()->getBasePath().c_str());
|
||||
util::itos(cuid).c_str(),
|
||||
_requestGroup->getDownloadContext()->getBasePath().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "message.h"
|
||||
#include "Logger.h"
|
||||
#include "FileEntry.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -54,8 +55,10 @@ Command* CheckIntegrityDispatcherCommand::createCommand
|
|||
(const SharedHandle<CheckIntegrityEntry>& entry)
|
||||
{
|
||||
cuid_t newCUID = _e->newCUID();
|
||||
logger->info("CUID#%d - Dispatching CheckIntegrityCommand CUID#%d.",
|
||||
cuid, newCUID);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Dispatching CheckIntegrityCommand CUID#%s.",
|
||||
util::itos(cuid).c_str(), util::itos(newCUID).c_str());
|
||||
}
|
||||
return new CheckIntegrityCommand
|
||||
(newCUID, entry->getRequestGroup(), _e, entry);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class Logger;
|
|||
|
||||
typedef int32_t CommandUuid;
|
||||
|
||||
typedef int32_t cuid_t;
|
||||
typedef int64_t cuid_t;
|
||||
|
||||
class Command {
|
||||
public:
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "Option.h"
|
||||
#include "SleepCommand.h"
|
||||
#include "Logger.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -112,7 +113,8 @@ bool CreateRequestCommand::prepareForRetry(time_t wait)
|
|||
_requestGroup->getSegmentMan()->cancelSegment(cuid);
|
||||
}
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Reusing CreateRequestCommand", cuid);
|
||||
logger->debug("CUID#%s - Reusing CreateRequestCommand",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup, this, wait);
|
||||
e->commands.push_back(scom);
|
||||
|
|
|
@ -151,19 +151,26 @@ bool DHTEntryPointNameResolveCommand::resolveHostname
|
|||
{
|
||||
switch(resolver->getStatus()) {
|
||||
case AsyncNameResolver::STATUS_READY:
|
||||
logger->info(MSG_RESOLVING_HOSTNAME, cuid, hostname.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_RESOLVING_HOSTNAME,
|
||||
util::itos(cuid).c_str(), hostname.c_str());
|
||||
}
|
||||
resolver->resolve(hostname);
|
||||
setNameResolverCheck(resolver);
|
||||
return false;
|
||||
case AsyncNameResolver::STATUS_SUCCESS:
|
||||
logger->info(MSG_NAME_RESOLUTION_COMPLETE, cuid,
|
||||
resolver->getHostname().c_str(),
|
||||
resolver->getResolvedAddresses().front().c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_NAME_RESOLUTION_COMPLETE,
|
||||
util::itos(cuid).c_str(),
|
||||
resolver->getHostname().c_str(),
|
||||
resolver->getResolvedAddresses().front().c_str());
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case AsyncNameResolver::STATUS_ERROR:
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(MSG_NAME_RESOLUTION_FAILED, cuid,
|
||||
(StringFormat(MSG_NAME_RESOLUTION_FAILED,
|
||||
util::itos(cuid).c_str(),
|
||||
hostname.c_str(),
|
||||
resolver->getError().c_str()).str());
|
||||
default:
|
||||
|
|
|
@ -112,29 +112,38 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) {
|
|||
PEER_ID_LENGTH) == 0) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat
|
||||
("CUID#%d - Drop connection from the same Peer ID", cuid).str());
|
||||
("CUID#%s - Drop connection from the same Peer ID",
|
||||
util::itos(cuid).c_str()).str());
|
||||
}
|
||||
|
||||
peer->setPeerId(message->getPeerId());
|
||||
|
||||
if(message->isFastExtensionSupported()) {
|
||||
peer->setFastExtensionEnabled(true);
|
||||
logger->info(MSG_FAST_EXTENSION_ENABLED, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_FAST_EXTENSION_ENABLED, util::itos(cuid).c_str());
|
||||
}
|
||||
}
|
||||
if(message->isExtendedMessagingEnabled()) {
|
||||
peer->setExtendedMessagingEnabled(true);
|
||||
if(!_utPexEnabled) {
|
||||
_extensionMessageRegistry->removeExtension("ut_pex");
|
||||
}
|
||||
logger->info(MSG_EXTENDED_MESSAGING_ENABLED, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_EXTENDED_MESSAGING_ENABLED, util::itos(cuid).c_str());
|
||||
}
|
||||
}
|
||||
if(message->isDHTEnabled()) {
|
||||
peer->setDHTEnabled(true);
|
||||
logger->info(MSG_DHT_ENABLED_PEER, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_DHT_ENABLED_PEER, util::itos(cuid).c_str());
|
||||
}
|
||||
}
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_RECEIVE_PEER_MESSAGE, util::itos(cuid).c_str(),
|
||||
peer->ipaddr.c_str(), peer->port,
|
||||
message->toString().c_str());
|
||||
}
|
||||
logger->info(MSG_RECEIVE_PEER_MESSAGE, cuid,
|
||||
peer->ipaddr.c_str(), peer->port,
|
||||
message->toString().c_str());
|
||||
return message;
|
||||
}
|
||||
|
||||
|
@ -267,7 +276,7 @@ size_t DefaultBtInteractive::receiveMessages() {
|
|||
}
|
||||
++msgcount;
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_RECEIVE_PEER_MESSAGE, cuid,
|
||||
logger->info(MSG_RECEIVE_PEER_MESSAGE, util::itos(cuid).c_str(),
|
||||
peer->ipaddr.c_str(), peer->port,
|
||||
message->toString().c_str());
|
||||
}
|
||||
|
@ -307,7 +316,7 @@ void DefaultBtInteractive::decideInterest() {
|
|||
if(_pieceStorage->hasMissingPiece(peer)) {
|
||||
if(!peer->amInterested()) {
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_PEER_INTERESTED, cuid);
|
||||
logger->debug(MSG_PEER_INTERESTED, util::itos(cuid).c_str());
|
||||
}
|
||||
dispatcher->
|
||||
addMessageToQueue(messageFactory->createInterestedMessage());
|
||||
|
@ -315,7 +324,7 @@ void DefaultBtInteractive::decideInterest() {
|
|||
} else {
|
||||
if(peer->amInterested()) {
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_PEER_NOT_INTERESTED, cuid);
|
||||
logger->debug(MSG_PEER_NOT_INTERESTED, util::itos(cuid).c_str());
|
||||
}
|
||||
dispatcher->
|
||||
addMessageToQueue(messageFactory->createNotInterestedMessage());
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "a2algo.h"
|
||||
#include "RequestGroupMan.h"
|
||||
#include "RequestGroup.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -152,7 +153,7 @@ public:
|
|||
{
|
||||
if(_logger->debug()) {
|
||||
_logger->debug(MSG_DELETING_REQUEST_SLOT,
|
||||
_cuid,
|
||||
util::itos(_cuid).c_str(),
|
||||
slot.getIndex(),
|
||||
slot.getBlockIndex());
|
||||
_logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin());
|
||||
|
@ -203,7 +204,7 @@ public:
|
|||
if(!_peer->isInPeerAllowedIndexSet(slot.getIndex())) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug(MSG_DELETING_REQUEST_SLOT_CHOKED,
|
||||
_cuid,
|
||||
util::itos(_cuid).c_str(),
|
||||
slot.getIndex(),
|
||||
slot.getBlockIndex());
|
||||
_logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin());
|
||||
|
@ -278,7 +279,7 @@ public:
|
|||
if(slot.isTimeout(_requestTimeout)) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug(MSG_DELETING_REQUEST_SLOT_TIMEOUT,
|
||||
_cuid,
|
||||
util::itos(_cuid).c_str(),
|
||||
slot.getBlockIndex());
|
||||
_logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin());
|
||||
}
|
||||
|
@ -287,7 +288,7 @@ public:
|
|||
} else if(slot.getPiece()->hasBlock(slot.getBlockIndex())) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug(MSG_DELETING_REQUEST_SLOT_ACQUIRED,
|
||||
_cuid,
|
||||
util::itos(_cuid).c_str(),
|
||||
slot.getBlockIndex());
|
||||
_logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin());
|
||||
}
|
||||
|
|
|
@ -204,7 +204,9 @@ bool DownloadCommand::executeInternal() {
|
|||
// If segment->getLength() == 0, the server doesn't provide
|
||||
// content length, but the client detected that download
|
||||
// completed.
|
||||
logger->info(MSG_SEGMENT_DOWNLOAD_COMPLETED, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SEGMENT_DOWNLOAD_COMPLETED, util::itos(cuid).c_str());
|
||||
}
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
|
||||
{
|
||||
|
|
|
@ -89,8 +89,8 @@ bool FileAllocationCommand::executeInternal()
|
|||
bool FileAllocationCommand::handleException(Exception& e)
|
||||
{
|
||||
_e->_fileAllocationMan->dropPickedEntry();
|
||||
logger->error(MSG_FILE_ALLOCATION_FAILURE, e, cuid);
|
||||
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid,
|
||||
logger->error(MSG_FILE_ALLOCATION_FAILURE, e, util::itos(cuid).c_str());
|
||||
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, util::itos(cuid).c_str(),
|
||||
_requestGroup->getDownloadContext()->getBasePath().c_str());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "message.h"
|
||||
#include "Logger.h"
|
||||
#include "DownloadContext.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -51,7 +52,9 @@ Command* FileAllocationDispatcherCommand::createCommand
|
|||
(const SharedHandle<FileAllocationEntry>& entry)
|
||||
{
|
||||
cuid_t newCUID = _e->newCUID();
|
||||
logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_FILE_ALLOCATION_DISPATCH, util::itos(newCUID).c_str());
|
||||
}
|
||||
FileAllocationCommand* command =
|
||||
new FileAllocationCommand(newCUID, entry->getRequestGroup(), _e, entry);
|
||||
return command;
|
||||
|
|
|
@ -80,7 +80,10 @@ bool FtpConnection::sendUser()
|
|||
std::string request = "USER ";
|
||||
request += _authConfig->getUser();
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, "USER ********");
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(),"USER ********");
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -93,7 +96,10 @@ bool FtpConnection::sendPass()
|
|||
std::string request = "PASS ";
|
||||
request += _authConfig->getPassword();
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, "PASS ********");
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(),"PASS ********");
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -112,7 +118,10 @@ bool FtpConnection::sendType()
|
|||
std::string request = "TYPE ";
|
||||
request += type;
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(),request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -123,7 +132,10 @@ bool FtpConnection::sendPwd()
|
|||
{
|
||||
if(_socketBuffer.sendBufferIsEmpty()) {
|
||||
std::string request = "PWD\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(),request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -133,15 +145,20 @@ bool FtpConnection::sendPwd()
|
|||
bool FtpConnection::sendCwd()
|
||||
{
|
||||
if(_socketBuffer.sendBufferIsEmpty()) {
|
||||
logger->info("CUID#%d - Using base working directory '%s'",
|
||||
cuid, _baseWorkingDir.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Using base working directory '%s'",
|
||||
util::itos(cuid).c_str(), _baseWorkingDir.c_str());
|
||||
}
|
||||
std::string request = "CWD ";
|
||||
if(_baseWorkingDir != "/") {
|
||||
request += _baseWorkingDir;
|
||||
}
|
||||
request += util::percentDecode(req->getDir());
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(),request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -154,7 +171,10 @@ bool FtpConnection::sendMdtm()
|
|||
std::string request = "MDTM ";
|
||||
request += util::percentDecode(req->getFile());
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(), request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -167,7 +187,10 @@ bool FtpConnection::sendSize()
|
|||
std::string request = "SIZE ";
|
||||
request += util::percentDecode(req->getFile());
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(), request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -178,7 +201,10 @@ bool FtpConnection::sendPasv()
|
|||
{
|
||||
if(_socketBuffer.sendBufferIsEmpty()) {
|
||||
static const std::string request("PASV\r\n");
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(), request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -216,7 +242,10 @@ bool FtpConnection::sendPort(const SharedHandle<SocketCore>& serverSocket)
|
|||
request += ",";
|
||||
request += util::uitos(addrinfo.second%256);
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(), request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -232,9 +261,11 @@ bool FtpConnection::sendRest(const SharedHandle<Segment>& segment)
|
|||
} else {
|
||||
request += util::itos(segment->getPositionToWrite());
|
||||
}
|
||||
request += "\r\n";
|
||||
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
request += "\r\n";
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(), request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -247,7 +278,10 @@ bool FtpConnection::sendRetr()
|
|||
std::string request = "RETR ";
|
||||
request += util::percentDecode(req->getFile());
|
||||
request += "\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(), request.c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
}
|
||||
_socketBuffer.send();
|
||||
|
@ -341,7 +375,10 @@ bool FtpConnection::bulkReceiveResponse(std::pair<unsigned int, std::string>& re
|
|||
if((length = findEndOfResponse(status, strbuf)) != std::string::npos) {
|
||||
response.first = status;
|
||||
response.second = strbuf.substr(0, length);
|
||||
logger->info(MSG_RECEIVE_RESPONSE, cuid, response.second.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_RECEIVE_RESPONSE,
|
||||
util::itos(cuid).c_str(), response.second.c_str());
|
||||
}
|
||||
strbuf.erase(0, length);
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "HttpConnection.h"
|
||||
#include "Socket.h"
|
||||
#include "DownloadContext.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -76,7 +77,10 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
|||
e->popPooledSocket(options, req->getHost(), req->getPort());
|
||||
std::string proxyMethod = resolveProxyMethod(req->getProtocol());
|
||||
if(pooledSocket.isNull()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER, cuid, addr.c_str(), port);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER,
|
||||
util::itos(cuid).c_str(), addr.c_str(), port);
|
||||
}
|
||||
socket.reset(new SocketCore());
|
||||
socket->establishConnection(addr, port);
|
||||
|
||||
|
@ -131,7 +135,10 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
|||
SharedHandle<SocketCore> pooledSocket =
|
||||
e->popPooledSocket(options, resolvedAddresses, req->getPort());
|
||||
if(pooledSocket.isNull()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER, cuid, addr.c_str(), port);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER,
|
||||
util::itos(cuid).c_str(), addr.c_str(), port);
|
||||
}
|
||||
socket.reset(new SocketCore());
|
||||
socket->establishConnection(addr, port);
|
||||
FtpNegotiationCommand* c =
|
||||
|
|
|
@ -243,7 +243,10 @@ bool FtpNegotiationCommand::recvPwd()
|
|||
throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, status).str());
|
||||
}
|
||||
ftp->setBaseWorkingDir(pwd);
|
||||
logger->info("CUID#%d - base working directory is '%s'", cuid, pwd.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - base working directory is '%s'",
|
||||
util::itos(cuid).c_str(), pwd.c_str());
|
||||
}
|
||||
sequence = SEQ_SEND_CWD;
|
||||
return true;
|
||||
}
|
||||
|
@ -321,7 +324,9 @@ bool FtpNegotiationCommand::recvMdtm()
|
|||
}
|
||||
}
|
||||
} else {
|
||||
logger->info("CUID#%d - MDTM command failed.", cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - MDTM command failed.", util::itos(cuid).c_str());
|
||||
}
|
||||
}
|
||||
sequence = SEQ_SEND_SIZE;
|
||||
return true;
|
||||
|
@ -449,9 +454,10 @@ bool FtpNegotiationCommand::recvSize() {
|
|||
}
|
||||
|
||||
} else {
|
||||
|
||||
logger->info("CUID#%d - The remote FTP Server doesn't recognize SIZE command. Continue.", cuid);
|
||||
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - The remote FTP Server doesn't recognize SIZE"
|
||||
" command. Continue.", util::itos(cuid).c_str());
|
||||
}
|
||||
// Even if one of the other servers waiting in the queue supports SIZE
|
||||
// command, resuming and segmented downloading are disabled when the first
|
||||
// contacted FTP server doesn't support it.
|
||||
|
@ -527,9 +533,11 @@ bool FtpNegotiationCommand::recvPasv() {
|
|||
throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, status).str());
|
||||
}
|
||||
// make a data connection to the server.
|
||||
logger->info(MSG_CONNECTING_TO_SERVER, cuid,
|
||||
dest.first.c_str(),
|
||||
dest.second);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER, util::itos(cuid).c_str(),
|
||||
dest.first.c_str(),
|
||||
dest.second);
|
||||
}
|
||||
dataSocket.reset(new SocketCore());
|
||||
dataSocket->establishConnection(dest.first, dest.second);
|
||||
|
||||
|
|
|
@ -95,7 +95,11 @@ std::string HttpConnection::eraseConfidentialInfo(const std::string& request)
|
|||
void HttpConnection::sendRequest(const SharedHandle<HttpRequest>& httpRequest)
|
||||
{
|
||||
std::string request = httpRequest->createRequest();
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, eraseConfidentialInfo(request).c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(),
|
||||
eraseConfidentialInfo(request).c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
_socketBuffer.send();
|
||||
SharedHandle<HttpRequestEntry> entry(new HttpRequestEntry(httpRequest));
|
||||
|
@ -106,7 +110,11 @@ void HttpConnection::sendProxyRequest
|
|||
(const SharedHandle<HttpRequest>& httpRequest)
|
||||
{
|
||||
std::string request = httpRequest->createProxyRequest();
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, eraseConfidentialInfo(request).c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SENDING_REQUEST,
|
||||
util::itos(cuid).c_str(),
|
||||
eraseConfidentialInfo(request).c_str());
|
||||
}
|
||||
_socketBuffer.pushStr(request);
|
||||
_socketBuffer.send();
|
||||
SharedHandle<HttpRequestEntry> entry(new HttpRequestEntry(httpRequest));
|
||||
|
@ -139,8 +147,10 @@ SharedHandle<HttpResponse> HttpConnection::receiveResponse()
|
|||
size_t putbackDataLength = proc->getPutBackDataLength();
|
||||
size -= putbackDataLength;
|
||||
socket->readData(buf, size);
|
||||
|
||||
logger->info(MSG_RECEIVE_RESPONSE, cuid, proc->getHeaderString().c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_RECEIVE_RESPONSE,
|
||||
util::itos(cuid).c_str(), proc->getHeaderString().c_str());
|
||||
}
|
||||
SharedHandle<HttpHeader> httpHeader = proc->getHttpResponseHeader();
|
||||
SharedHandle<HttpResponse> httpResponse(new HttpResponse());
|
||||
httpResponse->setCuid(cuid);
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "prefs.h"
|
||||
#include "A2STR.h"
|
||||
#include "DownloadContext.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -72,7 +73,10 @@ Command* HttpInitiateConnectionCommand::createNextCommand
|
|||
e->popPooledSocket(req->getHost(), req->getPort());
|
||||
std::string proxyMethod = resolveProxyMethod(req->getProtocol());
|
||||
if(pooledSocket.isNull()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER, cuid, addr.c_str(), port);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER,
|
||||
util::itos(cuid).c_str(), addr.c_str(), port);
|
||||
}
|
||||
socket.reset(new SocketCore());
|
||||
socket->establishConnection(addr, port);
|
||||
|
||||
|
@ -115,7 +119,10 @@ Command* HttpInitiateConnectionCommand::createNextCommand
|
|||
SharedHandle<SocketCore> pooledSocket =
|
||||
e->popPooledSocket(resolvedAddresses, req->getPort());
|
||||
if(pooledSocket.isNull()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER, cuid, addr.c_str(), port);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER,
|
||||
util::itos(cuid).c_str(), addr.c_str(), port);
|
||||
}
|
||||
socket.reset(new SocketCore());
|
||||
socket->establishConnection(addr, port);
|
||||
} else {
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "FileEntry.h"
|
||||
#include "prefs.h"
|
||||
#include "Option.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -80,7 +81,7 @@ bool HttpListenCommand::execute()
|
|||
}
|
||||
} catch(RecoverableException& e) {
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_ACCEPT_FAILURE, _e, cuid);
|
||||
logger->debug(MSG_ACCEPT_FAILURE, _e, util::itos(cuid).c_str());
|
||||
}
|
||||
}
|
||||
_e->commands.push_back(this);
|
||||
|
@ -93,7 +94,10 @@ bool HttpListenCommand::bindPort(uint16_t port)
|
|||
_e->deleteSocketForReadCheck(_serverSocket, this);
|
||||
}
|
||||
_serverSocket.reset(new SocketCore());
|
||||
logger->info("CUID#%d - Setting up HttpListenCommand", cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Setting up HttpListenCommand",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
try {
|
||||
int flags = 0;
|
||||
if(_e->option->getAsBool(PREF_XML_RPC_LISTEN_ALL)) {
|
||||
|
@ -102,11 +106,13 @@ bool HttpListenCommand::bindPort(uint16_t port)
|
|||
_serverSocket->bind(port, flags);
|
||||
_serverSocket->beginListen();
|
||||
_serverSocket->setNonBlockingMode();
|
||||
logger->info(MSG_LISTENING_PORT, cuid, port);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_LISTENING_PORT, util::itos(cuid).c_str(), port);
|
||||
}
|
||||
_e->addSocketForReadCheck(_serverSocket, this);
|
||||
return true;
|
||||
} catch(RecoverableException& e) {
|
||||
logger->error(MSG_BIND_FAILURE, e, cuid, port);
|
||||
logger->error(MSG_BIND_FAILURE, e, util::itos(cuid).c_str(), port);
|
||||
if(!_serverSocket.isNull()) {
|
||||
_e->deleteSocketForReadCheck(_serverSocket, this);
|
||||
}
|
||||
|
|
|
@ -105,8 +105,10 @@ std::string HttpResponse::determinFilename() const
|
|||
return file;
|
||||
}
|
||||
} else {
|
||||
logger->info(MSG_CONTENT_DISPOSITION_DETECTED,
|
||||
cuid, contentDisposition.c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONTENT_DISPOSITION_DETECTED,
|
||||
util::itos(cuid).c_str(), contentDisposition.c_str());
|
||||
}
|
||||
return contentDisposition;
|
||||
}
|
||||
}
|
||||
|
@ -133,12 +135,14 @@ void HttpResponse::processRedirect()
|
|||
{
|
||||
|
||||
if(httpRequest->getRequest()->redirectUri(getRedirectURI())) {
|
||||
logger->info(MSG_REDIRECT, cuid,
|
||||
httpRequest->getRequest()->getCurrentUri().c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_REDIRECT, util::itos(cuid).c_str(),
|
||||
httpRequest->getRequest()->getCurrentUri().c_str());
|
||||
}
|
||||
} else {
|
||||
throw DL_RETRY_EX
|
||||
(StringFormat("CUID#%d - Redirect to %s failed. It may not be a valid"
|
||||
" URI.", cuid,
|
||||
(StringFormat("CUID#%s - Redirect to %s failed. It may not be a valid"
|
||||
" URI.", util::itos(cuid).c_str(),
|
||||
httpRequest->getRequest()->getCurrentUri().c_str()).str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "XmlRpcResponse.h"
|
||||
#include "DownloadContext.h"
|
||||
#include "wallclock.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -116,8 +117,10 @@ bool HttpServerBodyCommand::execute()
|
|||
}
|
||||
}
|
||||
} catch(RecoverableException& e) {
|
||||
logger->info("CUID#%d - Error occurred while reading HTTP request body",
|
||||
e, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Error occurred while reading HTTP request body",
|
||||
e, util::itos(cuid).c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,8 +137,10 @@ bool HttpServerCommand::execute()
|
|||
}
|
||||
}
|
||||
} catch(RecoverableException& e) {
|
||||
logger->info("CUID#%d - Error occurred while reading HTTP request",
|
||||
e, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Error occurred while reading HTTP request",
|
||||
e, util::itos(cuid).c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "RecoverableException.h"
|
||||
#include "FileEntry.h"
|
||||
#include "wallclock.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -72,22 +73,31 @@ bool HttpServerResponseCommand::execute()
|
|||
try {
|
||||
_httpServer->sendResponse();
|
||||
} catch(RecoverableException& e) {
|
||||
logger->info("CUID#%d - Error occurred while transmitting response body.",
|
||||
e, cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Error occurred while transmitting response body.",
|
||||
e, util::itos(cuid).c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if(_httpServer->sendBufferIsEmpty()) {
|
||||
logger->info("CUID#%d - HttpServer: all response transmitted.", cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - HttpServer: all response transmitted.",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
if(_httpServer->supportsPersistentConnection()) {
|
||||
logger->info("CUID#%d - Persist connection.", cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Persist connection.", util::itos(cuid).c_str());
|
||||
}
|
||||
_e->commands.push_back
|
||||
(new HttpServerCommand(cuid, _httpServer, _e, _socket));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if(_timeout.difference(global::wallclock) >= 10) {
|
||||
logger->info("CUID#%d - HttpServer: Timeout while trasmitting response.",
|
||||
cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - HttpServer: Timeout while trasmitting"
|
||||
" response.", util::itos(cuid).c_str());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_e->commands.push_back(this);
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "Segment.h"
|
||||
#include "a2functional.h"
|
||||
#include "InitiateConnectionCommandFactory.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -104,9 +105,11 @@ bool InitiateConnectionCommand::executeInternal() {
|
|||
}
|
||||
res.resolve(addrs, hostname);
|
||||
}
|
||||
logger->info(MSG_NAME_RESOLUTION_COMPLETE, cuid,
|
||||
hostname.c_str(),
|
||||
strjoin(addrs.begin(), addrs.end(), ", ").c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_NAME_RESOLUTION_COMPLETE, util::itos(cuid).c_str(),
|
||||
hostname.c_str(),
|
||||
strjoin(addrs.begin(), addrs.end(), ", ").c_str());
|
||||
}
|
||||
for(std::vector<std::string>::const_iterator i = addrs.begin(),
|
||||
eoi = addrs.end(); i != eoi; ++i) {
|
||||
e->cacheIPAddress(hostname, *i, port);
|
||||
|
@ -114,8 +117,11 @@ bool InitiateConnectionCommand::executeInternal() {
|
|||
ipaddr = e->findCachedIPAddress(hostname, port);
|
||||
} else {
|
||||
ipaddr = addrs.front();
|
||||
logger->info(MSG_DNS_CACHE_HIT, cuid, hostname.c_str(),
|
||||
strjoin(addrs.begin(), addrs.end(), ", ").c_str());
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_DNS_CACHE_HIT,
|
||||
util::itos(cuid).c_str(), hostname.c_str(),
|
||||
strjoin(addrs.begin(), addrs.end(), ", ").c_str());
|
||||
}
|
||||
}
|
||||
try {
|
||||
Command* command = createNextCommand(hostname, ipaddr, port,
|
||||
|
@ -129,8 +135,11 @@ bool InitiateConnectionCommand::executeInternal() {
|
|||
// TODO ipaddr might not be used if pooled sockt was found.
|
||||
e->markBadIPAddress(hostname, ipaddr, port);
|
||||
if(!e->findCachedIPAddress(hostname, port).empty()) {
|
||||
logger->info(EX_EXCEPTION_CAUGHT, ex);
|
||||
logger->info(MSG_CONNECT_FAILED_AND_RETRY, cuid, ipaddr.c_str(), port);
|
||||
if(logger->info()) {
|
||||
logger->info(EX_EXCEPTION_CAUGHT, ex);
|
||||
logger->info(MSG_CONNECT_FAILED_AND_RETRY,
|
||||
util::itos(cuid).c_str(), ipaddr.c_str(), port);
|
||||
}
|
||||
Command* command =
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(cuid, req, _fileEntry, _requestGroup, e);
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "RequestGroup.h"
|
||||
#include "DownloadContext.h"
|
||||
#include "bittorrent_helper.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -169,7 +170,11 @@ bool InitiatorMSEHandshakeCommand::executeInternal() {
|
|||
bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
|
||||
{
|
||||
if(getOption()->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
|
||||
logger->info("CUID#%d - Establishing connection using legacy BitTorrent handshake is disabled by preference.", cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Establishing connection using legacy BitTorrent"
|
||||
" handshake is disabled by preference.",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
|
||||
SharedHandle<Peer> peer = _peerStorage->getUnusedPeer();
|
||||
peer->usedBy(e->newCUID());
|
||||
|
@ -183,7 +188,10 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
|
|||
return true;
|
||||
} else {
|
||||
// try legacy BitTorrent handshake
|
||||
logger->info("CUID#%d - Retry using legacy BitTorrent handshake.", cuid);
|
||||
if(logger->info()) {
|
||||
logger->info("CUID#%s - Retry using legacy BitTorrent handshake.",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
PeerInitiateConnectionCommand* command =
|
||||
new PeerInitiateConnectionCommand(cuid, _requestGroup, peer, e,
|
||||
_btRuntime, false);
|
||||
|
|
|
@ -105,13 +105,14 @@ MSEHandshake::HANDSHAKE_TYPE MSEHandshake::identifyHandshakeType()
|
|||
if(_rbuf[0] == BtHandshakeMessage::PSTR_LENGTH &&
|
||||
memcmp(BtHandshakeMessage::BT_PSTR, _rbuf+1, 19) == 0) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - This is legacy BitTorrent handshake.", _cuid);
|
||||
_logger->debug("CUID#%s - This is legacy BitTorrent handshake.",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
return HANDSHAKE_LEGACY;
|
||||
} else {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - This may be encrypted BitTorrent handshake.",
|
||||
_cuid);
|
||||
_logger->debug("CUID#%s - This may be encrypted BitTorrent handshake.",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
return HANDSHAKE_ENCRYPTED;
|
||||
}
|
||||
|
@ -124,7 +125,7 @@ void MSEHandshake::initEncryptionFacility(bool initiator)
|
|||
_dh->init(PRIME, PRIME_BITS, GENERATOR, 160);
|
||||
_dh->generatePublicKey();
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - DH initialized.", _cuid);
|
||||
_logger->debug("CUID#%s - DH initialized.", util::itos(_cuid).c_str());
|
||||
}
|
||||
_initiator = initiator;
|
||||
}
|
||||
|
@ -133,7 +134,8 @@ bool MSEHandshake::sendPublicKey()
|
|||
{
|
||||
if(_socketBuffer.sendBufferIsEmpty()) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - Sending public key.", _cuid);
|
||||
_logger->debug("CUID#%s - Sending public key.",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
unsigned char buffer[KEY_LENGTH+MAX_PAD_LENGTH];
|
||||
_dh->getPublicKey(buffer, KEY_LENGTH);
|
||||
|
@ -154,7 +156,7 @@ bool MSEHandshake::receivePublicKey()
|
|||
return false;
|
||||
}
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - public key received.", _cuid);
|
||||
_logger->debug("CUID#%s - public key received.", util::itos(_cuid).c_str());
|
||||
}
|
||||
// TODO handle exception. in catch, resbufLength = 0;
|
||||
_dh->computeSecret(_secret, sizeof(_secret), _rbuf, _rbufLength);
|
||||
|
@ -260,7 +262,8 @@ bool MSEHandshake::sendInitiatorStep2()
|
|||
{
|
||||
if(_socketBuffer.sendBufferIsEmpty()) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - Sending negotiation step2.", _cuid);
|
||||
_logger->debug("CUID#%s - Sending negotiation step2.",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
unsigned char md[20];
|
||||
createReq1Hash(md);
|
||||
|
@ -348,7 +351,8 @@ bool MSEHandshake::findInitiatorVCMarker()
|
|||
_socket->readData(_rbuf+_rbufLength, toRead);
|
||||
_rbufLength += toRead;
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - VC marker found at %u", _cuid, _markerIndex);
|
||||
_logger->debug("CUID#%s - VC marker found at %u",
|
||||
util::itos(_cuid).c_str(), _markerIndex);
|
||||
}
|
||||
verifyVC(_rbuf+_markerIndex);
|
||||
// reset _rbufLength
|
||||
|
@ -371,19 +375,22 @@ bool MSEHandshake::receiveInitiatorCryptoSelectAndPadDLength()
|
|||
if(cryptoSelect[3]&CRYPTO_PLAIN_TEXT &&
|
||||
_option->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - peer prefers plaintext.", _cuid);
|
||||
_logger->debug("CUID#%s - peer prefers plaintext.",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
_negotiatedCryptoType = CRYPTO_PLAIN_TEXT;
|
||||
}
|
||||
if(cryptoSelect[3]&CRYPTO_ARC4) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - peer prefers ARC4", _cuid);
|
||||
_logger->debug("CUID#%s - peer prefers ARC4",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
_negotiatedCryptoType = CRYPTO_ARC4;
|
||||
}
|
||||
if(_negotiatedCryptoType == CRYPTO_NONE) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("CUID#%d - No supported crypto type selected.", _cuid).str());
|
||||
(StringFormat("CUID#%s - No supported crypto type selected.",
|
||||
util::itos(_cuid).c_str()).str());
|
||||
}
|
||||
}
|
||||
// padD length
|
||||
|
@ -445,7 +452,8 @@ bool MSEHandshake::findReceiverHashMarker()
|
|||
_socket->readData(_rbuf+_rbufLength, toRead);
|
||||
_rbufLength += toRead;
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - Hash marker found at %u.", _cuid, _markerIndex);
|
||||
_logger->debug("CUID#%s - Hash marker found at %u.",
|
||||
util::itos(_cuid).c_str(), _markerIndex);
|
||||
}
|
||||
verifyReq1Hash(_rbuf+_markerIndex);
|
||||
// reset _rbufLength
|
||||
|
@ -472,7 +480,8 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength
|
|||
createReq23Hash(md, torrentAttrs[bittorrent::INFO_HASH].uc());
|
||||
if(memcmp(md, rbufptr, sizeof(md)) == 0) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - info hash found: %s", _cuid,
|
||||
_logger->debug("CUID#%s - info hash found: %s",
|
||||
util::itos(_cuid).c_str(),
|
||||
util::toHex
|
||||
(torrentAttrs[bittorrent::INFO_HASH].s()).c_str());
|
||||
}
|
||||
|
@ -498,18 +507,21 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength
|
|||
if(cryptoProvide[3]&CRYPTO_PLAIN_TEXT &&
|
||||
_option->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - peer provides plaintext.", _cuid);
|
||||
_logger->debug("CUID#%s - peer provides plaintext.",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
_negotiatedCryptoType = CRYPTO_PLAIN_TEXT;
|
||||
} else if(cryptoProvide[3]&CRYPTO_ARC4) {
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - peer provides ARC4.", _cuid);
|
||||
_logger->debug("CUID#%s - peer provides ARC4.",
|
||||
util::itos(_cuid).c_str());
|
||||
}
|
||||
_negotiatedCryptoType = CRYPTO_ARC4;
|
||||
}
|
||||
if(_negotiatedCryptoType == CRYPTO_NONE) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("CUID#%d - No supported crypto type provided.", _cuid).str());
|
||||
(StringFormat("CUID#%s - No supported crypto type provided.",
|
||||
util::itos(_cuid).c_str()).str());
|
||||
}
|
||||
}
|
||||
// decrypt PadC length
|
||||
|
@ -529,7 +541,8 @@ bool MSEHandshake::receiveReceiverIALength()
|
|||
}
|
||||
_iaLength = decodeLength16(_rbuf);
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - len(IA)=%u.", _cuid, _iaLength);
|
||||
_logger->debug("CUID#%s - len(IA)=%u.",
|
||||
util::itos(_cuid).c_str(), _iaLength);
|
||||
}
|
||||
// reset _rbufLength
|
||||
_rbufLength = 0;
|
||||
|
@ -549,7 +562,7 @@ bool MSEHandshake::receiveReceiverIA()
|
|||
_ia = new unsigned char[_iaLength];
|
||||
_decryptor->decrypt(_ia, _iaLength, _rbuf, _iaLength);
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - IA received.", _cuid);
|
||||
_logger->debug("CUID#%s - IA received.", util::itos(_cuid).c_str());
|
||||
}
|
||||
// reset _rbufLength
|
||||
_rbufLength = 0;
|
||||
|
@ -590,11 +603,13 @@ bool MSEHandshake::sendReceiverStep2()
|
|||
uint16_t MSEHandshake::verifyPadLength(const unsigned char* padlenbuf, const char* padName)
|
||||
{
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - Verifying Pad length for %s", _cuid, padName);
|
||||
_logger->debug("CUID#%s - Verifying Pad length for %s",
|
||||
util::itos(_cuid).c_str(), padName);
|
||||
}
|
||||
uint16_t padLength = decodeLength16(padlenbuf);
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - len(%s)=%u", _cuid, padName, padLength);
|
||||
_logger->debug("CUID#%s - len(%s)=%u",
|
||||
util::itos(_cuid).c_str(), padName, padLength);
|
||||
}
|
||||
if(padLength > 512) {
|
||||
throw DL_ABORT_EX
|
||||
|
@ -606,7 +621,7 @@ uint16_t MSEHandshake::verifyPadLength(const unsigned char* padlenbuf, const cha
|
|||
void MSEHandshake::verifyVC(const unsigned char* vcbuf)
|
||||
{
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - Verifying VC.", _cuid);
|
||||
_logger->debug("CUID#%s - Verifying VC.", util::itos(_cuid).c_str());
|
||||
}
|
||||
unsigned char vc[VC_LENGTH];
|
||||
_decryptor->decrypt(vc, sizeof(vc), vcbuf, sizeof(vc));
|
||||
|
@ -619,7 +634,7 @@ void MSEHandshake::verifyVC(const unsigned char* vcbuf)
|
|||
void MSEHandshake::verifyReq1Hash(const unsigned char* req1buf)
|
||||
{
|
||||
if(_logger->debug()) {
|
||||
_logger->debug("CUID#%d - Verifying req hash.", _cuid);
|
||||
_logger->debug("CUID#%s - Verifying req hash.", util::itos(_cuid).c_str());
|
||||
}
|
||||
unsigned char md[20];
|
||||
createReq1Hash(md);
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "DownloadFailureException.h"
|
||||
#include "StringFormat.h"
|
||||
#include "wallclock.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -75,9 +76,10 @@ PeerAbstractCommand::~PeerAbstractCommand()
|
|||
bool PeerAbstractCommand::execute()
|
||||
{
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d -"
|
||||
logger->debug("CUID#%s -"
|
||||
" socket: read:%d, write:%d, hup:%d, err:%d, noCheck:%d",
|
||||
cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent,
|
||||
util::itos(cuid).c_str(),
|
||||
_readEvent, _writeEvent, _hupEvent, _errorEvent,
|
||||
noCheck);
|
||||
}
|
||||
if(exitBeforeExecute()) {
|
||||
|
@ -106,9 +108,10 @@ bool PeerAbstractCommand::execute()
|
|||
return true;
|
||||
} catch(RecoverableException& err) {
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err, cuid);
|
||||
logger->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err,
|
||||
util::itos(cuid).c_str());
|
||||
logger->debug(MSG_PEER_BANNED,
|
||||
cuid, peer->ipaddr.c_str(), peer->port);
|
||||
util::itos(cuid).c_str(), peer->ipaddr.c_str(), peer->port);
|
||||
}
|
||||
onAbort();
|
||||
return prepareForNextPeer(0);
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "ARC4Encryptor.h"
|
||||
#include "ARC4Decryptor.h"
|
||||
#include "StringFormat.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -121,9 +122,10 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength) {
|
|||
}
|
||||
// we got EOF
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - In PeerConnection::receiveMessage(),"
|
||||
logger->debug("CUID#%s - In PeerConnection::receiveMessage(),"
|
||||
" remain=%lu",
|
||||
cuid, static_cast<unsigned long>(temp));
|
||||
util::itos(cuid).c_str(),
|
||||
static_cast<unsigned long>(temp));
|
||||
}
|
||||
throw DL_ABORT_EX(EX_EOF_FROM_PEER);
|
||||
}
|
||||
|
@ -154,9 +156,9 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength) {
|
|||
}
|
||||
// we got EOF
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - In PeerConnection::receiveMessage(),"
|
||||
logger->debug("CUID#%s - In PeerConnection::receiveMessage(),"
|
||||
" payloadlen=%lu, remaining=%lu",
|
||||
cuid,
|
||||
util::itos(cuid).c_str(),
|
||||
static_cast<unsigned long>(currentPayloadLength),
|
||||
static_cast<unsigned long>(temp));
|
||||
}
|
||||
|
@ -207,8 +209,8 @@ bool PeerConnection::receiveHandshake(unsigned char* data, size_t& dataLength,
|
|||
// we got EOF
|
||||
if(logger->debug()) {
|
||||
logger->debug
|
||||
("CUID#%d - In PeerConnection::receiveHandshake(), remain=%lu",
|
||||
cuid, static_cast<unsigned long>(temp));
|
||||
("CUID#%s - In PeerConnection::receiveHandshake(), remain=%lu",
|
||||
util::itos(cuid).c_str(), static_cast<unsigned long>(temp));
|
||||
}
|
||||
throw DL_ABORT_EX(EX_EOF_FROM_PEER);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "PeerConnection.h"
|
||||
#include "RequestGroup.h"
|
||||
#include "DownloadContext.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -75,8 +76,11 @@ PeerInitiateConnectionCommand::~PeerInitiateConnectionCommand()
|
|||
}
|
||||
|
||||
bool PeerInitiateConnectionCommand::executeInternal() {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER, cuid, peer->ipaddr.c_str(),
|
||||
peer->port);
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_CONNECTING_TO_SERVER,
|
||||
util::itos(cuid).c_str(), peer->ipaddr.c_str(),
|
||||
peer->port);
|
||||
}
|
||||
socket.reset(new SocketCore());
|
||||
socket->establishConnection(peer->ipaddr, peer->port);
|
||||
if(_mseHandshakeEnabled) {
|
||||
|
|
|
@ -244,8 +244,6 @@ PeerInteractionCommand::~PeerInteractionCommand() {
|
|||
|
||||
_requestGroup->decreaseNumCommand();
|
||||
_btRuntime->decreaseConnections();
|
||||
//logger->debug("CUID#%d - unregistered message factory using ID:%s",
|
||||
//cuid, peer->getId().c_str());
|
||||
}
|
||||
|
||||
bool PeerInteractionCommand::executeInternal() {
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "Socket.h"
|
||||
#include "SimpleRandomizer.h"
|
||||
#include "FileEntry.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -88,7 +89,7 @@ bool PeerListenCommand::bindPort(uint16_t& port, IntSequence& seq)
|
|||
logger->notice("BitTorrent: listening to port %d", port);
|
||||
return true;
|
||||
} catch(RecoverableException& ex) {
|
||||
logger->error(MSG_BIND_FAILURE, ex, cuid, port);
|
||||
logger->error(MSG_BIND_FAILURE, ex, util::itos(cuid).c_str(), port);
|
||||
socket->closeConnection();
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +129,11 @@ bool PeerListenCommand::execute() {
|
|||
logger->debug("Accepted the connection from %s:%u.",
|
||||
peer->ipaddr.c_str(),
|
||||
peer->port);
|
||||
logger->debug("Added CUID#%d to receive BitTorrent/MSE handshake.",
|
||||
cuid);
|
||||
logger->debug("Added CUID#%s to receive BitTorrent/MSE handshake.",
|
||||
util::itos(cuid).c_str());
|
||||
}
|
||||
} catch(RecoverableException& ex) {
|
||||
logger->debug(MSG_ACCEPT_FAILURE, ex, cuid);
|
||||
logger->debug(MSG_ACCEPT_FAILURE, ex, util::itos(cuid).c_str());
|
||||
}
|
||||
}
|
||||
e->commands.push_back(this);
|
||||
|
|
|
@ -143,7 +143,9 @@ bool PeerReceiveHandshakeCommand::executeInternal()
|
|||
_peerConnection);
|
||||
e->commands.push_back(command);
|
||||
if(logger->debug()) {
|
||||
logger->debug(MSG_INCOMING_PEER_CONNECTION, cuid, peer->usedBy());
|
||||
logger->debug(MSG_INCOMING_PEER_CONNECTION,
|
||||
util::itos(cuid).c_str(),
|
||||
util::itos(peer->usedBy()).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,8 @@ SharedHandle<Segment> SegmentMan::checkoutSegment
|
|||
return SharedHandle<Segment>();
|
||||
}
|
||||
if(logger->debug()) {
|
||||
logger->debug("Attach segment#%d to CUID#%d.", piece->getIndex(), cuid);
|
||||
logger->debug("Attach segment#%d to CUID#%s.",
|
||||
piece->getIndex(), util::itos(cuid).c_str());
|
||||
}
|
||||
SharedHandle<Segment> segment;
|
||||
if(piece->getLength() == 0) {
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "Peer.h"
|
||||
#include "PeerConnection.h"
|
||||
#include "Logger.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -55,7 +56,8 @@ void SimpleBtMessage::send() {
|
|||
if(!sendingInProgress) {
|
||||
if(logger->info()) {
|
||||
logger->info(MSG_SEND_PEER_MESSAGE,
|
||||
cuid, peer->ipaddr.c_str(), peer->port, toString().c_str());
|
||||
util::itos(cuid).c_str(),
|
||||
peer->ipaddr.c_str(), peer->port, toString().c_str());
|
||||
}
|
||||
unsigned char* msg = createMessage();
|
||||
size_t msgLength = getMessageLength();
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "DownloadContext.h"
|
||||
#include "bittorrent_helper.h"
|
||||
#include "a2functional.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -176,8 +177,9 @@ void TrackerWatcherCommand::processTrackerResponse
|
|||
command->setPieceStorage(_pieceStorage);
|
||||
e->commands.push_back(command);
|
||||
if(logger->debug()) {
|
||||
logger->debug("CUID#%d - Adding new command CUID#%d",
|
||||
cuid, peer->usedBy());
|
||||
logger->debug("CUID#%s - Adding new command CUID#%s",
|
||||
util::itos(cuid).c_str(),
|
||||
util::itos(peer->usedBy()).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
117
src/message.h
117
src/message.h
|
@ -37,60 +37,67 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#define MSG_SEGMENT_DOWNLOAD_COMPLETED _("CUID#%d - The download for one segment completed successfully.")
|
||||
#define MSG_NO_SEGMENT_AVAILABLE _("CUID#%d - No segment available.")
|
||||
#define MSG_CONNECTING_TO_SERVER _("CUID#%d - Connecting to %s:%d")
|
||||
#define MSG_SEGMENT_CHANGED _("CUID#%d - The segment changed. We send the request again with new Range header.")
|
||||
#define MSG_REDIRECT _("CUID#%d - Redirecting to %s")
|
||||
#define MSG_SENDING_REQUEST _("CUID#%d - Requesting:\n%s")
|
||||
#define MSG_RECEIVE_RESPONSE _("CUID#%d - Response received:\n%s")
|
||||
#define MSG_DOWNLOAD_ABORTED _("CUID#%d - Download aborted. URI=%s")
|
||||
#define MSG_RESTARTING_DOWNLOAD _("CUID#%d - Restarting the download. URI=%s")
|
||||
#define MSG_TORRENT_DOWNLOAD_ABORTED _("CUID#%d - Download aborted.")
|
||||
#define MSG_MAX_TRY _("CUID#%d - %d times attempted, but no success. Download aborted.")
|
||||
#define MSG_SEND_PEER_MESSAGE "CUID#%d - To: %s:%d %s"
|
||||
#define MSG_SEND_PEER_MESSAGE_WITH_INDEX "CUID#%d - To: %s:%d %s index=%d"
|
||||
#define MSG_SEND_PEER_MESSAGE_WITH_BITFIELD "CUID#%d - To: %s:%d %s %s"
|
||||
#define MSG_SEND_PEER_MESSAGE_WITH_INDEX_BEGIN_LENGTH "CUID#%d - To: %s:%d %s index=%d, begin=%d, length=%d"
|
||||
#define MSG_RECEIVE_PEER_MESSAGE "CUID#%d - From: %s:%d %s"
|
||||
#define MSG_GOT_NEW_PIECE _("CUID#%d - we got new piece. index=%d")
|
||||
#define MSG_GOT_WRONG_PIECE _("CUID#%d - we got wrong piece. index=%d")
|
||||
#define MSG_DOWNLOAD_NOT_COMPLETE _("CUID#%d - Download not complete: %s")
|
||||
#define MSG_SEGMENT_DOWNLOAD_COMPLETED \
|
||||
"CUID#%s - The download for one segment completed successfully."
|
||||
#define MSG_NO_SEGMENT_AVAILABLE "CUID#%s - No segment available."
|
||||
#define MSG_CONNECTING_TO_SERVER "CUID#%s - Connecting to %s:%d"
|
||||
#define MSG_REDIRECT "CUID#%s - Redirecting to %s"
|
||||
#define MSG_SENDING_REQUEST "CUID#%s - Requesting:\n%s"
|
||||
#define MSG_RECEIVE_RESPONSE "CUID#%s - Response received:\n%s"
|
||||
#define MSG_DOWNLOAD_ABORTED "CUID#%s - Download aborted. URI=%s"
|
||||
#define MSG_RESTARTING_DOWNLOAD "CUID#%s - Restarting the download. URI=%s"
|
||||
#define MSG_TORRENT_DOWNLOAD_ABORTED "CUID#%s - Download aborted."
|
||||
#define MSG_MAX_TRY \
|
||||
"CUID#%s - %d times attempted, but no success. Download aborted."
|
||||
#define MSG_SEND_PEER_MESSAGE "CUID#%s - To: %s:%d %s"
|
||||
#define MSG_RECEIVE_PEER_MESSAGE "CUID#%s - From: %s:%d %s"
|
||||
#define MSG_GOT_NEW_PIECE "CUID#%s - we got new piece. index=%d"
|
||||
#define MSG_GOT_WRONG_PIECE "CUID#%s - we got wrong piece. index=%d"
|
||||
#define MSG_DOWNLOAD_NOT_COMPLETE "CUID#%s - Download not complete: %s"
|
||||
#define MSG_DOWNLOAD_ALREADY_COMPLETED _("#%d - Download has already completed: %s")
|
||||
#define MSG_GOOD_CHECKSUM _("CUID#%d - Good checksum: %s")
|
||||
#define MSG_BAD_CHECKSUM _("CUID#%d - Bad checksum: %s")
|
||||
#define MSG_RESOLVING_HOSTNAME _("CUID#%d - Resolving hostname %s")
|
||||
#define MSG_NAME_RESOLUTION_COMPLETE _("CUID#%d - Name resolution complete: %s -> %s")
|
||||
#define MSG_NAME_RESOLUTION_FAILED _("CUID#%d - Name resolution for %s failed:%s")
|
||||
#define MSG_DNS_CACHE_HIT _("CUID#%d - DNS cache hit: %s -> %s")
|
||||
#define MSG_ABORT_REQUESTED _("CUID#%d - Abort requested.")
|
||||
#define MSG_CONNECTING_TO_PEER _("CUID#%d - Connecting to the peer %s")
|
||||
#define MSG_PIECE_RECEIVED _("CUID#%d - Piece received. index=%d, begin=%d, length=%d, offset=%llu, blockIndex=%d")
|
||||
#define MSG_PIECE_BITFIELD _("CUID#%d - Piece bitfield %s")
|
||||
#define MSG_REJECT_PIECE_CHOKED _("CUID#%d - Reject piece message in queue because the peer has been choked. index=%d, begin=%d, length=%d")
|
||||
#define MSG_REJECT_PIECE_CANCEL _("CUID#%d - Reject piece message in queue because cancel message received. index=%d, begin=%d, length=%d")
|
||||
#define MSG_FILE_VALIDATION_FAILURE _("CUID#%d - Exception caught while validating file integrity.")
|
||||
#define MSG_PEER_INTERESTED _("CUID#%d - Interested in the peer")
|
||||
#define MSG_PEER_NOT_INTERESTED _("CUID#%d - Not interested in the peer")
|
||||
#define MSG_DELETING_REQUEST_SLOT _("CUID#%d - Deleting request slot index=%d, blockIndex=%d")
|
||||
#define MSG_DELETING_REQUEST_SLOT_CHOKED _("CUID#%d - Deleting request slot index=%d, blockIndex=%d because localhost got choked.")
|
||||
#define MSG_DELETING_REQUEST_SLOT_TIMEOUT _("CUID#%d - Deleting request slot blockIndex=%d because of time out")
|
||||
#define MSG_DELETING_REQUEST_SLOT_ACQUIRED _("CUID#%d - Deleting request slot blockIndex=%d because the block has been acquired.")
|
||||
#define MSG_FAST_EXTENSION_ENABLED _("CUID#%d - Fast extension enabled.")
|
||||
#define MSG_EXTENDED_MESSAGING_ENABLED _("CUID#%d - Extended Messaging enabled.")
|
||||
#define MSG_FILE_ALLOCATION_FAILURE _("CUID#%d - Exception caught while allocating file space.")
|
||||
#define MSG_CONTENT_DISPOSITION_DETECTED _("CUID#%d - Content-Disposition detected. Use %s as filename")
|
||||
#define MSG_PEER_BANNED _("CUID#%d - Peer %s:%d banned.")
|
||||
#define MSG_LISTENING_PORT _("CUID#%d - Using port %d for accepting new connections")
|
||||
#define MSG_BIND_FAILURE _("CUID#%d - An error occurred while binding port=%d")
|
||||
#define MSG_INCOMING_PEER_CONNECTION _("CUID#%d - Incoming connection, adding new command CUID#%d")
|
||||
#define MSG_ACCEPT_FAILURE _("CUID#%d - Error in accepting connection")
|
||||
#define MSG_TRACKER_RESPONSE_PROCESSING_FAILED _("CUID#%d - Error occurred while processing tracker response.")
|
||||
#define MSG_TRACKER_REQUEST_CREATION_FAILED _("CUID#%d - Cannot create tracker request.")
|
||||
#define MSG_CREATING_TRACKER_REQUEST _("CUID#%d - Creating new tracker request command #%d")
|
||||
#define MSG_DHT_ENABLED_PEER _("CUID#%d - The peer is DHT-enabled.")
|
||||
#define MSG_CONNECT_FAILED_AND_RETRY "CUID#%d - Could not to connect to %s:%u." \
|
||||
" Trying another address"
|
||||
#define MSG_RESOLVING_HOSTNAME "CUID#%s - Resolving hostname %s"
|
||||
#define MSG_NAME_RESOLUTION_COMPLETE \
|
||||
"CUID#%s - Name resolution complete: %s -> %s"
|
||||
#define MSG_NAME_RESOLUTION_FAILED \
|
||||
"CUID#%s - Name resolution for %s failed:%s"
|
||||
#define MSG_DNS_CACHE_HIT "CUID#%s - DNS cache hit: %s -> %s"
|
||||
#define MSG_CONNECTING_TO_PEER "CUID#%s - Connecting to the peer %s"
|
||||
#define MSG_PIECE_RECEIVED \
|
||||
"CUID#%s - Piece received. index=%d, begin=%d, length=%d, offset=%llu," \
|
||||
" blockIndex=%d"
|
||||
#define MSG_PIECE_BITFIELD "CUID#%s - Piece bitfield %s"
|
||||
#define MSG_REJECT_PIECE_CHOKED \
|
||||
"CUID#%s - Reject piece message in queue because the peer has been choked." \
|
||||
" index=%d, begin=%d, length=%d"
|
||||
#define MSG_REJECT_PIECE_CANCEL \
|
||||
"CUID#%s - Reject piece message in queue because cancel message received." \
|
||||
" index=%d, begin=%d, length=%d"
|
||||
#define MSG_FILE_VALIDATION_FAILURE \
|
||||
"CUID#%s - Exception caught while validating file integrity."
|
||||
#define MSG_PEER_INTERESTED "CUID#%s - Interested in the peer"
|
||||
#define MSG_PEER_NOT_INTERESTED "CUID#%s - Not interested in the peer"
|
||||
#define MSG_DELETING_REQUEST_SLOT "CUID#%s - Deleting request slot index=%d, blockIndex=%d"
|
||||
#define MSG_DELETING_REQUEST_SLOT_CHOKED "CUID#%s - Deleting request slot index=%d, blockIndex=%d because localhost got choked."
|
||||
#define MSG_DELETING_REQUEST_SLOT_TIMEOUT "CUID#%s - Deleting request slot blockIndex=%d because of time out"
|
||||
#define MSG_DELETING_REQUEST_SLOT_ACQUIRED "CUID#%s - Deleting request slot blockIndex=%d because the block has been acquired."
|
||||
#define MSG_FAST_EXTENSION_ENABLED "CUID#%s - Fast extension enabled."
|
||||
#define MSG_EXTENDED_MESSAGING_ENABLED "CUID#%s - Extended Messaging enabled."
|
||||
#define MSG_FILE_ALLOCATION_FAILURE \
|
||||
"CUID#%s - Exception caught while allocating file space."
|
||||
#define MSG_CONTENT_DISPOSITION_DETECTED \
|
||||
"CUID#%s - Content-Disposition detected. Use %s as filename"
|
||||
#define MSG_PEER_BANNED "CUID#%s - Peer %s:%d banned."
|
||||
#define MSG_LISTENING_PORT \
|
||||
"CUID#%s - Using port %d for accepting new connections"
|
||||
#define MSG_BIND_FAILURE "CUID#%s - An error occurred while binding port=%d"
|
||||
#define MSG_INCOMING_PEER_CONNECTION \
|
||||
"CUID#%s - Incoming connection, adding new command CUID#%s"
|
||||
#define MSG_ACCEPT_FAILURE "CUID#%s - Error in accepting connection"
|
||||
#define MSG_TRACKER_RESPONSE_PROCESSING_FAILED \
|
||||
"CUID#%s - Error occurred while processing tracker response."
|
||||
#define MSG_DHT_ENABLED_PEER "CUID#%s - The peer is DHT-enabled."
|
||||
#define MSG_CONNECT_FAILED_AND_RETRY \
|
||||
"CUID#%s - Could not to connect to %s:%u. Trying another address"
|
||||
|
||||
#define MSG_UNRECOGNIZED_URI _("Unrecognized URI or unsupported protocol: %s")
|
||||
#define MSG_TRACKER_WARNING_MESSAGE _("Tracker returned warning message: %s")
|
||||
|
@ -115,11 +122,11 @@
|
|||
#define MSG_REMOVED_HAVE_ENTRY _("Removed %d have entries.")
|
||||
#define MSG_VALIDATING_FILE _("Validating file %s")
|
||||
#define MSG_ALLOCATION_COMPLETED _("%d seconds to allocate %s byte(s)")
|
||||
#define MSG_FILE_ALLOCATION_DISPATCH _("Dispatching FileAllocationCommand for CUID#%d.")
|
||||
#define MSG_FILE_ALLOCATION_DISPATCH \
|
||||
"Dispatching FileAllocationCommand for CUID#%s."
|
||||
#define MSG_METALINK_QUEUEING _("Metalink: Queueing %s for download.")
|
||||
#define MSG_FILE_DOWNLOAD_COMPLETED _("Download complete: %s")
|
||||
#define MSG_SEEDING_END _("Seeding is over.")
|
||||
#define MSG_SEGMENT_FORWARDING _("CUID#%d cancels segment index=%d. CUID#%d handles it instead.")
|
||||
#define MSG_NO_CHUNK_CHECKSUM _("No chunk to verify.")
|
||||
#define MSG_GOOD_CHUNK_CHECKSUM _("Good chunk checksum. hash=%s")
|
||||
#define MSG_LOADING_COOKIE_FAILED _("Failed to load cookies from %s")
|
||||
|
|
Loading…
Reference in New Issue