2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
* m4/openssl.m4: Added.
* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
readData(), peekData(). Added gnutls support.
* src/HttpDownloadCommand.cc: Removed SleepCommand.h
* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
TrackerInitCommand periodicaly(TorrentMan::minInterval).
* src/TorrentMan.cc: Remove downloadedSize == 0 check from
save().
Instead, added a check for whether setup method has executed
successfully.
* src/TorrentMan.h: Added member vaiable setupComplete. Updated
DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to
300.
* src/Makefile.am: Updated.
* src/messageDigest.h: Added. This is a macro calculating SHA1
digest
using whether OpenSSL or gcrypt, depending on the result of
configure
script.
* src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by
using
messageDigest.h.
* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
* src/PeerListenCommand.cc: Added log about port binded
successfully.
Fixed memory leak.
* src/main.cc: Added gnutls support. Replaced LIB_SSL with
ENABLE_BITTORRENT where they are not related to OpenSSL but
BitTorrent.
Removed instantiation of TrackerInitCommand. Instead,
TrackerWatcherCommand is instantiated and pushed to the command
queue.
* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL
with
ENABLE_SSL.
* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
* src/RequestSlotMan.cc:
(deleteCompletedRequestSlot)
If a piece is already acquired by another command, delete the
request
slots for the piece.
* src/TrackerUpdateCommand.cc:
(execute)
Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to
warn.
Added a check whether peer list is null.
Fixed the bug that causes sending completed event to the tracker
several times.
* src/TrackerInitCommand.cc:
(execute)
Fixed the bug that causes sending completed event to the tracker
several times.
* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on
OpenSSL
by using messageDigest.h.
2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* PeerConnection.cc: Replaced log message "keep-alive" with
"keep alive".
* PeerInteractionCommand.{h,cc}: Close connection if peer is
choking
localhost long time.
* TorrentMan.cc: When adding new peer with duplicate = true, if
the
number of peer list is equal to or grater than MAX_PEER_LIST,
delete
at most 100 failure entry from the list. If with duplicate =
false,
MAX_PEER_LIST is not checked.
* PeerListenCommand.cc: Fixed the argument order of log message.
2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
Added warn().
* SimpleLogger.h: Moved enum LEVEL to Logger.h.
Implemented warn().
Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated
code.
2006-03-27 14:47:26 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
2006-09-21 15:31:24 +00:00
|
|
|
* aria2 - The high speed download utility
|
2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
* m4/openssl.m4: Added.
* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
readData(), peekData(). Added gnutls support.
* src/HttpDownloadCommand.cc: Removed SleepCommand.h
* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
TrackerInitCommand periodicaly(TorrentMan::minInterval).
* src/TorrentMan.cc: Remove downloadedSize == 0 check from
save().
Instead, added a check for whether setup method has executed
successfully.
* src/TorrentMan.h: Added member vaiable setupComplete. Updated
DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to
300.
* src/Makefile.am: Updated.
* src/messageDigest.h: Added. This is a macro calculating SHA1
digest
using whether OpenSSL or gcrypt, depending on the result of
configure
script.
* src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by
using
messageDigest.h.
* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
* src/PeerListenCommand.cc: Added log about port binded
successfully.
Fixed memory leak.
* src/main.cc: Added gnutls support. Replaced LIB_SSL with
ENABLE_BITTORRENT where they are not related to OpenSSL but
BitTorrent.
Removed instantiation of TrackerInitCommand. Instead,
TrackerWatcherCommand is instantiated and pushed to the command
queue.
* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL
with
ENABLE_SSL.
* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
* src/RequestSlotMan.cc:
(deleteCompletedRequestSlot)
If a piece is already acquired by another command, delete the
request
slots for the piece.
* src/TrackerUpdateCommand.cc:
(execute)
Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to
warn.
Added a check whether peer list is null.
Fixed the bug that causes sending completed event to the tracker
several times.
* src/TrackerInitCommand.cc:
(execute)
Fixed the bug that causes sending completed event to the tracker
several times.
* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on
OpenSSL
by using messageDigest.h.
2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* PeerConnection.cc: Replaced log message "keep-alive" with
"keep alive".
* PeerInteractionCommand.{h,cc}: Close connection if peer is
choking
localhost long time.
* TorrentMan.cc: When adding new peer with duplicate = true, if
the
number of peer list is equal to or grater than MAX_PEER_LIST,
delete
at most 100 failure entry from the list. If with duplicate =
false,
MAX_PEER_LIST is not checked.
* PeerListenCommand.cc: Fixed the argument order of log message.
2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
Added warn().
* SimpleLogger.h: Moved enum LEVEL to Logger.h.
Implemented warn().
Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated
code.
2006-03-27 14:47:26 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-09-21 15:31:24 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
* m4/openssl.m4: Added.
* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
readData(), peekData(). Added gnutls support.
* src/HttpDownloadCommand.cc: Removed SleepCommand.h
* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
TrackerInitCommand periodicaly(TorrentMan::minInterval).
* src/TorrentMan.cc: Remove downloadedSize == 0 check from
save().
Instead, added a check for whether setup method has executed
successfully.
* src/TorrentMan.h: Added member vaiable setupComplete. Updated
DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to
300.
* src/Makefile.am: Updated.
* src/messageDigest.h: Added. This is a macro calculating SHA1
digest
using whether OpenSSL or gcrypt, depending on the result of
configure
script.
* src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by
using
messageDigest.h.
* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
* src/PeerListenCommand.cc: Added log about port binded
successfully.
Fixed memory leak.
* src/main.cc: Added gnutls support. Replaced LIB_SSL with
ENABLE_BITTORRENT where they are not related to OpenSSL but
BitTorrent.
Removed instantiation of TrackerInitCommand. Instead,
TrackerWatcherCommand is instantiated and pushed to the command
queue.
* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL
with
ENABLE_SSL.
* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
* src/RequestSlotMan.cc:
(deleteCompletedRequestSlot)
If a piece is already acquired by another command, delete the
request
slots for the piece.
* src/TrackerUpdateCommand.cc:
(execute)
Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to
warn.
Added a check whether peer list is null.
Fixed the bug that causes sending completed event to the tracker
several times.
* src/TrackerInitCommand.cc:
(execute)
Fixed the bug that causes sending completed event to the tracker
several times.
* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on
OpenSSL
by using messageDigest.h.
2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* PeerConnection.cc: Replaced log message "keep-alive" with
"keep alive".
* PeerInteractionCommand.{h,cc}: Close connection if peer is
choking
localhost long time.
* TorrentMan.cc: When adding new peer with duplicate = true, if
the
number of peer list is equal to or grater than MAX_PEER_LIST,
delete
at most 100 failure entry from the list. If with duplicate =
false,
MAX_PEER_LIST is not checked.
* PeerListenCommand.cc: Fixed the argument order of log message.
2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
Added warn().
* SimpleLogger.h: Moved enum LEVEL to Logger.h.
Implemented warn().
Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated
code.
2006-03-27 14:47:26 +00:00
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#include "TrackerWatcherCommand.h"
|
2008-11-03 06:49:02 +00:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "DownloadEngine.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "BtAnnounce.h"
|
|
|
|
#include "BtRuntime.h"
|
|
|
|
#include "PieceStorage.h"
|
|
|
|
#include "PeerStorage.h"
|
|
|
|
#include "Peer.h"
|
2006-06-18 09:23:25 +00:00
|
|
|
#include "prefs.h"
|
2007-07-20 17:06:21 +00:00
|
|
|
#include "message.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "ByteArrayDiskWriterFactory.h"
|
|
|
|
#include "RecoverableException.h"
|
|
|
|
#include "PeerInitiateConnectionCommand.h"
|
|
|
|
#include "DiskAdaptor.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "FileEntry.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "RequestGroup.h"
|
|
|
|
#include "Option.h"
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
#include "DlAbortEx.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Logger.h"
|
2008-05-13 14:15:23 +00:00
|
|
|
#include "A2STR.h"
|
2008-05-17 09:15:14 +00:00
|
|
|
#include "SocketCore.h"
|
2008-11-23 15:00:44 +00:00
|
|
|
#include "Request.h"
|
2009-02-01 03:24:02 +00:00
|
|
|
#include "AnnounceTier.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
#include "DownloadContext.h"
|
|
|
|
#include "bittorrent_helper.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
* m4/openssl.m4: Added.
* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
readData(), peekData(). Added gnutls support.
* src/HttpDownloadCommand.cc: Removed SleepCommand.h
* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
TrackerInitCommand periodicaly(TorrentMan::minInterval).
* src/TorrentMan.cc: Remove downloadedSize == 0 check from
save().
Instead, added a check for whether setup method has executed
successfully.
* src/TorrentMan.h: Added member vaiable setupComplete. Updated
DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to
300.
* src/Makefile.am: Updated.
* src/messageDigest.h: Added. This is a macro calculating SHA1
digest
using whether OpenSSL or gcrypt, depending on the result of
configure
script.
* src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by
using
messageDigest.h.
* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
* src/PeerListenCommand.cc: Added log about port binded
successfully.
Fixed memory leak.
* src/main.cc: Added gnutls support. Replaced LIB_SSL with
ENABLE_BITTORRENT where they are not related to OpenSSL but
BitTorrent.
Removed instantiation of TrackerInitCommand. Instead,
TrackerWatcherCommand is instantiated and pushed to the command
queue.
* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL
with
ENABLE_SSL.
* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
* src/RequestSlotMan.cc:
(deleteCompletedRequestSlot)
If a piece is already acquired by another command, delete the
request
slots for the piece.
* src/TrackerUpdateCommand.cc:
(execute)
Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to
warn.
Added a check whether peer list is null.
Fixed the bug that causes sending completed event to the tracker
several times.
* src/TrackerInitCommand.cc:
(execute)
Fixed the bug that causes sending completed event to the tracker
several times.
* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on
OpenSSL
by using messageDigest.h.
2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* PeerConnection.cc: Replaced log message "keep-alive" with
"keep alive".
* PeerInteractionCommand.{h,cc}: Close connection if peer is
choking
localhost long time.
* TorrentMan.cc: When adding new peer with duplicate = true, if
the
number of peer list is equal to or grater than MAX_PEER_LIST,
delete
at most 100 failure entry from the list. If with duplicate =
false,
MAX_PEER_LIST is not checked.
* PeerListenCommand.cc: Fixed the argument order of log message.
2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
Added warn().
* SimpleLogger.h: Moved enum LEVEL to Logger.h.
Implemented warn().
Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated
code.
2006-03-27 14:47:26 +00:00
|
|
|
|
2009-06-28 10:37:15 +00:00
|
|
|
TrackerWatcherCommand::TrackerWatcherCommand
|
|
|
|
(int32_t cuid, RequestGroup* requestGroup, DownloadEngine* e):
|
2007-10-11 16:58:24 +00:00
|
|
|
Command(cuid),
|
2009-04-23 15:00:09 +00:00
|
|
|
_requestGroup(requestGroup),
|
2009-06-28 10:37:15 +00:00
|
|
|
e(e)
|
2009-04-23 15:00:09 +00:00
|
|
|
{
|
|
|
|
_requestGroup->increaseNumCommand();
|
|
|
|
}
|
2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
* m4/openssl.m4: Added.
* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
readData(), peekData(). Added gnutls support.
* src/HttpDownloadCommand.cc: Removed SleepCommand.h
* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
TrackerInitCommand periodicaly(TorrentMan::minInterval).
* src/TorrentMan.cc: Remove downloadedSize == 0 check from
save().
Instead, added a check for whether setup method has executed
successfully.
* src/TorrentMan.h: Added member vaiable setupComplete. Updated
DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to
300.
* src/Makefile.am: Updated.
* src/messageDigest.h: Added. This is a macro calculating SHA1
digest
using whether OpenSSL or gcrypt, depending on the result of
configure
script.
* src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by
using
messageDigest.h.
* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
* src/PeerListenCommand.cc: Added log about port binded
successfully.
Fixed memory leak.
* src/main.cc: Added gnutls support. Replaced LIB_SSL with
ENABLE_BITTORRENT where they are not related to OpenSSL but
BitTorrent.
Removed instantiation of TrackerInitCommand. Instead,
TrackerWatcherCommand is instantiated and pushed to the command
queue.
* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL
with
ENABLE_SSL.
* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
* src/RequestSlotMan.cc:
(deleteCompletedRequestSlot)
If a piece is already acquired by another command, delete the
request
slots for the piece.
* src/TrackerUpdateCommand.cc:
(execute)
Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to
warn.
Added a check whether peer list is null.
Fixed the bug that causes sending completed event to the tracker
several times.
* src/TrackerInitCommand.cc:
(execute)
Fixed the bug that causes sending completed event to the tracker
several times.
* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on
OpenSSL
by using messageDigest.h.
2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* PeerConnection.cc: Replaced log message "keep-alive" with
"keep alive".
* PeerInteractionCommand.{h,cc}: Close connection if peer is
choking
localhost long time.
* TorrentMan.cc: When adding new peer with duplicate = true, if
the
number of peer list is equal to or grater than MAX_PEER_LIST,
delete
at most 100 failure entry from the list. If with duplicate =
false,
MAX_PEER_LIST is not checked.
* PeerListenCommand.cc: Fixed the argument order of log message.
2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
Added warn().
* SimpleLogger.h: Moved enum LEVEL to Logger.h.
Implemented warn().
Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated
code.
2006-03-27 14:47:26 +00:00
|
|
|
|
2009-04-23 15:00:09 +00:00
|
|
|
TrackerWatcherCommand::~TrackerWatcherCommand()
|
|
|
|
{
|
|
|
|
_requestGroup->decreaseNumCommand();
|
|
|
|
}
|
2006-10-20 13:20:50 +00:00
|
|
|
|
2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
* m4/openssl.m4: Added.
* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
readData(), peekData(). Added gnutls support.
* src/HttpDownloadCommand.cc: Removed SleepCommand.h
* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
TrackerInitCommand periodicaly(TorrentMan::minInterval).
* src/TorrentMan.cc: Remove downloadedSize == 0 check from
save().
Instead, added a check for whether setup method has executed
successfully.
* src/TorrentMan.h: Added member vaiable setupComplete. Updated
DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to
300.
* src/Makefile.am: Updated.
* src/messageDigest.h: Added. This is a macro calculating SHA1
digest
using whether OpenSSL or gcrypt, depending on the result of
configure
script.
* src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by
using
messageDigest.h.
* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
* src/PeerListenCommand.cc: Added log about port binded
successfully.
Fixed memory leak.
* src/main.cc: Added gnutls support. Replaced LIB_SSL with
ENABLE_BITTORRENT where they are not related to OpenSSL but
BitTorrent.
Removed instantiation of TrackerInitCommand. Instead,
TrackerWatcherCommand is instantiated and pushed to the command
queue.
* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL
with
ENABLE_SSL.
* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
* src/RequestSlotMan.cc:
(deleteCompletedRequestSlot)
If a piece is already acquired by another command, delete the
request
slots for the piece.
* src/TrackerUpdateCommand.cc:
(execute)
Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to
warn.
Added a check whether peer list is null.
Fixed the bug that causes sending completed event to the tracker
several times.
* src/TrackerInitCommand.cc:
(execute)
Fixed the bug that causes sending completed event to the tracker
several times.
* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on
OpenSSL
by using messageDigest.h.
2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* PeerConnection.cc: Replaced log message "keep-alive" with
"keep alive".
* PeerInteractionCommand.{h,cc}: Close connection if peer is
choking
localhost long time.
* TorrentMan.cc: When adding new peer with duplicate = true, if
the
number of peer list is equal to or grater than MAX_PEER_LIST,
delete
at most 100 failure entry from the list. If with duplicate =
false,
MAX_PEER_LIST is not checked.
* PeerListenCommand.cc: Fixed the argument order of log message.
2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
Added warn().
* SimpleLogger.h: Moved enum LEVEL to Logger.h.
Implemented warn().
Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated
code.
2006-03-27 14:47:26 +00:00
|
|
|
bool TrackerWatcherCommand::execute() {
|
2007-12-07 13:33:59 +00:00
|
|
|
if(_requestGroup->isForceHaltRequested()) {
|
|
|
|
if(_trackerRequestGroup.isNull()) {
|
|
|
|
return true;
|
|
|
|
} else if(_trackerRequestGroup->getNumCommand() == 0 ||
|
|
|
|
_trackerRequestGroup->downloadFinished()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
_trackerRequestGroup->setForceHaltRequested(true);
|
2009-09-09 13:28:52 +00:00
|
|
|
e->commands.push_back(this);
|
2007-12-07 13:33:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2008-11-03 06:49:02 +00:00
|
|
|
if(_btAnnounce->noMoreAnnounce()) {
|
2007-10-11 16:58:24 +00:00
|
|
|
logger->debug("no more announce");
|
2006-10-20 13:20:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_trackerRequestGroup.isNull()) {
|
|
|
|
_trackerRequestGroup = createAnnounce();
|
|
|
|
if(!_trackerRequestGroup.isNull()) {
|
2008-05-11 09:36:39 +00:00
|
|
|
std::deque<Command*> commands;
|
2009-07-04 14:32:53 +00:00
|
|
|
_trackerRequestGroup->createInitialCommand(commands, e);
|
2008-05-11 09:36:39 +00:00
|
|
|
e->addCommand(commands);
|
2007-10-11 16:58:24 +00:00
|
|
|
logger->debug("added tracker request command");
|
|
|
|
}
|
|
|
|
} else if(_trackerRequestGroup->downloadFinished()){
|
|
|
|
try {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string trackerResponse = getTrackerResponse(_trackerRequestGroup);
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
|
|
processTrackerResponse(trackerResponse);
|
2008-11-03 06:49:02 +00:00
|
|
|
_btAnnounce->announceSuccess();
|
|
|
|
_btAnnounce->resetAnnounce();
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(RecoverableException& ex) {
|
2007-11-04 12:26:12 +00:00
|
|
|
logger->error(EX_EXCEPTION_CAUGHT, ex);
|
2008-11-03 06:49:02 +00:00
|
|
|
_btAnnounce->announceFailure();
|
|
|
|
if(_btAnnounce->isAllAnnounceFailed()) {
|
|
|
|
_btAnnounce->resetAnnounce();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-20 00:50:22 +00:00
|
|
|
_trackerRequestGroup.reset();
|
2007-10-11 16:58:24 +00:00
|
|
|
} else if(_trackerRequestGroup->getNumCommand() == 0){
|
|
|
|
// handle errors here
|
2008-11-03 06:49:02 +00:00
|
|
|
_btAnnounce->announceFailure(); // inside it, trackers = 0.
|
2008-04-20 00:50:22 +00:00
|
|
|
_trackerRequestGroup.reset();
|
2008-11-03 06:49:02 +00:00
|
|
|
if(_btAnnounce->isAllAnnounceFailed()) {
|
|
|
|
_btAnnounce->resetAnnounce();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2006-10-20 13:20:50 +00:00
|
|
|
}
|
|
|
|
e->commands.push_back(this);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-11-03 06:49:02 +00:00
|
|
|
std::string TrackerWatcherCommand::getTrackerResponse
|
|
|
|
(const RequestGroupHandle& requestGroup)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::stringstream strm;
|
2008-03-07 12:05:50 +00:00
|
|
|
unsigned char data[2048];
|
2007-10-11 16:58:24 +00:00
|
|
|
requestGroup->getPieceStorage()->getDiskAdaptor()->openFile();
|
|
|
|
while(1) {
|
2008-11-03 06:49:02 +00:00
|
|
|
ssize_t dataLength = requestGroup->getPieceStorage()->
|
|
|
|
getDiskAdaptor()->readData(data, sizeof(data), strm.tellp());
|
2007-10-11 16:58:24 +00:00
|
|
|
if(dataLength == 0) {
|
|
|
|
break;
|
|
|
|
}
|
2008-03-09 12:24:01 +00:00
|
|
|
strm.write(reinterpret_cast<const char*>(data), dataLength);
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
return strm.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO we have to deal with the exception thrown By BtAnnounce
|
2008-11-03 06:49:02 +00:00
|
|
|
void TrackerWatcherCommand::processTrackerResponse
|
|
|
|
(const std::string& trackerResponse)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2008-11-03 06:49:02 +00:00
|
|
|
_btAnnounce->processAnnounceResponse
|
|
|
|
(reinterpret_cast<const unsigned char*>(trackerResponse.c_str()),
|
2007-10-11 16:58:24 +00:00
|
|
|
trackerResponse.size());
|
2008-11-03 06:49:02 +00:00
|
|
|
while(!_btRuntime->isHalt() && _btRuntime->lessThanMinPeers()) {
|
|
|
|
PeerHandle peer = _peerStorage->getUnusedPeer();
|
2007-10-11 16:58:24 +00:00
|
|
|
if(peer.isNull()) {
|
|
|
|
break;
|
|
|
|
}
|
2008-11-03 07:49:13 +00:00
|
|
|
peer->usedBy(e->newCUID());
|
2007-10-11 16:58:24 +00:00
|
|
|
PeerInitiateConnectionCommand* command =
|
2009-06-28 10:37:15 +00:00
|
|
|
new PeerInitiateConnectionCommand
|
|
|
|
(peer->usedBy(), _requestGroup, peer, e, _btRuntime);
|
2008-11-03 06:49:02 +00:00
|
|
|
command->setPeerStorage(_peerStorage);
|
|
|
|
command->setPieceStorage(_pieceStorage);
|
2007-10-11 16:58:24 +00:00
|
|
|
e->commands.push_back(command);
|
2008-02-09 17:14:40 +00:00
|
|
|
logger->debug("CUID#%d - Adding new command CUID#%d", cuid, peer->usedBy());
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-22 16:55:56 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
RequestGroupHandle TrackerWatcherCommand::createAnnounce() {
|
2008-04-20 00:50:22 +00:00
|
|
|
RequestGroupHandle rg;
|
2008-11-03 06:49:02 +00:00
|
|
|
if(_btAnnounce->isAnnounceReady()) {
|
|
|
|
rg = createRequestGroup(_btAnnounce->getAnnounceUrl());
|
|
|
|
_btAnnounce->announceStart(); // inside it, trackers++.
|
2006-10-18 14:57:00 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
return rg;
|
2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
* m4/openssl.m4: Added.
* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
readData(), peekData(). Added gnutls support.
* src/HttpDownloadCommand.cc: Removed SleepCommand.h
* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
TrackerInitCommand periodicaly(TorrentMan::minInterval).
* src/TorrentMan.cc: Remove downloadedSize == 0 check from
save().
Instead, added a check for whether setup method has executed
successfully.
* src/TorrentMan.h: Added member vaiable setupComplete. Updated
DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to
300.
* src/Makefile.am: Updated.
* src/messageDigest.h: Added. This is a macro calculating SHA1
digest
using whether OpenSSL or gcrypt, depending on the result of
configure
script.
* src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by
using
messageDigest.h.
* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
* src/PeerListenCommand.cc: Added log about port binded
successfully.
Fixed memory leak.
* src/main.cc: Added gnutls support. Replaced LIB_SSL with
ENABLE_BITTORRENT where they are not related to OpenSSL but
BitTorrent.
Removed instantiation of TrackerInitCommand. Instead,
TrackerWatcherCommand is instantiated and pushed to the command
queue.
* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL
with
ENABLE_SSL.
* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
* src/RequestSlotMan.cc:
(deleteCompletedRequestSlot)
If a piece is already acquired by another command, delete the
request
slots for the piece.
* src/TrackerUpdateCommand.cc:
(execute)
Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to
warn.
Added a check whether peer list is null.
Fixed the bug that causes sending completed event to the tracker
several times.
* src/TrackerInitCommand.cc:
(execute)
Fixed the bug that causes sending completed event to the tracker
several times.
* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on
OpenSSL
by using messageDigest.h.
2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* PeerConnection.cc: Replaced log message "keep-alive" with
"keep alive".
* PeerInteractionCommand.{h,cc}: Close connection if peer is
choking
localhost long time.
* TorrentMan.cc: When adding new peer with duplicate = true, if
the
number of peer list is equal to or grater than MAX_PEER_LIST,
delete
at most 100 failure entry from the list. If with duplicate =
false,
MAX_PEER_LIST is not checked.
* PeerListenCommand.cc: Fixed the argument order of log message.
2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
Added warn().
* SimpleLogger.h: Moved enum LEVEL to Logger.h.
Implemented warn().
Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated
code.
2006-03-27 14:47:26 +00:00
|
|
|
}
|
2006-10-18 14:57:00 +00:00
|
|
|
|
2009-02-01 03:24:02 +00:00
|
|
|
static bool backupTrackerIsAvailable
|
2009-06-28 10:37:15 +00:00
|
|
|
(const SharedHandle<DownloadContext>& context)
|
2009-02-01 03:24:02 +00:00
|
|
|
{
|
2009-06-28 10:37:15 +00:00
|
|
|
const BDE& announceList =
|
|
|
|
context->getAttribute(bittorrent::BITTORRENT)[bittorrent::ANNOUNCE_LIST];
|
|
|
|
if(announceList.size() >= 2) {
|
2009-02-01 03:24:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-06-28 10:37:15 +00:00
|
|
|
if(announceList.empty()) {
|
2009-02-01 03:24:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-06-28 10:37:15 +00:00
|
|
|
if(announceList[0].size() >= 2) {
|
2009-02-01 03:24:02 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
RequestGroupHandle
|
2008-02-08 15:53:45 +00:00
|
|
|
TrackerWatcherCommand::createRequestGroup(const std::string& uri)
|
2007-03-21 10:19:23 +00:00
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::deque<std::string> uris;
|
2007-10-11 16:58:24 +00:00
|
|
|
uris.push_back(uri);
|
2009-06-29 08:42:58 +00:00
|
|
|
RequestGroupHandle rg(new RequestGroup(getOption()));
|
2009-02-01 03:24:02 +00:00
|
|
|
// If backup tracker is available, only try 2 times for each tracker
|
|
|
|
// and if they all fails, then try next one.
|
2009-06-28 10:37:15 +00:00
|
|
|
if(backupTrackerIsAvailable(_requestGroup->getDownloadContext())) {
|
2009-02-01 03:24:02 +00:00
|
|
|
logger->debug("This is multi-tracker announce.");
|
2009-06-12 14:12:54 +00:00
|
|
|
rg->getOption()->put(PREF_MAX_TRIES, "2");
|
2009-02-01 03:24:02 +00:00
|
|
|
} else {
|
|
|
|
logger->debug("This is single-tracker announce.");
|
2009-06-12 14:12:54 +00:00
|
|
|
rg->getOption()->put(PREF_MAX_TRIES, "5");
|
2009-02-01 03:24:02 +00:00
|
|
|
}
|
2009-07-04 14:32:53 +00:00
|
|
|
// TODO When dry-run mode becomes available in BitTorrent, set
|
|
|
|
// PREF_DRY_RUN=false too.
|
|
|
|
rg->getOption()->put(PREF_USE_HEAD, V_FALSE);
|
2007-05-20 13:51:52 +00:00
|
|
|
|
2008-05-14 15:22:52 +00:00
|
|
|
static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]");
|
2009-06-28 10:37:15 +00:00
|
|
|
SharedHandle<DownloadContext> dctx
|
|
|
|
(new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE),
|
|
|
|
0,
|
|
|
|
TRACKER_ANNOUNCE_FILE));
|
2008-05-13 14:15:23 +00:00
|
|
|
dctx->setDir(A2STR::NIL);
|
2009-06-23 15:35:45 +00:00
|
|
|
dctx->getFileEntries().front()->setUris(uris);
|
2007-10-11 16:58:24 +00:00
|
|
|
rg->setDownloadContext(dctx);
|
2008-04-20 00:50:22 +00:00
|
|
|
SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
|
|
|
|
rg->setDiskWriterFactory(dwf);
|
2007-10-11 16:58:24 +00:00
|
|
|
rg->setFileAllocationEnabled(false);
|
|
|
|
rg->setPreLocalFileCheckEnabled(false);
|
|
|
|
logger->info("Creating tracker request group GID#%d", rg->getGID());
|
|
|
|
return rg;
|
2006-10-18 14:57:00 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2008-11-03 06:49:02 +00:00
|
|
|
void TrackerWatcherCommand::setBtRuntime
|
|
|
|
(const SharedHandle<BtRuntime>& btRuntime)
|
|
|
|
{
|
|
|
|
_btRuntime = btRuntime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrackerWatcherCommand::setPeerStorage
|
|
|
|
(const SharedHandle<PeerStorage>& peerStorage)
|
|
|
|
{
|
|
|
|
_peerStorage = peerStorage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrackerWatcherCommand::setPieceStorage
|
|
|
|
(const SharedHandle<PieceStorage>& pieceStorage)
|
|
|
|
{
|
|
|
|
_pieceStorage = pieceStorage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrackerWatcherCommand::setBtAnnounce
|
|
|
|
(const SharedHandle<BtAnnounce>& btAnnounce)
|
|
|
|
{
|
|
|
|
_btAnnounce = btAnnounce;
|
|
|
|
}
|
|
|
|
|
2009-05-08 16:41:21 +00:00
|
|
|
const SharedHandle<Option>& TrackerWatcherCommand::getOption() const
|
|
|
|
{
|
|
|
|
return _requestGroup->getOption();
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|