Parcourir la source

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
Tatsuhiro Tsujikawa il y a 17 ans
Parent
commit
220a483004

+ 23 - 0
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>
 
 	Implemented commented code in BtSeederStateChoke

+ 1 - 2
src/ActivePeerConnectionCommand.cc

@@ -34,7 +34,6 @@
 /* copyright --> */
 #include "ActivePeerConnectionCommand.h"
 #include "PeerInitiateConnectionCommand.h"
-#include "CUIDCounter.h"
 #include "message.h"
 #include "DownloadEngine.h"
 #include "BtContext.h"
@@ -115,7 +114,7 @@ void ActivePeerConnectionCommand::connectToPeer(const PeerHandle& peer)
   if(peer.isNull()) {
     return;
   }
-  peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
+  peer->usedBy(e->newCUID());
   PeerInitiateConnectionCommand* command =
     new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e,
 				      _btContext, _btRuntime);

+ 6 - 19
src/BtSetup.cc

@@ -46,7 +46,6 @@
 #include "UnionSeedCriteria.h"
 #include "TimeSeedCriteria.h"
 #include "ShareRatioSeedCriteria.h"
-#include "CUIDCounter.h"
 #include "prefs.h"
 #include "LogFactory.h"
 #include "Logger.h"
@@ -85,10 +84,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
   // commands
   {
     TrackerWatcherCommand* c =
-      new TrackerWatcherCommand(CUIDCounterSingletonHolder::instance()->newID(),
-				requestGroup,
-				e,
-				btContext);
+      new TrackerWatcherCommand(e->newCUID(), requestGroup, e, btContext);
     c->setPeerStorage(peerStorage);
     c->setPieceStorage(pieceStorage);
     c->setBtRuntime(btRuntime);
@@ -98,9 +94,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
   }
   {
     PeerChokeCommand* c =
-      new PeerChokeCommand(CUIDCounterSingletonHolder::instance()->newID(),
-			   e,
-			   btContext);
+      new PeerChokeCommand(e->newCUID(), e, btContext);
     c->setPeerStorage(peerStorage);
     c->setBtRuntime(btRuntime);
 
@@ -108,8 +102,8 @@ void BtSetup::setup(std::deque<Command*>& commands,
   }
   {
     ActivePeerConnectionCommand* c =
-      new ActivePeerConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(),
-				      requestGroup, e, btContext, 10);
+      new ActivePeerConnectionCommand(e->newCUID(), requestGroup, e, btContext,
+				      10);
     c->setBtRuntime(btRuntime);
     c->setPieceStorage(pieceStorage);
     c->setPeerStorage(peerStorage);
@@ -122,10 +116,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
     DHTRegistry::_peerAnnounceStorage->addPeerAnnounce(btContext->getInfoHash(),
 						       peerStorage);
     DHTGetPeersCommand* command =
-      new DHTGetPeersCommand(CUIDCounterSingletonHolder::instance()->newID(),
-			     requestGroup,
-			     e,
-			     btContext);
+      new DHTGetPeersCommand(e->newCUID(), requestGroup, e, btContext);
     command->setTaskQueue(DHTRegistry::_taskQueue);
     command->setTaskFactory(DHTRegistry::_taskFactory);
     command->setBtRuntime(btRuntime);
@@ -152,11 +143,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
   }
   if(unionCri->getSeedCriterion().size() > 0) {
     SeedCheckCommand* c =
-      new SeedCheckCommand(CUIDCounterSingletonHolder::instance()->newID(),
-			   requestGroup,
-			   e,
-			   btContext,
-			   unionCri);
+      new SeedCheckCommand(e->newCUID(), requestGroup, e, btContext, unionCri);
     c->setPieceStorage(pieceStorage);
     c->setBtRuntime(btRuntime);
     commands.push_back(c);

+ 0 - 4
src/CUIDCounter.h

@@ -36,7 +36,6 @@
 #define _D_CUID_COUNTER_H_
 
 #include "common.h"
-#include "SingletonHolder.h"
 
 namespace aria2 {
 
@@ -56,9 +55,6 @@ public:
   }
 };
 
-typedef SharedHandle<CUIDCounter> CUIDCounterHandle;
-typedef SingletonHolder<CUIDCounterHandle> CUIDCounterSingletonHolder;
-
 }
 
 #endif // _D_CUID_COUNTER_H_

+ 15 - 7
src/DHTSetup.cc

@@ -63,13 +63,13 @@
 #include "DHTRegistry.h"
 #include "DHTBucketRefreshTask.h"
 #include "DHTMessageCallback.h"
-#include "CUIDCounter.h"
 #include "prefs.h"
 #include "Option.h"
 #include "SocketCore.h"
 #include "DlAbortEx.h"
 #include "RecoverableException.h"
 #include "a2functional.h"
+#include "DownloadEngine.h"
 
 namespace aria2 {
 
@@ -195,7 +195,8 @@ void DHTSetup::setup(std::deque<Command*>& commands,
 					      option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
 	std::deque<std::pair<std::string, uint16_t> > entryPoints;
 	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->setTaskQueue(taskQueue);
 	command->setTaskFactory(taskFactory);
@@ -207,7 +208,8 @@ void DHTSetup::setup(std::deque<Command*>& commands,
       _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->setMessageReceiver(receiver);
       command->setTaskQueue(taskQueue);
@@ -215,24 +217,30 @@ void DHTSetup::setup(std::deque<Command*>& commands,
       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);
       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->setRoutingTable(routingTable);
       command->setTaskFactory(taskFactory);
       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);
       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->setRoutingTable(routingTable);
       tempCommands.push_back(command);

+ 4 - 3
src/DownloadCommand.cc

@@ -33,6 +33,9 @@
  */
 /* copyright --> */
 #include "DownloadCommand.h"
+
+#include <cassert>
+
 #include "Request.h"
 #include "RequestGroup.h"
 #include "DownloadEngine.h"
@@ -46,7 +49,6 @@
 #include "PieceStorage.h"
 #include "CheckIntegrityCommand.h"
 #include "DiskAdaptor.h"
-#include "CUIDCounter.h"
 #include "DownloadContext.h"
 #include "Option.h"
 #include "Util.h"
@@ -58,7 +60,6 @@
 #ifdef ENABLE_MESSAGE_DIGEST
 # include "MessageDigestHelper.h"
 #endif // ENABLE_MESSAGE_DIGEST
-#include <cassert>
 
 namespace aria2 {
 
@@ -254,7 +255,7 @@ bool DownloadCommand::prepareForNextSegment() {
     if(entry->isValidationReady()) {
       entry->initValidator();
       CheckIntegrityCommand* command =
-	new CheckIntegrityCommand(CUIDCounterSingletonHolder::instance()->newID(), _requestGroup, e, entry);
+	new CheckIntegrityCommand(e->newCUID(), _requestGroup, e, entry);
       e->commands.push_back(command);
     }
 #endif // ENABLE_MESSAGE_DIGEST

+ 5 - 0
src/DownloadEngine.cc

@@ -1059,4 +1059,9 @@ DownloadEngine::SocketPoolEntry::getOptions() const
   return _options;
 }
 
+CUID DownloadEngine::newCUID()
+{
+  return _cuidCounter.newID();
+}
+
 } // namespace aria2

+ 5 - 0
src/DownloadEngine.h

@@ -53,6 +53,7 @@
 #ifdef ENABLE_ASYNC_DNS
 # include "AsyncNameResolver.h"
 #endif // ENABLE_ASYNC_DNS
+#include "CUIDCounter.h"
 
 namespace aria2 {
 
@@ -298,6 +299,8 @@ private:
 
   SharedHandle<BtRegistry> _btRegistry;
 
+  CUIDCounter _cuidCounter;
+
   void shortSleep() const;
 
   /**
@@ -413,6 +416,8 @@ public:
   SharedHandle<CookieStorage> getCookieStorage() const;
 
   SharedHandle<BtRegistry> getBtRegistry() const;
+
+  CUID newCUID();
 };
 
 typedef SharedHandle<DownloadEngine> DownloadEngineHandle;

+ 11 - 8
src/DownloadEngineFactory.cc

@@ -33,6 +33,9 @@
  */
 /* copyright --> */
 #include "DownloadEngineFactory.h"
+
+#include <algorithm>
+
 #include "LogFactory.h"
 #include "Logger.h"
 #include "Option.h"
@@ -44,7 +47,6 @@
 # include "CheckIntegrityMan.h"
 #endif // ENABLE_MESSAGE_DIGEST
 #include "prefs.h"
-#include "CUIDCounter.h"
 #include "FillRequestGroupCommand.h"
 #include "FileAllocationDispatcherCommand.h"
 #include "AutoSaveCommand.h"
@@ -52,7 +54,6 @@
 #include "TimedHaltCommand.h"
 #include "DownloadResult.h"
 #include "ServerStatMan.h"
-#include <algorithm>
 
 namespace aria2 {
 
@@ -89,18 +90,20 @@ DownloadEngineFactory::newDownloadEngine(Option* op,
 #ifdef ENABLE_MESSAGE_DIGEST
   e->_checkIntegrityMan.reset(new CheckIntegrityMan());
 #endif // ENABLE_MESSAGE_DIGEST
-  e->addRoutineCommand(new FillRequestGroupCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 1));
-  e->addRoutineCommand(new FileAllocationDispatcherCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get()));
+  e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get(), 1));
+  e->addRoutineCommand(new FileAllocationDispatcherCommand(e->newCUID(),
+							   e.get()));
   if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
     e->addRoutineCommand
-      (new AutoSaveCommand(CUIDCounterSingletonHolder::instance()->newID(),
-			   e.get(), op->getAsInt(PREF_AUTO_SAVE_INTERVAL)));
+      (new AutoSaveCommand(e->newCUID(), e.get(),
+			   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);
     if(stopSec > 0) {
-      e->addRoutineCommand(new TimedHaltCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), stopSec));
+      e->addRoutineCommand(new TimedHaltCommand(e->newCUID(), e.get(),
+						stopSec));
     }
   }
   return e;

+ 1 - 2
src/FileAllocationDispatcherCommand.cc

@@ -39,7 +39,6 @@
 #include "FileAllocationEntry.h"
 #include "FileAllocationCommand.h"
 #include "message.h"
-#include "CUIDCounter.h"
 #include "Logger.h"
 
 namespace aria2 {
@@ -60,7 +59,7 @@ bool FileAllocationDispatcherCommand::execute()
   if(_e->_fileAllocationMan->nextFileAllocationEntryExists() &&
      !_e->_fileAllocationMan->isFileAllocationBeingExecuted()) {
     FileAllocationEntryHandle entry = _e->_fileAllocationMan->popNextFileAllocationEntry();
-    int32_t newCUID = CUIDCounterSingletonHolder::instance()->newID();
+    int32_t newCUID = _e->newCUID();
     logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
     FileAllocationCommand* command =
       new FileAllocationCommand(newCUID,

+ 1 - 2
src/InitiatorMSEHandshakeCommand.cc

@@ -39,7 +39,6 @@
 #include "DlAbortEx.h"
 #include "message.h"
 #include "prefs.h"
-#include "CUIDCounter.h"
 #include "Socket.h"
 #include "Logger.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);
     if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
       SharedHandle<Peer> peer = _peerStorage->getUnusedPeer();
-      peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
+      peer->usedBy(e->newCUID());
       PeerInitiateConnectionCommand* command =
 	new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer,
 					  e, _btContext, _btRuntime);

+ 1 - 2
src/PeerInitiateConnectionCommand.cc

@@ -39,7 +39,6 @@
 #include "DlAbortEx.h"
 #include "message.h"
 #include "prefs.h"
-#include "CUIDCounter.h"
 #include "Socket.h"
 #include "Logger.h"
 #include "Peer.h"
@@ -101,7 +100,7 @@ bool PeerInitiateConnectionCommand::executeInternal() {
 bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) {
   if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
     PeerHandle peer = _peerStorage->getUnusedPeer();
-    peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
+    peer->usedBy(e->newCUID());
     PeerInitiateConnectionCommand* command =
       new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e,
 					_btContext, _btRuntime);

+ 1 - 2
src/PeerInteractionCommand.cc

@@ -57,7 +57,6 @@
 #include "DefaultBtInteractive.h"
 #include "PeerConnection.h"
 #include "ExtensionMessageFactory.h"
-#include "CUIDCounter.h"
 #include "DHTRoutingTable.h"
 #include "DHTTaskQueue.h"
 #include "DHTTaskFactory.h"
@@ -292,7 +291,7 @@ bool PeerInteractionCommand::executeInternal() {
 bool PeerInteractionCommand::prepareForNextPeer(time_t wait) {
   if(_peerStorage->isPeerAvailable() && _btRuntime->lessThanEqMinPeers()) {
     PeerHandle peer = _peerStorage->getUnusedPeer();
-    peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
+    peer->usedBy(e->newCUID());
     PeerInitiateConnectionCommand* command =
       new PeerInitiateConnectionCommand(peer->usedBy(),
 					_requestGroup,

+ 5 - 4
src/PeerListenCommand.cc

@@ -33,16 +33,17 @@
  */
 /* copyright --> */
 #include "PeerListenCommand.h"
+
+#include <utility>
+
 #include "DownloadEngine.h"
 #include "Peer.h"
 #include "RequestGroupMan.h"
 #include "RecoverableException.h"
-#include "CUIDCounter.h"
 #include "message.h"
 #include "ReceiverMSEHandshakeCommand.h"
 #include "Logger.h"
 #include "Socket.h"
-#include <utility>
 
 namespace aria2 {
 
@@ -100,7 +101,7 @@ bool PeerListenCommand::execute() {
       peerSocket->setNonBlockingMode();
 
       PeerHandle peer(new Peer(peerInfo.first, peerInfo.second, true));
-      int32_t cuid = CUIDCounterSingletonHolder::instance()->newID();
+      int32_t cuid = e->newCUID();
       Command* command =
 	new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
       e->commands.push_back(command);
@@ -119,7 +120,7 @@ bool PeerListenCommand::execute() {
 PeerListenCommand* PeerListenCommand::getInstance(DownloadEngine* e)
 {
   if(__numInstance == 0) {
-    __instance = new PeerListenCommand(CUIDCounterSingletonHolder::instance()->newID(), e);
+    __instance = new PeerListenCommand(e->newCUID(), e);
   }
   return __instance;
 }

+ 6 - 4
src/RequestGroup.cc

@@ -45,7 +45,6 @@
 #include "Dependency.h"
 #include "prefs.h"
 #include "InitiateConnectionCommandFactory.h"
-#include "CUIDCounter.h"
 #include "File.h"
 #include "message.h"
 #include "Util.h"
@@ -281,7 +280,8 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
 	e->addCommand(commands);
 	if(!btContext->getNodes().empty() && DHTSetup::initialized()) {
 	  DHTEntryPointNameResolveCommand* command =
-	    new DHTEntryPointNameResolveCommand(CUIDCounterSingletonHolder::instance()->newID(), e, btContext->getNodes());
+	    new DHTEntryPointNameResolveCommand(e->newCUID(), e,
+						btContext->getNodes());
 	  command->setTaskQueue(DHTRegistry::_taskQueue);
 	  command->setTaskFactory(DHTRegistry::_taskFactory);
 	  command->setRoutingTable(DHTRegistry::_routingTable);
@@ -334,7 +334,7 @@ void RequestGroup::processCheckIntegrityEntry(std::deque<Command*>& commands,
     entry->initValidator();
     entry->cutTrailingGarbage();
     CheckIntegrityCommand* command =
-      new CheckIntegrityCommand(CUIDCounterSingletonHolder::instance()->newID(), this, e, entry);
+      new CheckIntegrityCommand(e->newCUID(), this, e, entry);
     commands.push_back(command);
   } else
 #endif // ENABLE_MESSAGE_DIGEST
@@ -533,7 +533,9 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
 	req->setReferer(_option->get(PREF_REFERER));
 	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()));
 	registerServerHost(sv);
 	// give a chance to be executed in the next loop in DownloadEngine

+ 4 - 4
src/StreamFileAllocationEntry.cc

@@ -33,14 +33,15 @@
  */
 /* copyright --> */
 #include "StreamFileAllocationEntry.h"
-#include "CUIDCounter.h"
+
+#include <algorithm>
+
 #include "DownloadEngine.h"
 #include "Option.h"
 #include "Request.h"
 #include "prefs.h"
 #include "RequestGroup.h"
 #include "InitiateConnectionCommandFactory.h"
-#include <algorithm>
 
 namespace aria2 {
 
@@ -68,8 +69,7 @@ void StreamFileAllocationEntry::prepareForNextAction(std::deque<Command*>& comma
     } else {
       Command* command =
 	InitiateConnectionCommandFactory::createInitiateConnectionCommand
-	(CUIDCounterSingletonHolder::instance()->newID(),
-	 _currentRequest, _requestGroup, e);
+	(e->newCUID(), _currentRequest, _requestGroup, e);
 
       commands.push_back(command);
 

+ 1 - 2
src/TrackerWatcherCommand.cc

@@ -48,7 +48,6 @@
 #include "SingleFileDownloadContext.h"
 #include "ByteArrayDiskWriterFactory.h"
 #include "RecoverableException.h"
-#include "CUIDCounter.h"
 #include "PeerInitiateConnectionCommand.h"
 #include "DiskAdaptor.h"
 #include "FileEntry.h"
@@ -153,7 +152,7 @@ void TrackerWatcherCommand::processTrackerResponse
     if(peer.isNull()) {
       break;
     }
-    peer->usedBy(CUIDCounterSingletonHolder::instance()->newID());
+    peer->usedBy(e->newCUID());
     PeerInitiateConnectionCommand* command =
       new PeerInitiateConnectionCommand(peer->usedBy(),
 					_requestGroup,

+ 11 - 10
src/main.cc

@@ -33,6 +33,16 @@
  */
 /* copyright --> */
 #include "common.h"
+
+#include <signal.h>
+#include <unistd.h>
+#include <getopt.h>
+
+#include <deque>
+#include <fstream>
+#include <iostream>
+#include <numeric>
+
 #include "SharedHandle.h"
 #include "LogFactory.h"
 #include "Logger.h"
@@ -45,7 +55,6 @@
 #include "Netrc.h"
 #include "FatalException.h"
 #include "File.h"
-#include "CUIDCounter.h"
 #include "UriListParser.h"
 #include "message.h"
 #include "prefs.h"
@@ -74,15 +83,9 @@
 #ifdef ENABLE_MESSAGE_DIGEST
 # include "MessageDigestHelper.h"
 #endif // ENABLE_MESSAGE_DIGEST
-#include <deque>
-#include <signal.h>
-#include <unistd.h>
-#include <fstream>
-#include <iostream>
-#include <numeric>
+
 extern char* optarg;
 extern int optind, opterr, optopt;
-#include <getopt.h>
 
 namespace aria2 {
 
@@ -383,8 +386,6 @@ int main(int argc, char* argv[])
     }
 
     AuthConfigFactorySingleton::instance(authConfigFactory);
-    CUIDCounterHandle cuidCounter(new CUIDCounter());
-    CUIDCounterSingletonHolder::instance(cuidCounter);
 #ifdef ENABLE_MESSAGE_DIGEST
     MessageDigestHelper::staticSHA1DigestInit();
 #endif // ENABLE_MESSAGE_DIGEST

+ 0 - 7
test/RequestGroupManTest.cc

@@ -1,5 +1,4 @@
 #include "RequestGroupMan.h"
-#include "CUIDCounter.h"
 #include "prefs.h"
 #include "SingleFileDownloadContext.h"
 #include "RequestGroup.h"
@@ -25,12 +24,6 @@ class RequestGroupManTest : public CppUnit::TestFixture {
 private:
 
 public:
-  void setUp()
-  {
-    SharedHandle<CUIDCounter> counter(new CUIDCounter());
-    SingletonHolder<SharedHandle<CUIDCounter> >::instance(counter);
-  }
-
   void testIsSameFileBeingDownloaded();
   void testGetInitialCommands();
   void testLoadServerStat();