summaryrefslogtreecommitdiff
path: root/src/LogFactory.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-05-21 16:19:17 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-05-21 16:19:17 +0000
commit896ca193e01f9f629f222fe992e05aebdca23a24 (patch)
tree6183195c2d279d7617096ad7c3080489cc7e7a96 /src/LogFactory.cc
parent6497ed63d42042a249ea0233a3ef3b97b75f3db3 (diff)
2006-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the ability to download several pieces in mix in a command and increase the number of request slots according to request-cancel latency: * src/PeerInteractionCommand.cc (executeInternal): The number of messages to be received at a time is increased from 10 to 50. * src/LogFactory (getInstance): Added NullLogger. * src/NullLogger.h: New class. * src/BitfieldMan.h (getMissingIndex): New function. * src/BitfieldMan.cc (getMissingIndex): New function. * src/TorrentMan.h (checkOutPiece): New function. (getMissingPieceIndex): New function. (getMissingFastPieceIndex): New function. (getMissingFastPiece): New function. * src/TorrentMan.cc (updatePiece): Rewritten using STL. (syncPiece): Rewritten using STL. (getMissingPiece): Rewritten using getMissingPieceIndex() and checkOutPiece(). (getMissingPieceIndex): New function. (getMissingFastPieceIndex): New function. (getMissingFastPiece): New function. (checkOutPiece): New function. * src/PeerInteraction.h (Pieces): New type definition. (piece): Removed. (pieces): New variable. (getNewPieceAndSendInterest): Added the "piece" argument. (abortPiece): Added the "piece" argument. (abortAllPieces): New function. (isInRequestSlot): New function. (hasDownloadPiece): Added the "index" argument. (setDownloadPiece): Removed. (getDownloadPiece): Added the "index" argument. (updatePiece): New function. (createRequestMessage): Added the "index" argument. * src/PeerInteraction.cc (onChoked): Rewritten. (abortPiece): Rewirtten. (abortAllPieces): New function. (deleteTimeoutRequestSlot): Rewritten. Clarified code a little bit. (deleteCompletedRequestSlot): Rewritten. (isInRequestSlot): New function. (syncPiece): Rewritten. (updatePiece): New function. (getNewPieceAndSendInterest): Rewritten. (addRequests): Rewritten. (getDownloadPiece): Rewritten. (hasDownloadPiece): Rewritten. (createRequestMessage): Added the "index" argument. * src/common.h (BITFIELD_LEN_FROM_PIECES): Enclosed the variable in parentheses. (DIV_FLOOR): New definition. * src/PieceMessage.cc (receivedAction): Update request-piece latency here. * src/RequestSlot.h (getLatencyInMillis): New function. * src/RequestSlot.cc (isTimeout): Rewritten using getLatencyInMillis. (getLatencyInMillis): New function. * src/Piece.h (operator==): New function. (getMissingBlockIndex): New function. * src/Piece.cc (operator==): New function. (getMissingBlockIndex): New function. * src/Peer.h (DEFAULT_LATENCY): New definition. (latency): New variable. (updateLatency): New function. (getLatency): New function. * src/Peer.cc (resetStatus): Reset latecy. (updateLatency): New function.
Diffstat (limited to 'src/LogFactory.cc')
-rw-r--r--src/LogFactory.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/LogFactory.cc b/src/LogFactory.cc
index e45ae653..8bb5780f 100644
--- a/src/LogFactory.cc
+++ b/src/LogFactory.cc
@@ -21,19 +21,20 @@
/* copyright --> */
#include "LogFactory.h"
#include "SimpleLogger.h"
+#include "NullLogger.h"
string LogFactory::filename;
Logger* LogFactory::logger = NULL;
Logger* LogFactory::getInstance() {
if(logger == NULL) {
- SimpleLogger* slogger = new SimpleLogger();
if(filename.empty()) {
- slogger->openFile("/dev/null");
+ logger = new NullLogger();
} else {
+ SimpleLogger* slogger = new SimpleLogger();
slogger->openFile(filename);
+ logger = slogger;
}
- logger = slogger;
}
return logger;
}