diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-02-09 12:20:20 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-02-09 12:20:20 +0000 |
| commit | e227e53d7b7afb63255ae9df4cdc0ef56ff577d9 (patch) | |
| tree | 883aecdcf7348a4115cb9eb897e5d1133bae6a53 /src/AdaptiveURISelector.cc | |
| parent | 65c094664c52ff1dc8330166858e5280f0bfdf88 (diff) | |
2010-02-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Wrapped logger->debug(...) with if(logger->debug()) { ... }
* src/AbstractCommand.cc
* src/AdaptiveURISelector.cc
* src/BtPieceMessage.cc
* src/BtPortMessage.cc
* src/CreateRequestCommand.cc
* src/DHTAbstractNodeLookupTask.cc
* src/DHTBucket.cc
* src/DHTGetPeersCommand.cc
* src/DHTMessageDispatcherImpl.cc
* src/DHTMessageFactoryImpl.cc
* src/DHTMessageTracker.cc
* src/DHTPeerAnnounceStorage.cc
* src/DHTRoutingTable.cc
* src/DHTSetup.cc
* src/DefaultBtAnnounce.cc
* src/DefaultBtInteractive.cc
* src/DefaultBtMessageDispatcher.cc
* src/DefaultBtMessageReceiver.cc
* src/DefaultBtProgressInfoFile.cc
* src/DefaultBtRequestFactory.cc
* src/DefaultPeerStorage.cc
* src/DefaultPieceStorage.cc
* src/DownloadCommand.cc
* src/DownloadEngine.cc
* src/EpollEventPoll.cc
* src/FileAllocationCommand.cc
* src/FileEntry.cc
* src/FtpNegotiationCommand.cc
* src/HandshakeExtensionMessage.cc
* src/HttpListenCommand.cc
* src/HttpServer.cc
* src/HttpSkipResponseCommand.cc
* src/IteratableChunkChecksumValidator.cc
* src/Logger.h
* src/MSEHandshake.cc
* src/MetalinkPostDownloadHandler.cc
* src/MultiDiskAdaptor.cc
* src/PeerAbstractCommand.cc
* src/PeerConnection.cc
* src/PeerListenCommand.cc
* src/PeerReceiveHandshakeCommand.cc
* src/RequestGroup.cc
* src/RequestGroupMan.cc
* src/SegmentMan.cc
* src/SelectEventPoll.cc
* src/ServerStat.cc
* src/SimpleBtMessage.cc
* src/SocketCore.cc
* src/TrackerWatcherCommand.cc
* src/UTMetadataDataExtensionMessage.cc
* src/UTMetadataRequestFactory.cc
* src/UTMetadataRequestTracker.cc
* src/XmlRpcMethod.cc
Diffstat (limited to 'src/AdaptiveURISelector.cc')
| -rw-r--r-- | src/AdaptiveURISelector.cc | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/src/AdaptiveURISelector.cc b/src/AdaptiveURISelector.cc index f631ff63..32d910b0 100644 --- a/src/AdaptiveURISelector.cc +++ b/src/AdaptiveURISelector.cc @@ -74,8 +74,10 @@ AdaptiveURISelector::~AdaptiveURISelector() {} std::string AdaptiveURISelector::select(FileEntry* fileEntry) { - _logger->debug("AdaptiveURISelector: called %d", - _requestGroup->getNumConnection()); + if(_logger->debug()) { + _logger->debug("AdaptiveURISelector: called %d", + _requestGroup->getNumConnection()); + } std::deque<std::string>& uris = fileEntry->getRemainingUris(); if (uris.empty() && _requestGroup->getNumConnection() <= 1) { // here we know the download will fail, trying to find previously @@ -103,11 +105,13 @@ void AdaptiveURISelector::mayRetryWithIncreasedTimeout(FileEntry* fileEntry) std::transform(timeouts.begin(), timeouts.end(), std::back_inserter(uris), std::mem_fun_ref(&URIResult::getURI)); - for(std::deque<std::string>::const_iterator i = uris.begin(); i != uris.end(); - ++i) { - _logger->debug("AdaptiveURISelector: will retry server with increased" - " timeout (%d s): %s", - _requestGroup->getTimeout(), (*i).c_str()); + if(_logger->debug()) { + for(std::deque<std::string>::const_iterator i = uris.begin(); + i != uris.end(); ++i) { + _logger->debug("AdaptiveURISelector: will retry server with increased" + " timeout (%d s): %s", + _requestGroup->getTimeout(), (*i).c_str()); + } } } @@ -132,8 +136,10 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris) if(getNbTestedServers(uris) < 3) { std::string notTested = getFirstNotTestedUri(uris); if(notTested != A2STR::NIL) { - _logger->debug("AdaptiveURISelector: choosing the first non tested" - " mirror: %s", notTested.c_str()); + if(_logger->debug()) { + _logger->debug("AdaptiveURISelector: choosing the first non tested" + " mirror: %s", notTested.c_str()); + } --_nbServerToEvaluate; return notTested; } @@ -144,16 +150,21 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris) std::string notTested = getFirstNotTestedUri(uris); if(notTested != A2STR::NIL) { /* Here we return the first untested mirror */ - _logger->debug("AdaptiveURISelector: choosing non tested mirror %s for" - " connection #%d", notTested.c_str(), _nbConnections); + if(_logger->debug()) { + _logger->debug("AdaptiveURISelector: choosing non tested mirror %s" + " for connection #%d", + notTested.c_str(), _nbConnections); + } return notTested; } else { /* Here we return a mirror which need to be tested again */ std::string toReTest = getFirstToTestUri(uris); if(toReTest != A2STR::NIL) { - _logger->debug("AdaptiveURISelector: choosing mirror %s which has not" - " been tested recently for connection #%d", - toReTest.c_str(), _nbConnections); + if(_logger->debug()) { + _logger->debug("AdaptiveURISelector: choosing mirror %s which has" + " not been tested recently for connection #%d", + toReTest.c_str(), _nbConnections); + } return toReTest; } else { return getBestMirror(uris); @@ -176,15 +187,19 @@ std::string AdaptiveURISelector::getBestMirror if (bests.size() < 2) { std::string uri = getMaxDownloadSpeedUri(uris); - _logger->debug("AdaptiveURISelector: choosing the best mirror :" - " %.2fKB/s %s (other mirrors are at least 25%% slower)", - (float) max/1024, uri.c_str()); + if(_logger->debug()) { + _logger->debug("AdaptiveURISelector: choosing the best mirror :" + " %.2fKB/s %s (other mirrors are at least 25%% slower)", + (float) max/1024, uri.c_str()); + } return uri; } else { std::string uri = selectRandomUri(bests); - _logger->debug("AdaptiveURISelector: choosing randomly one of the best" - " mirrors (range [%.2fKB/s, %.2fKB/s]): %s", - (float) min/1024, (float) max/1024, uri.c_str()); + if(_logger->debug()) { + _logger->debug("AdaptiveURISelector: choosing randomly one of the best" + " mirrors (range [%.2fKB/s, %.2fKB/s]): %s", + (float) min/1024, (float) max/1024, uri.c_str()); + } return uri; } } |
