summaryrefslogtreecommitdiff
path: root/src/SimpleRandomizer.cc
Commit message (Collapse)AuthorAgeFilesLines
* Fixed segmentation fault in open solaris in unit test.Tatsuhiro Tsujikawa2012-03-251-2/+3
| | | | | This is due to the fact that the maximum value of random() in open solaris is not RAND_MAX, but (2**31)-1.
* MinGW32: Use CryptGenRandom() to generate random number.Tatsuhiro Tsujikawa2011-08-181-3/+37
| | | | | | | MinGW32 lacks random(), so we use CryptGenRandom() as a replacement. In the implementation, SimpleRandomizer::getRandomNumber() returns the random number in range [0, INT32_MAX]. Thus, simpleRandomizer::getMaxRandomNumber() returns INT32_MAX.
* Use random() instead of rand().Tatsuhiro Tsujikawa2011-08-111-3/+3
|
* 2010-11-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-121-1/+1
| | | | | | | | Removed SharedHandle::isNull(). Instead we added operator* and operator unspecified_bool_type. Removed use of WeakHandle and replaced with raw pointer.
* 2010-06-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-06-211-4/+4
| | | | | | | Changed naming standards for class member variable: now it looks like var_ instead of _var.
* 2010-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-05-081-1/+1
| | | | | | | | | | | | | | Return const reference. * src/DefaultPieceStorage.h * src/DownloadContext.h * src/FeatureConfig.cc * src/FeatureConfig.h * src/OptionParser.cc * src/OptionParser.h * src/SimpleRandomizer.cc * src/SimpleRandomizer.h
* 2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-01-051-1/+1
| | | | | | | | | Untabify. Fixed one line in copyright which is longer than 80 columns. * src * test
* 2008-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2008-11-161-2/+7
| | | | | | | | | | | | | | Given custom random number generator to std::random_shuffle. * src/AnnounceList.cc * src/BtLeecherStateChoke.cc * src/BtSeederStateChoke.cc * src/DefaultBtRequestFactory.cc * src/MetalinkEntry.cc * src/RarestPieceSelector.cc * src/SimpleRandomizer.cc * src/SimpleRandomizer.h
* 2008-09-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-09-021-1/+37
| | | | | | | | | | | | Moved implementation to SimpleRandomizer.cc from SimpleRandomizer.h. Added return value of getpid() to argument of srand() to achieve more randomized value. * src/SimpleRandomizer.cc * src/SimpleRandomizer.h
* 2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-04-201-1/+1
| | | | | | | | | | | | | | | Rewritten SharedHandle. Now copy constructor taking raw pointer has keyword explicit and SharedHandle's default constructor initializes its internal obj to null, old implementation initializes it using obj's default constructor. To assign null, write SharedHandle<T> x(...); x.reset(); TODO: test/SharedHandleTest.cc needs more tests. * src/SharedHandle.h
* 2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-02-081-0/+4
| | | | | | | | | Removed "using namespace std;" from all sources. Appended std:: prefix to c++ standard classes. Included string.h where mem* function are used.
* 2007-02-06 Tatsuhiro Tsujikawa <tujikawa dot rednoah dot com>Tatsuhiro Tsujikawa2007-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | To fix the bug that causes crash on Max OS X: * src/SimpleRandomizer.h (getInstance): Create new instance if the static variable is null. * src/SimpleRandomizer.cc (randomizer): Initialized to 0. * src/BitfieldManFactory.h (getNewFactory): Removed the call to setRandomizer(). To fix the miscalculation of the range of checksum: * src/BitfieldMan.h (isBitSetOffsetRange): New function. * src/BitfieldMan.cc (isBitSetOffsetRange): New function. * src/SegmentMan.cc (tryChunkChecksumValidation): Use BitfieldMan::isBitSetOffsetRange(). Use bitfield->getBlockLength() instead of segment.segmentLength.
* 2006-12-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2006-12-241-0/+37
Rewritten a portion of bittorrent implementation: * src/BtMessageValidator.h: New class. * src/BtBitfieldMessageValidator.h: New class. * src/BtHandshakeMessageValidator.h: New class. * src/BtRequestMessageValidator.h: New class. * src/BtSuggestPieceMessageValidator.h: New class. * src/BtAllowedFastMessageValidator.h: New class. * src/BtRejectMessageValidator.h: New class. * src/BtCancelMessageValidator.h: New class. * src/BtPieceMessageValidator.h: New class. * src/BtHaveMessageValidator.h: New class. * src/BtEventListener.h: New class. * src/AbstractBtEventListener.h: New class. * src/BtEvent.h: New class. * src/BtChokingEvent.h: New class. * src/BtChokedEvent.h: New class. * src/BtCancelSendingPieceEvent.h: New class. * src/BtAbortOutstandingRequestEvent.h: New class. * src/Randomizer.h: New class. * src/SimpleRandomizer.h: New class. * src/BtMessage.h: New class. * src/AbstractBtMessage.h: New class. * src/SimpleBtMessage.h: New class. * src/BtHaveMessage.h: New class. * src/BtInterestedMessage.h: New class. * src/BtAllowedFastMessage.h: New class. * src/BtUnchokeMessage.h: New class. * src/BtCancelMessage.h: New class. * src/BtNotInterestedMessage.h: New class. * src/BtChokeMessage.h: New class. * src/BtHaveNoneMessage.h: New class. * src/BtHandshakeMessage.h: New class. * src/BtSuggestPieceMessage.h: New class. * src/BtHaveMessage.h: New class. * src/BtPieceMessage.h: New class. * src/BtHaveAllMessage.h: New class. * src/BtKeepAliveMessage.h: New class. * src/BtPortMessage.h: New class. * src/BtRejectMessage.h: New class. * src/BtBitfieldMessage.h: New class. * src/BtRequestMessage.h: New class. * src/DefaultBtRequestFactory.h: New class. * src/DefaultBtMessageReceiver.h: New class. * src/BtInteractive.h: New class. * src/BtMessageDispatcher.h: New class. * src/DefaultBtMessageDispatcher.h: New class. * src/DefaultBtInteractive.h: New class. * src/BitfieldManFactory.h: New class. * src/HandleRegistry.h: New class. * src/BtMessageFactory.h: New class. * src/BtMessageReceiver.h: New class. * src/DefaultBtMessageFactory.h: New class. * src/PeerObject.h: New class. * src/BtRequestFactory.h: New class.