mirror of https://github.com/aria2/aria2
2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed SingletonHolder of CUIDCounter. CUIDCounter is now part of DownloadEngine. * src/ActivePeerConnectionCommand.cc * src/BtSetup.cc * src/CUIDCounter.h * src/DHTSetup.cc * src/DownloadCommand.cc * src/DownloadEngine.cc * src/DownloadEngine.h * src/DownloadEngineFactory.cc * src/FileAllocationDispatcherCommand.cc * src/InitiatorMSEHandshakeCommand.cc * src/PeerInitiateConnectionCommand.cc * src/PeerInteractionCommand.cc * src/PeerListenCommand.cc * src/RequestGroup.cc * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/main.cc * test/RequestGroupManTest.ccpull/1/head
parent
7818e0e770
commit
220a483004
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
||||||
|
2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Removed SingletonHolder of CUIDCounter. CUIDCounter is now part of
|
||||||
|
DownloadEngine.
|
||||||
|
* src/ActivePeerConnectionCommand.cc
|
||||||
|
* src/BtSetup.cc
|
||||||
|
* src/CUIDCounter.h
|
||||||
|
* src/DHTSetup.cc
|
||||||
|
* src/DownloadCommand.cc
|
||||||
|
* src/DownloadEngine.cc
|
||||||
|
* src/DownloadEngine.h
|
||||||
|
* src/DownloadEngineFactory.cc
|
||||||
|
* src/FileAllocationDispatcherCommand.cc
|
||||||
|
* src/InitiatorMSEHandshakeCommand.cc
|
||||||
|
* src/PeerInitiateConnectionCommand.cc
|
||||||
|
* src/PeerInteractionCommand.cc
|
||||||
|
* src/PeerListenCommand.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* src/StreamFileAllocationEntry.cc
|
||||||
|
* src/TrackerWatcherCommand.cc
|
||||||
|
* src/main.cc
|
||||||
|
* test/RequestGroupManTest.cc
|
||||||
|
|
||||||
2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Implemented commented code in BtSeederStateChoke
|
Implemented commented code in BtSeederStateChoke
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "ActivePeerConnectionCommand.h"
|
#include "ActivePeerConnectionCommand.h"
|
||||||
#include "PeerInitiateConnectionCommand.h"
|
#include "PeerInitiateConnectionCommand.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "BtContext.h"
|
#include "BtContext.h"
|
||||||
|
@ -115,7 +114,7 @@ void ActivePeerConnectionCommand::connectToPeer(const PeerHandle& peer)
|
||||||
if(peer.isNull()) {
|
if(peer.isNull()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
|
peer->usedBy(e->newCUID());
|
||||||
PeerInitiateConnectionCommand* command =
|
PeerInitiateConnectionCommand* command =
|
||||||
new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e,
|
new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e,
|
||||||
_btContext, _btRuntime);
|
_btContext, _btRuntime);
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
#include "UnionSeedCriteria.h"
|
#include "UnionSeedCriteria.h"
|
||||||
#include "TimeSeedCriteria.h"
|
#include "TimeSeedCriteria.h"
|
||||||
#include "ShareRatioSeedCriteria.h"
|
#include "ShareRatioSeedCriteria.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
@ -85,10 +84,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
|
||||||
// commands
|
// commands
|
||||||
{
|
{
|
||||||
TrackerWatcherCommand* c =
|
TrackerWatcherCommand* c =
|
||||||
new TrackerWatcherCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
new TrackerWatcherCommand(e->newCUID(), requestGroup, e, btContext);
|
||||||
requestGroup,
|
|
||||||
e,
|
|
||||||
btContext);
|
|
||||||
c->setPeerStorage(peerStorage);
|
c->setPeerStorage(peerStorage);
|
||||||
c->setPieceStorage(pieceStorage);
|
c->setPieceStorage(pieceStorage);
|
||||||
c->setBtRuntime(btRuntime);
|
c->setBtRuntime(btRuntime);
|
||||||
|
@ -98,9 +94,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PeerChokeCommand* c =
|
PeerChokeCommand* c =
|
||||||
new PeerChokeCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
new PeerChokeCommand(e->newCUID(), e, btContext);
|
||||||
e,
|
|
||||||
btContext);
|
|
||||||
c->setPeerStorage(peerStorage);
|
c->setPeerStorage(peerStorage);
|
||||||
c->setBtRuntime(btRuntime);
|
c->setBtRuntime(btRuntime);
|
||||||
|
|
||||||
|
@ -108,8 +102,8 @@ void BtSetup::setup(std::deque<Command*>& commands,
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ActivePeerConnectionCommand* c =
|
ActivePeerConnectionCommand* c =
|
||||||
new ActivePeerConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
new ActivePeerConnectionCommand(e->newCUID(), requestGroup, e, btContext,
|
||||||
requestGroup, e, btContext, 10);
|
10);
|
||||||
c->setBtRuntime(btRuntime);
|
c->setBtRuntime(btRuntime);
|
||||||
c->setPieceStorage(pieceStorage);
|
c->setPieceStorage(pieceStorage);
|
||||||
c->setPeerStorage(peerStorage);
|
c->setPeerStorage(peerStorage);
|
||||||
|
@ -122,10 +116,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
|
||||||
DHTRegistry::_peerAnnounceStorage->addPeerAnnounce(btContext->getInfoHash(),
|
DHTRegistry::_peerAnnounceStorage->addPeerAnnounce(btContext->getInfoHash(),
|
||||||
peerStorage);
|
peerStorage);
|
||||||
DHTGetPeersCommand* command =
|
DHTGetPeersCommand* command =
|
||||||
new DHTGetPeersCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
new DHTGetPeersCommand(e->newCUID(), requestGroup, e, btContext);
|
||||||
requestGroup,
|
|
||||||
e,
|
|
||||||
btContext);
|
|
||||||
command->setTaskQueue(DHTRegistry::_taskQueue);
|
command->setTaskQueue(DHTRegistry::_taskQueue);
|
||||||
command->setTaskFactory(DHTRegistry::_taskFactory);
|
command->setTaskFactory(DHTRegistry::_taskFactory);
|
||||||
command->setBtRuntime(btRuntime);
|
command->setBtRuntime(btRuntime);
|
||||||
|
@ -152,11 +143,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
|
||||||
}
|
}
|
||||||
if(unionCri->getSeedCriterion().size() > 0) {
|
if(unionCri->getSeedCriterion().size() > 0) {
|
||||||
SeedCheckCommand* c =
|
SeedCheckCommand* c =
|
||||||
new SeedCheckCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
new SeedCheckCommand(e->newCUID(), requestGroup, e, btContext, unionCri);
|
||||||
requestGroup,
|
|
||||||
e,
|
|
||||||
btContext,
|
|
||||||
unionCri);
|
|
||||||
c->setPieceStorage(pieceStorage);
|
c->setPieceStorage(pieceStorage);
|
||||||
c->setBtRuntime(btRuntime);
|
c->setBtRuntime(btRuntime);
|
||||||
commands.push_back(c);
|
commands.push_back(c);
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#define _D_CUID_COUNTER_H_
|
#define _D_CUID_COUNTER_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SingletonHolder.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -56,9 +55,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<CUIDCounter> CUIDCounterHandle;
|
|
||||||
typedef SingletonHolder<CUIDCounterHandle> CUIDCounterSingletonHolder;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _D_CUID_COUNTER_H_
|
#endif // _D_CUID_COUNTER_H_
|
||||||
|
|
|
@ -63,13 +63,13 @@
|
||||||
#include "DHTRegistry.h"
|
#include "DHTRegistry.h"
|
||||||
#include "DHTBucketRefreshTask.h"
|
#include "DHTBucketRefreshTask.h"
|
||||||
#include "DHTMessageCallback.h"
|
#include "DHTMessageCallback.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
|
#include "DownloadEngine.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -195,7 +195,8 @@ void DHTSetup::setup(std::deque<Command*>& commands,
|
||||||
option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
|
option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
|
||||||
std::deque<std::pair<std::string, uint16_t> > entryPoints;
|
std::deque<std::pair<std::string, uint16_t> > entryPoints;
|
||||||
entryPoints.push_back(addr);
|
entryPoints.push_back(addr);
|
||||||
DHTEntryPointNameResolveCommand* command = new DHTEntryPointNameResolveCommand(CUIDCounterSingletonHolder::instance()->newID(), e, entryPoints);
|
DHTEntryPointNameResolveCommand* command =
|
||||||
|
new DHTEntryPointNameResolveCommand(e->newCUID(), e, entryPoints);
|
||||||
command->setBootstrapEnabled(true);
|
command->setBootstrapEnabled(true);
|
||||||
command->setTaskQueue(taskQueue);
|
command->setTaskQueue(taskQueue);
|
||||||
command->setTaskFactory(taskFactory);
|
command->setTaskFactory(taskFactory);
|
||||||
|
@ -207,7 +208,8 @@ void DHTSetup::setup(std::deque<Command*>& commands,
|
||||||
_logger->info("No DHT entry point specified.");
|
_logger->info("No DHT entry point specified.");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
DHTInteractionCommand* command = new DHTInteractionCommand(CUIDCounterSingletonHolder::instance()->newID(), e);
|
DHTInteractionCommand* command =
|
||||||
|
new DHTInteractionCommand(e->newCUID(), e);
|
||||||
command->setMessageDispatcher(dispatcher);
|
command->setMessageDispatcher(dispatcher);
|
||||||
command->setMessageReceiver(receiver);
|
command->setMessageReceiver(receiver);
|
||||||
command->setTaskQueue(taskQueue);
|
command->setTaskQueue(taskQueue);
|
||||||
|
@ -215,24 +217,30 @@ void DHTSetup::setup(std::deque<Command*>& commands,
|
||||||
tempCommands.push_back(command);
|
tempCommands.push_back(command);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
DHTTokenUpdateCommand* command = new DHTTokenUpdateCommand(CUIDCounterSingletonHolder::instance()->newID(), e, DHT_TOKEN_UPDATE_INTERVAL);
|
DHTTokenUpdateCommand* command =
|
||||||
|
new DHTTokenUpdateCommand(e->newCUID(), e, DHT_TOKEN_UPDATE_INTERVAL);
|
||||||
command->setTokenTracker(tokenTracker);
|
command->setTokenTracker(tokenTracker);
|
||||||
tempCommands.push_back(command);
|
tempCommands.push_back(command);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
DHTBucketRefreshCommand* command = new DHTBucketRefreshCommand(CUIDCounterSingletonHolder::instance()->newID(), e, DHT_BUCKET_REFRESH_CHECK_INTERVAL);
|
DHTBucketRefreshCommand* command =
|
||||||
|
new DHTBucketRefreshCommand(e->newCUID(), e,
|
||||||
|
DHT_BUCKET_REFRESH_CHECK_INTERVAL);
|
||||||
command->setTaskQueue(taskQueue);
|
command->setTaskQueue(taskQueue);
|
||||||
command->setRoutingTable(routingTable);
|
command->setRoutingTable(routingTable);
|
||||||
command->setTaskFactory(taskFactory);
|
command->setTaskFactory(taskFactory);
|
||||||
tempCommands.push_back(command);
|
tempCommands.push_back(command);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
DHTPeerAnnounceCommand* command = new DHTPeerAnnounceCommand(CUIDCounterSingletonHolder::instance()->newID(), e, DHT_PEER_ANNOUNCE_CHECK_INTERVAL);
|
DHTPeerAnnounceCommand* command =
|
||||||
|
new DHTPeerAnnounceCommand(e->newCUID(), e,
|
||||||
|
DHT_PEER_ANNOUNCE_CHECK_INTERVAL);
|
||||||
command->setPeerAnnounceStorage(peerAnnounceStorage);
|
command->setPeerAnnounceStorage(peerAnnounceStorage);
|
||||||
tempCommands.push_back(command);
|
tempCommands.push_back(command);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
DHTAutoSaveCommand* command = new DHTAutoSaveCommand(CUIDCounterSingletonHolder::instance()->newID(), e, 30*60);
|
DHTAutoSaveCommand* command =
|
||||||
|
new DHTAutoSaveCommand(e->newCUID(), e, 30*60);
|
||||||
command->setLocalNode(localNode);
|
command->setLocalNode(localNode);
|
||||||
command->setRoutingTable(routingTable);
|
command->setRoutingTable(routingTable);
|
||||||
tempCommands.push_back(command);
|
tempCommands.push_back(command);
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "DownloadCommand.h"
|
#include "DownloadCommand.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
|
@ -46,7 +49,6 @@
|
||||||
#include "PieceStorage.h"
|
#include "PieceStorage.h"
|
||||||
#include "CheckIntegrityCommand.h"
|
#include "CheckIntegrityCommand.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
@ -58,7 +60,6 @@
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
# include "MessageDigestHelper.h"
|
# include "MessageDigestHelper.h"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ bool DownloadCommand::prepareForNextSegment() {
|
||||||
if(entry->isValidationReady()) {
|
if(entry->isValidationReady()) {
|
||||||
entry->initValidator();
|
entry->initValidator();
|
||||||
CheckIntegrityCommand* command =
|
CheckIntegrityCommand* command =
|
||||||
new CheckIntegrityCommand(CUIDCounterSingletonHolder::instance()->newID(), _requestGroup, e, entry);
|
new CheckIntegrityCommand(e->newCUID(), _requestGroup, e, entry);
|
||||||
e->commands.push_back(command);
|
e->commands.push_back(command);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
|
@ -1059,4 +1059,9 @@ DownloadEngine::SocketPoolEntry::getOptions() const
|
||||||
return _options;
|
return _options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUID DownloadEngine::newCUID()
|
||||||
|
{
|
||||||
|
return _cuidCounter.newID();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
# include "AsyncNameResolver.h"
|
# include "AsyncNameResolver.h"
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
|
#include "CUIDCounter.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -298,6 +299,8 @@ private:
|
||||||
|
|
||||||
SharedHandle<BtRegistry> _btRegistry;
|
SharedHandle<BtRegistry> _btRegistry;
|
||||||
|
|
||||||
|
CUIDCounter _cuidCounter;
|
||||||
|
|
||||||
void shortSleep() const;
|
void shortSleep() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -413,6 +416,8 @@ public:
|
||||||
SharedHandle<CookieStorage> getCookieStorage() const;
|
SharedHandle<CookieStorage> getCookieStorage() const;
|
||||||
|
|
||||||
SharedHandle<BtRegistry> getBtRegistry() const;
|
SharedHandle<BtRegistry> getBtRegistry() const;
|
||||||
|
|
||||||
|
CUID newCUID();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<DownloadEngine> DownloadEngineHandle;
|
typedef SharedHandle<DownloadEngine> DownloadEngineHandle;
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "DownloadEngineFactory.h"
|
#include "DownloadEngineFactory.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
|
@ -44,7 +47,6 @@
|
||||||
# include "CheckIntegrityMan.h"
|
# include "CheckIntegrityMan.h"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "FillRequestGroupCommand.h"
|
#include "FillRequestGroupCommand.h"
|
||||||
#include "FileAllocationDispatcherCommand.h"
|
#include "FileAllocationDispatcherCommand.h"
|
||||||
#include "AutoSaveCommand.h"
|
#include "AutoSaveCommand.h"
|
||||||
|
@ -52,7 +54,6 @@
|
||||||
#include "TimedHaltCommand.h"
|
#include "TimedHaltCommand.h"
|
||||||
#include "DownloadResult.h"
|
#include "DownloadResult.h"
|
||||||
#include "ServerStatMan.h"
|
#include "ServerStatMan.h"
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -89,18 +90,20 @@ DownloadEngineFactory::newDownloadEngine(Option* op,
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
e->addRoutineCommand(new FillRequestGroupCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 1));
|
e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get(), 1));
|
||||||
e->addRoutineCommand(new FileAllocationDispatcherCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get()));
|
e->addRoutineCommand(new FileAllocationDispatcherCommand(e->newCUID(),
|
||||||
|
e.get()));
|
||||||
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
||||||
e->addRoutineCommand
|
e->addRoutineCommand
|
||||||
(new AutoSaveCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
(new AutoSaveCommand(e->newCUID(), e.get(),
|
||||||
e.get(), op->getAsInt(PREF_AUTO_SAVE_INTERVAL)));
|
op->getAsInt(PREF_AUTO_SAVE_INTERVAL)));
|
||||||
}
|
}
|
||||||
e->addRoutineCommand(new HaveEraseCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 10));
|
e->addRoutineCommand(new HaveEraseCommand(e->newCUID(), e.get(), 10));
|
||||||
{
|
{
|
||||||
time_t stopSec = op->getAsInt(PREF_STOP);
|
time_t stopSec = op->getAsInt(PREF_STOP);
|
||||||
if(stopSec > 0) {
|
if(stopSec > 0) {
|
||||||
e->addRoutineCommand(new TimedHaltCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), stopSec));
|
e->addRoutineCommand(new TimedHaltCommand(e->newCUID(), e.get(),
|
||||||
|
stopSec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "FileAllocationEntry.h"
|
#include "FileAllocationEntry.h"
|
||||||
#include "FileAllocationCommand.h"
|
#include "FileAllocationCommand.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -60,7 +59,7 @@ bool FileAllocationDispatcherCommand::execute()
|
||||||
if(_e->_fileAllocationMan->nextFileAllocationEntryExists() &&
|
if(_e->_fileAllocationMan->nextFileAllocationEntryExists() &&
|
||||||
!_e->_fileAllocationMan->isFileAllocationBeingExecuted()) {
|
!_e->_fileAllocationMan->isFileAllocationBeingExecuted()) {
|
||||||
FileAllocationEntryHandle entry = _e->_fileAllocationMan->popNextFileAllocationEntry();
|
FileAllocationEntryHandle entry = _e->_fileAllocationMan->popNextFileAllocationEntry();
|
||||||
int32_t newCUID = CUIDCounterSingletonHolder::instance()->newID();
|
int32_t newCUID = _e->newCUID();
|
||||||
logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
|
logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
|
||||||
FileAllocationCommand* command =
|
FileAllocationCommand* command =
|
||||||
new FileAllocationCommand(newCUID,
|
new FileAllocationCommand(newCUID,
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
|
@ -171,7 +170,7 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
|
||||||
logger->info("CUID#%d - Establishing connection using legacy BitTorrent handshake is disabled by preference.", cuid);
|
logger->info("CUID#%d - Establishing connection using legacy BitTorrent handshake is disabled by preference.", cuid);
|
||||||
if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
|
if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
|
||||||
SharedHandle<Peer> peer = _peerStorage->getUnusedPeer();
|
SharedHandle<Peer> peer = _peerStorage->getUnusedPeer();
|
||||||
peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
|
peer->usedBy(e->newCUID());
|
||||||
PeerInitiateConnectionCommand* command =
|
PeerInitiateConnectionCommand* command =
|
||||||
new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer,
|
new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer,
|
||||||
e, _btContext, _btRuntime);
|
e, _btContext, _btRuntime);
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
|
@ -101,7 +100,7 @@ bool PeerInitiateConnectionCommand::executeInternal() {
|
||||||
bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) {
|
bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) {
|
||||||
if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
|
if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
|
||||||
PeerHandle peer = _peerStorage->getUnusedPeer();
|
PeerHandle peer = _peerStorage->getUnusedPeer();
|
||||||
peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
|
peer->usedBy(e->newCUID());
|
||||||
PeerInitiateConnectionCommand* command =
|
PeerInitiateConnectionCommand* command =
|
||||||
new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e,
|
new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e,
|
||||||
_btContext, _btRuntime);
|
_btContext, _btRuntime);
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "DefaultBtInteractive.h"
|
#include "DefaultBtInteractive.h"
|
||||||
#include "PeerConnection.h"
|
#include "PeerConnection.h"
|
||||||
#include "ExtensionMessageFactory.h"
|
#include "ExtensionMessageFactory.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "DHTRoutingTable.h"
|
#include "DHTRoutingTable.h"
|
||||||
#include "DHTTaskQueue.h"
|
#include "DHTTaskQueue.h"
|
||||||
#include "DHTTaskFactory.h"
|
#include "DHTTaskFactory.h"
|
||||||
|
@ -292,7 +291,7 @@ bool PeerInteractionCommand::executeInternal() {
|
||||||
bool PeerInteractionCommand::prepareForNextPeer(time_t wait) {
|
bool PeerInteractionCommand::prepareForNextPeer(time_t wait) {
|
||||||
if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
|
if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
|
||||||
PeerHandle peer = _peerStorage->getUnusedPeer();
|
PeerHandle peer = _peerStorage->getUnusedPeer();
|
||||||
peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
|
peer->usedBy(e->newCUID());
|
||||||
PeerInitiateConnectionCommand* command =
|
PeerInitiateConnectionCommand* command =
|
||||||
new PeerInitiateConnectionCommand(peer->usedBy(),
|
new PeerInitiateConnectionCommand(peer->usedBy(),
|
||||||
_requestGroup,
|
_requestGroup,
|
||||||
|
|
|
@ -33,16 +33,17 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "PeerListenCommand.h"
|
#include "PeerListenCommand.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "ReceiverMSEHandshakeCommand.h"
|
#include "ReceiverMSEHandshakeCommand.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ bool PeerListenCommand::execute() {
|
||||||
peerSocket->setNonBlockingMode();
|
peerSocket->setNonBlockingMode();
|
||||||
|
|
||||||
PeerHandle peer(new Peer(peerInfo.first, peerInfo.second, true));
|
PeerHandle peer(new Peer(peerInfo.first, peerInfo.second, true));
|
||||||
int32_t cuid = CUIDCounterSingletonHolder::instance()->newID();
|
int32_t cuid = e->newCUID();
|
||||||
Command* command =
|
Command* command =
|
||||||
new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
|
new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
|
||||||
e->commands.push_back(command);
|
e->commands.push_back(command);
|
||||||
|
@ -119,7 +120,7 @@ bool PeerListenCommand::execute() {
|
||||||
PeerListenCommand* PeerListenCommand::getInstance(DownloadEngine* e)
|
PeerListenCommand* PeerListenCommand::getInstance(DownloadEngine* e)
|
||||||
{
|
{
|
||||||
if(__numInstance == 0) {
|
if(__numInstance == 0) {
|
||||||
__instance = new PeerListenCommand(CUIDCounterSingletonHolder::instance()->newID(), e);
|
__instance = new PeerListenCommand(e->newCUID(), e);
|
||||||
}
|
}
|
||||||
return __instance;
|
return __instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#include "Dependency.h"
|
#include "Dependency.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "InitiateConnectionCommandFactory.h"
|
#include "InitiateConnectionCommandFactory.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
@ -281,7 +280,8 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
|
||||||
e->addCommand(commands);
|
e->addCommand(commands);
|
||||||
if(!btContext->getNodes().empty() && DHTSetup::initialized()) {
|
if(!btContext->getNodes().empty() && DHTSetup::initialized()) {
|
||||||
DHTEntryPointNameResolveCommand* command =
|
DHTEntryPointNameResolveCommand* command =
|
||||||
new DHTEntryPointNameResolveCommand(CUIDCounterSingletonHolder::instance()->newID(), e, btContext->getNodes());
|
new DHTEntryPointNameResolveCommand(e->newCUID(), e,
|
||||||
|
btContext->getNodes());
|
||||||
command->setTaskQueue(DHTRegistry::_taskQueue);
|
command->setTaskQueue(DHTRegistry::_taskQueue);
|
||||||
command->setTaskFactory(DHTRegistry::_taskFactory);
|
command->setTaskFactory(DHTRegistry::_taskFactory);
|
||||||
command->setRoutingTable(DHTRegistry::_routingTable);
|
command->setRoutingTable(DHTRegistry::_routingTable);
|
||||||
|
@ -334,7 +334,7 @@ void RequestGroup::processCheckIntegrityEntry(std::deque<Command*>& commands,
|
||||||
entry->initValidator();
|
entry->initValidator();
|
||||||
entry->cutTrailingGarbage();
|
entry->cutTrailingGarbage();
|
||||||
CheckIntegrityCommand* command =
|
CheckIntegrityCommand* command =
|
||||||
new CheckIntegrityCommand(CUIDCounterSingletonHolder::instance()->newID(), this, e, entry);
|
new CheckIntegrityCommand(e->newCUID(), this, e, entry);
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
} else
|
} else
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
@ -533,7 +533,9 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
|
||||||
req->setReferer(_option->get(PREF_REFERER));
|
req->setReferer(_option->get(PREF_REFERER));
|
||||||
req->setMethod(method);
|
req->setMethod(method);
|
||||||
|
|
||||||
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), req, this, e);
|
Command* command =
|
||||||
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
|
(e->newCUID(), req, this, e);
|
||||||
ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
||||||
registerServerHost(sv);
|
registerServerHost(sv);
|
||||||
// give a chance to be executed in the next loop in DownloadEngine
|
// give a chance to be executed in the next loop in DownloadEngine
|
||||||
|
|
|
@ -33,14 +33,15 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "StreamFileAllocationEntry.h"
|
#include "StreamFileAllocationEntry.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "InitiateConnectionCommandFactory.h"
|
#include "InitiateConnectionCommandFactory.h"
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -68,8 +69,7 @@ void StreamFileAllocationEntry::prepareForNextAction(std::deque<Command*>& comma
|
||||||
} else {
|
} else {
|
||||||
Command* command =
|
Command* command =
|
||||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
(CUIDCounterSingletonHolder::instance()->newID(),
|
(e->newCUID(), _currentRequest, _requestGroup, e);
|
||||||
_currentRequest, _requestGroup, e);
|
|
||||||
|
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include "SingleFileDownloadContext.h"
|
#include "SingleFileDownloadContext.h"
|
||||||
#include "ByteArrayDiskWriterFactory.h"
|
#include "ByteArrayDiskWriterFactory.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "PeerInitiateConnectionCommand.h"
|
#include "PeerInitiateConnectionCommand.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
@ -153,7 +152,7 @@ void TrackerWatcherCommand::processTrackerResponse
|
||||||
if(peer.isNull()) {
|
if(peer.isNull()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
|
peer->usedBy(e->newCUID());
|
||||||
PeerInitiateConnectionCommand* command =
|
PeerInitiateConnectionCommand* command =
|
||||||
new PeerInitiateConnectionCommand(peer->usedBy(),
|
new PeerInitiateConnectionCommand(peer->usedBy(),
|
||||||
_requestGroup,
|
_requestGroup,
|
||||||
|
|
21
src/main.cc
21
src/main.cc
|
@ -33,6 +33,16 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
@ -45,7 +55,6 @@
|
||||||
#include "Netrc.h"
|
#include "Netrc.h"
|
||||||
#include "FatalException.h"
|
#include "FatalException.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "UriListParser.h"
|
#include "UriListParser.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
@ -74,15 +83,9 @@
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
# include "MessageDigestHelper.h"
|
# include "MessageDigestHelper.h"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
#include <deque>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <numeric>
|
|
||||||
extern char* optarg;
|
extern char* optarg;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
#include <getopt.h>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -383,8 +386,6 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthConfigFactorySingleton::instance(authConfigFactory);
|
AuthConfigFactorySingleton::instance(authConfigFactory);
|
||||||
CUIDCounterHandle cuidCounter(new CUIDCounter());
|
|
||||||
CUIDCounterSingletonHolder::instance(cuidCounter);
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MessageDigestHelper::staticSHA1DigestInit();
|
MessageDigestHelper::staticSHA1DigestInit();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "CUIDCounter.h"
|
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "SingleFileDownloadContext.h"
|
#include "SingleFileDownloadContext.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
|
@ -25,12 +24,6 @@ class RequestGroupManTest : public CppUnit::TestFixture {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setUp()
|
|
||||||
{
|
|
||||||
SharedHandle<CUIDCounter> counter(new CUIDCounter());
|
|
||||||
SingletonHolder<SharedHandle<CUIDCounter> >::instance(counter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testIsSameFileBeingDownloaded();
|
void testIsSameFileBeingDownloaded();
|
||||||
void testGetInitialCommands();
|
void testGetInitialCommands();
|
||||||
void testLoadServerStat();
|
void testLoadServerStat();
|
||||||
|
|
Loading…
Reference in New Issue