From 722b3f8957e884b759e63366a541b3b61f0bd535 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 24 Jun 2006 16:09:14 +0000 Subject: [PATCH] 2006-06-25 Tatsuhiro Tsujikawa To fix the bug that causes same have message is sent many times to a single peer. * src/Time.cc (isNewer): Use Util::difftv(). To fix the bug that sends tracker requests without a sleep interval when the number of connections is less than 15. * src/TrackerWatcherCommand.cc (execute): Now the number of connections is not a factor to decide whether or not a tracker request should be sent or not. * src/Time.h (setTimeInSec): New function. * src/Time.cc (setTimeInSec): New function. etc. * src/ChokeMessage.cc (receivedAction): Removed peer->snubbing = false * src/PeerConnection.h (receiveHandshake): Updated doc. * src/TorrentMan.h (getAdvertisedPieceIndexes): Updated the method signature. * src/TorrentMan.cc (getAdvertisedPieceIndexes): Updated the method signature. * Release 0.5.2 --- ChangeLog | 34 ++++++++++++++++++++++++++++++++++ configure | 20 ++++++++++---------- configure.ac | 2 +- po/Makefile.in | 2 +- src/ChokeMessage.cc | 1 - src/PeerConnection.h | 6 ++++++ src/Time.cc | 7 ++++++- src/Time.h | 2 ++ src/TorrentMan.cc | 2 +- src/TorrentMan.h | 2 +- src/TrackerWatcherCommand.cc | 8 +++++--- 11 files changed, 67 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55043eb7..f4beecfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2006-06-25 Tatsuhiro Tsujikawa + + To fix the bug that causes same have message is sent many times to + a single peer. + + * src/Time.cc + (isNewer): Use Util::difftv(). + + To fix the bug that sends tracker requests without a sleep interval + when the number of connections is less than 15. + + * src/TrackerWatcherCommand.cc + (execute): Now the number of connections is not a factor to decide + whether or not a tracker request should be sent or not. + * src/Time.h + (setTimeInSec): New function. + * src/Time.cc + (setTimeInSec): New function. + + etc. + + * src/ChokeMessage.cc + (receivedAction): Removed peer->snubbing = false + + * src/PeerConnection.h + (receiveHandshake): Updated doc. + + * src/TorrentMan.h + (getAdvertisedPieceIndexes): Updated the method signature. + * src/TorrentMan.cc + (getAdvertisedPieceIndexes): Updated the method signature. + + * Release 0.5.2 + 2006-06-22 Tatsuhiro Tsujikawa To make a listening socket non-block: diff --git a/configure b/configure index 5a182bfa..5972f242 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for aria2c 0.5.1. +# Generated by GNU Autoconf 2.59 for aria2c 0.5.2. # # Report bugs to . # @@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='aria2c' PACKAGE_TARNAME='aria2c' -PACKAGE_VERSION='0.5.1' -PACKAGE_STRING='aria2c 0.5.1' +PACKAGE_VERSION='0.5.2' +PACKAGE_STRING='aria2c 0.5.2' PACKAGE_BUGREPORT='tujikawa@rednoah.com' ac_unique_file="src/Socket.h" @@ -788,7 +788,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures aria2c 0.5.1 to adapt to many kinds of systems. +\`configure' configures aria2c 0.5.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -854,7 +854,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of aria2c 0.5.1:";; + short | recursive ) echo "Configuration of aria2c 0.5.2:";; esac cat <<\_ACEOF @@ -994,7 +994,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -aria2c configure 0.5.1 +aria2c configure 0.5.2 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1008,7 +1008,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by aria2c $as_me 0.5.1, which was +It was created by aria2c $as_me 0.5.2, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1651,7 +1651,7 @@ fi # Define the identity of the package. PACKAGE='aria2c' - VERSION='0.5.1' + VERSION='0.5.2' cat >>confdefs.h <<_ACEOF @@ -11528,7 +11528,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by aria2c $as_me 0.5.1, which was +This file was extended by aria2c $as_me 0.5.2, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11591,7 +11591,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -aria2c config.status 0.5.1 +aria2c config.status 0.5.2 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 9cef0b10..4e974144 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. # AC_PREREQ(2.59) -AC_INIT(aria2c, 0.5.1, tujikawa@rednoah.com) +AC_INIT(aria2c, 0.5.2, tujikawa@rednoah.com) AM_INIT_AUTOMAKE() AM_PATH_CPPUNIT(1.10.2) AC_CONFIG_SRCDIR([src/Socket.h]) diff --git a/po/Makefile.in b/po/Makefile.in index 74a735a9..e58e66e5 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -9,7 +9,7 @@ # General Public License and is *not* in the public domain. PACKAGE = aria2c -VERSION = 0.5.1 +VERSION = 0.5.2 SHELL = /bin/sh diff --git a/src/ChokeMessage.cc b/src/ChokeMessage.cc index c57de0c6..c2313b4f 100644 --- a/src/ChokeMessage.cc +++ b/src/ChokeMessage.cc @@ -40,7 +40,6 @@ ChokeMessage* ChokeMessage::create(const char* data, int dataLength) { void ChokeMessage::receivedAction() { peer->peerChoking = true; - peer->snubbing = false; peerInteraction->onChoked(); } diff --git a/src/PeerConnection.h b/src/PeerConnection.h index 31b8fbdd..e96f37e9 100644 --- a/src/PeerConnection.h +++ b/src/PeerConnection.h @@ -55,6 +55,12 @@ public: int sendMessage(const char* msg, int length); bool receiveMessage(char* msg, int& length); + /** + * Returns true if a handshake message is fully received, otherwise returns + * false. + * In both cases, 'msg' is filled with received bytes and the filled length + * is assigned to 'length'. + */ bool receiveHandshake(char* msg, int& length); }; diff --git a/src/Time.cc b/src/Time.cc index e3663c5c..35336de4 100644 --- a/src/Time.cc +++ b/src/Time.cc @@ -58,7 +58,7 @@ bool Time::elapsedInMillis(int millis) const { } bool Time::isNewer(const Time& time) const { - return Util::difftvsec(this->tv, time.tv) > 0; + return Util::difftv(this->tv, time.tv) > 0; } int Time::difference() const { @@ -68,3 +68,8 @@ int Time::difference() const { long long int Time::differenceInMillis() const { return Util::difftv(getCurrentTime(), tv)/1000; } + +void Time::setTimeInSec(int sec) { + tv.tv_sec = sec; + tv.tv_usec = 0; +} diff --git a/src/Time.h b/src/Time.h index 1a9eb470..254864f5 100644 --- a/src/Time.h +++ b/src/Time.h @@ -65,6 +65,8 @@ public: return tv.tv_sec; } + void setTimeInSec(int sec); + bool isNewer(const Time& time) const; }; diff --git a/src/TorrentMan.cc b/src/TorrentMan.cc index d4cb74bb..1e607dc1 100644 --- a/src/TorrentMan.cc +++ b/src/TorrentMan.cc @@ -655,7 +655,7 @@ void TorrentMan::advertisePiece(int cuid, int index) { }; PieceIndexes TorrentMan::getAdvertisedPieceIndexes(int myCuid, - Time lastCheckTime) const { + const Time& lastCheckTime) const { PieceIndexes indexes; for(Haves::const_iterator itr = haves.begin(); itr != haves.end(); itr++) { const Haves::value_type& have = *itr; diff --git a/src/TorrentMan.h b/src/TorrentMan.h index d4b888c2..972d5059 100644 --- a/src/TorrentMan.h +++ b/src/TorrentMan.h @@ -178,7 +178,7 @@ public: void advertisePiece(int cuid, int index); - PieceIndexes getAdvertisedPieceIndexes(int myCuid, Time lastCheckTime) const; + PieceIndexes getAdvertisedPieceIndexes(int myCuid, const Time& lastCheckTime) const; long long int getTotalLength() const { return totalLength; } void setTotalLength(long long int length) { totalLength = length; } diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc index 3b6c1d50..e890f924 100644 --- a/src/TrackerWatcherCommand.cc +++ b/src/TrackerWatcherCommand.cc @@ -28,7 +28,10 @@ TrackerWatcherCommand::TrackerWatcherCommand(int cuid, TorrentDownloadEngine* e, int interval): - Command(cuid), e(e), interval(interval) {} + Command(cuid), e(e), interval(interval) { + // to force requesting to a tracker first time. + checkPoint.setTimeInSec(0); +} TrackerWatcherCommand::~TrackerWatcherCommand() {} @@ -44,8 +47,7 @@ bool TrackerWatcherCommand::execute() { return false; } if(e->torrentMan->trackers == 0 && - (e->torrentMan->connections < MAX_PEER_UPDATE || - e->torrentMan->isHalt() || + (e->torrentMan->isHalt() || checkPoint.elapsed(interval))) { checkPoint.reset(); e->torrentMan->req->resetTryCount();