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
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-09-21 15:31:24 +00:00
|
|
|
*
|
|
|
|
* 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"
|
2010-11-20 08:21:36 +00:00
|
|
|
#include "LogFactory.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"
|
2010-01-11 15:35:12 +00:00
|
|
|
#include "a2functional.h"
|
2010-03-21 07:05:49 +00:00
|
|
|
#include "util.h"
|
2010-11-20 08:21:36 +00:00
|
|
|
#include "fmt.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
|
2010-11-20 08:21:36 +00:00
|
|
|
(cuid_t cuid, RequestGroup* requestGroup, DownloadEngine* e)
|
|
|
|
: Command(cuid),
|
|
|
|
requestGroup_(requestGroup),
|
|
|
|
e_(e)
|
2009-04-23 15:00:09 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
requestGroup_->increaseNumCommand();
|
2009-04-23 15:00:09 +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
|
|
|
|
2009-04-23 15:00:09 +00:00
|
|
|
TrackerWatcherCommand::~TrackerWatcherCommand()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
requestGroup_->decreaseNumCommand();
|
2009-04-23 15:00:09 +00:00
|
|
|
}
|
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() {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(requestGroup_->isForceHaltRequested()) {
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!trackerRequestGroup_) {
|
2007-12-07 13:33:59 +00:00
|
|
|
return true;
|
2010-06-21 13:51:56 +00:00
|
|
|
} else if(trackerRequestGroup_->getNumCommand() == 0 ||
|
|
|
|
trackerRequestGroup_->downloadFinished()) {
|
2007-12-07 13:33:59 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
trackerRequestGroup_->setForceHaltRequested(true);
|
2011-05-15 14:35:06 +00:00
|
|
|
e_->setRefreshInterval(0);
|
2010-06-21 13:51:56 +00:00
|
|
|
e_->addCommand(this);
|
2007-12-07 13:33:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
if(btAnnounce_->noMoreAnnounce()) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG("no more announce");
|
2006-10-20 13:20:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!trackerRequestGroup_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
trackerRequestGroup_ = createAnnounce();
|
2010-11-12 12:48:48 +00:00
|
|
|
if(trackerRequestGroup_) {
|
2010-01-11 15:35:12 +00:00
|
|
|
try {
|
2010-06-20 11:37:47 +00:00
|
|
|
std::vector<Command*>* commands = new std::vector<Command*>();
|
|
|
|
auto_delete_container<std::vector<Command*> > commandsDel(commands);
|
2010-06-21 13:51:56 +00:00
|
|
|
trackerRequestGroup_->createInitialCommand(*commands, e_);
|
|
|
|
e_->addCommand(*commands);
|
2010-06-20 11:37:47 +00:00
|
|
|
commands->clear();
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG("added tracker request command");
|
2010-01-11 15:35:12 +00:00
|
|
|
} catch(RecoverableException& ex) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
} else if(trackerRequestGroup_->downloadFinished()){
|
2007-10-11 16:58:24 +00:00
|
|
|
try {
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string trackerResponse = getTrackerResponse(trackerRequestGroup_);
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
|
|
processTrackerResponse(trackerResponse);
|
2010-06-21 13:51:56 +00:00
|
|
|
btAnnounce_->announceSuccess();
|
|
|
|
btAnnounce_->resetAnnounce();
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(RecoverableException& ex) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
|
2010-06-21 13:51:56 +00:00
|
|
|
btAnnounce_->announceFailure();
|
|
|
|
if(btAnnounce_->isAllAnnounceFailed()) {
|
|
|
|
btAnnounce_->resetAnnounce();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
trackerRequestGroup_.reset();
|
|
|
|
} else if(trackerRequestGroup_->getNumCommand() == 0){
|
2007-10-11 16:58:24 +00:00
|
|
|
// handle errors here
|
2010-06-21 13:51:56 +00:00
|
|
|
btAnnounce_->announceFailure(); // inside it, trackers = 0.
|
|
|
|
trackerRequestGroup_.reset();
|
|
|
|
if(btAnnounce_->isAllAnnounceFailed()) {
|
|
|
|
btAnnounce_->resetAnnounce();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2006-10-20 13:20:50 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
e_->addCommand(this);
|
2006-10-20 13:20:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-11-03 06:49:02 +00:00
|
|
|
std::string TrackerWatcherCommand::getTrackerResponse
|
2010-02-28 12:30:11 +00:00
|
|
|
(const SharedHandle<RequestGroup>& 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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
btAnnounce_->processAnnounceResponse
|
2008-11-03 06:49:02 +00:00
|
|
|
(reinterpret_cast<const unsigned char*>(trackerResponse.c_str()),
|
2010-01-05 16:01:46 +00:00
|
|
|
trackerResponse.size());
|
2010-06-21 13:51:56 +00:00
|
|
|
while(!btRuntime_->isHalt() && btRuntime_->lessThanMinPeers()) {
|
|
|
|
SharedHandle<Peer> peer = peerStorage_->getUnusedPeer();
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!peer) {
|
2007-10-11 16:58:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-06-21 13:51:56 +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
|
2010-06-21 13:51:56 +00:00
|
|
|
(peer->usedBy(), requestGroup_, peer, e_, btRuntime_);
|
|
|
|
command->setPeerStorage(peerStorage_);
|
|
|
|
command->setPieceStorage(pieceStorage_);
|
|
|
|
e_->addCommand(command);
|
2012-06-25 13:43:33 +00:00
|
|
|
A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Adding new command CUID#%" PRId64 "",
|
2011-11-13 11:55:06 +00:00
|
|
|
getCuid(), peer->usedBy()));
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-22 16:55:56 +00:00
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
SharedHandle<RequestGroup> TrackerWatcherCommand::createAnnounce() {
|
|
|
|
SharedHandle<RequestGroup> rg;
|
2010-06-21 13:51:56 +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
|
|
|
|
2010-10-30 16:02:15 +00:00
|
|
|
namespace {
|
|
|
|
bool backupTrackerIsAvailable
|
2009-06-28 10:37:15 +00:00
|
|
|
(const SharedHandle<DownloadContext>& context)
|
2009-02-01 03:24:02 +00:00
|
|
|
{
|
2010-06-18 14:47:09 +00:00
|
|
|
SharedHandle<TorrentAttribute> torrentAttrs =
|
|
|
|
bittorrent::getTorrentAttrs(context);
|
|
|
|
if(torrentAttrs->announceList.size() >= 2) {
|
2009-02-01 03:24:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-18 14:47:09 +00:00
|
|
|
if(torrentAttrs->announceList.empty()) {
|
2009-02-01 03:24:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-06-18 14:47:09 +00:00
|
|
|
if(torrentAttrs->announceList[0].size() >= 2) {
|
2009-02-01 03:24:02 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2010-10-30 16:02:15 +00:00
|
|
|
} // namespace
|
2009-02-01 03:24:02 +00:00
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
SharedHandle<RequestGroup>
|
2008-02-08 15:53:45 +00:00
|
|
|
TrackerWatcherCommand::createRequestGroup(const std::string& uri)
|
2007-03-21 10:19:23 +00:00
|
|
|
{
|
2010-02-28 12:30:11 +00:00
|
|
|
std::vector<std::string> uris;
|
2007-10-11 16:58:24 +00:00
|
|
|
uris.push_back(uri);
|
2011-10-25 12:44:04 +00:00
|
|
|
SharedHandle<Option> option = util::copy(getOption());
|
|
|
|
SharedHandle<RequestGroup> rg(new RequestGroup(option));
|
2010-06-21 13:51:56 +00:00
|
|
|
if(backupTrackerIsAvailable(requestGroup_->getDownloadContext())) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG("This is multi-tracker announce.");
|
2009-02-01 03:24:02 +00:00
|
|
|
} else {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG("This is single-tracker announce.");
|
2009-02-01 03:24:02 +00:00
|
|
|
}
|
2010-07-14 11:39:05 +00:00
|
|
|
rg->setNumConcurrentCommand(1);
|
2010-03-30 14:17:16 +00:00
|
|
|
// If backup tracker is available, try 2 times for each tracker
|
|
|
|
// and if they all fails, then try next one.
|
2011-10-25 12:44:04 +00:00
|
|
|
option->put(PREF_MAX_TRIES, "2");
|
2009-07-04 14:32:53 +00:00
|
|
|
// TODO When dry-run mode becomes available in BitTorrent, set
|
|
|
|
// PREF_DRY_RUN=false too.
|
2011-10-25 12:44:04 +00:00
|
|
|
option->put(PREF_USE_HEAD, A2_V_FALSE);
|
2010-03-30 14:17:16 +00:00
|
|
|
// Setting tracker timeouts
|
2011-10-25 12:44:04 +00:00
|
|
|
rg->setTimeout(option->getAsInt(PREF_BT_TRACKER_TIMEOUT));
|
|
|
|
option->put(PREF_CONNECT_TIMEOUT,
|
|
|
|
option->get(PREF_BT_TRACKER_CONNECT_TIMEOUT));
|
|
|
|
option->put(PREF_REUSE_URI, A2_V_FALSE);
|
|
|
|
option->put(PREF_SELECT_LEAST_USED_HOST, A2_V_FALSE);
|
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
|
2011-10-25 12:44:04 +00:00
|
|
|
(new DownloadContext(option->getAsInt(PREF_PIECE_LENGTH),
|
2010-01-05 16:01:46 +00:00
|
|
|
0,
|
|
|
|
TRACKER_ANNOUNCE_FILE));
|
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);
|
2010-04-01 15:41:53 +00:00
|
|
|
util::removeMetalinkContentTypes(rg);
|
2012-06-25 13:43:33 +00:00
|
|
|
A2_LOG_INFO(fmt("Creating tracker request group GID#%" PRId64 "", rg->getGID()));
|
2007-10-11 16:58:24 +00:00
|
|
|
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)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
btRuntime_ = btRuntime;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrackerWatcherCommand::setPeerStorage
|
|
|
|
(const SharedHandle<PeerStorage>& peerStorage)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
peerStorage_ = peerStorage;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrackerWatcherCommand::setPieceStorage
|
|
|
|
(const SharedHandle<PieceStorage>& pieceStorage)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_ = pieceStorage;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrackerWatcherCommand::setBtAnnounce
|
|
|
|
(const SharedHandle<BtAnnounce>& btAnnounce)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
btAnnounce_ = btAnnounce;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
2009-05-08 16:41:21 +00:00
|
|
|
const SharedHandle<Option>& TrackerWatcherCommand::getOption() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return requestGroup_->getOption();
|
2009-05-08 16:41:21 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|