2006-08-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

* src/FeatureConfig.cc
	(FEATURE_ASYNC_DNS): New definition.
	(FeatureConfig): Added aysnc DNS entry.

	To replace CommandUuid with Command* in SocketEntry and
	NameResolverEntry:
	
	* src/DownloadEngine.h
	(CommandUuids): Removed.
	(SocketEntry::commandUuid): Removed.
	(SocketEntry::command): New variable.
	(SocketEntry::SocketEntry): Updated.
	(SocketEntry::operator==): Updated.
	(NameResolverEntry::commandUuid): Removed.
	(NameResolverEntry::command): New variable.
	(NameResolverEntry::NameResolverEntry): Updated.
	(NameResolverEntry::operator==): Updated.
	(waitData): Changed the argument type.
	(addSocketForReadCheck): Changed the argument type.
	(deleteSocketForReadCheck): Changed the argument type.
	(addSocketForWriteCheck): Changed the argument type.
	(deleteSocketForWriteCheck): Changed the argument type.
	(addNameResolverCheck): Changed the argument type.
	(deleteNameResolverCheck): Changed the argument type.
	* src/DownloadEngine.cc
	(FindCommand): Removed.
	(run): Removed activeUuid. Added activeCommands instead.
	(AccumulateActiveUuid): Renamed as AccumulateActiveCommand.
	(AccumulateActiveCommand): New function object.
	(waitData): Use AccumulateActiveCommand.
	(addSocketForReadCheck): Use Command instead of CommandUuid.
	(deleteSocketForReadCheck): Use Command instead of CommandUuid.
	(addSocketForWriteCheck): Use Command instead of CommandUuid.
	(deleteSocketForWriteCheck): Use Command instead of CommandUuid.
	(addNameResolverCheck): Use Command instead of CommandUuid.
	(deleteNameResolverCheck): Use Command instead of CommandUuid.	
	* src/AbstractCommand.cc
	(disableReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(disableWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setNameResolverCheck): Updated according to the changes in
	DownloadEngine.
	(disableNameResolverCheck): Updated according to the changes in
	DownloadEngine.
	* src/AbstractCommand.cc
	(disableReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(disableWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setWriteCheckSocket): Updated according to the changes in
	DownloadEngine.

	* release 0.7.1
pull/1/head
Tatsuhiro Tsujikawa 2006-08-14 15:03:38 +00:00
parent e3b0153e85
commit 11dc664f83
19 changed files with 240 additions and 115 deletions

View File

@ -7,6 +7,67 @@
(printDownloadAbortMessage): Added a message to inform users that
transfer can be resumed.
* src/FeatureConfig.cc
(FEATURE_ASYNC_DNS): New definition.
(FeatureConfig): Added aysnc DNS entry.
To replace CommandUuid with Command* in SocketEntry and
NameResolverEntry:
* src/DownloadEngine.h
(CommandUuids): Removed.
(SocketEntry::commandUuid): Removed.
(SocketEntry::command): New variable.
(SocketEntry::SocketEntry): Updated.
(SocketEntry::operator==): Updated.
(NameResolverEntry::commandUuid): Removed.
(NameResolverEntry::command): New variable.
(NameResolverEntry::NameResolverEntry): Updated.
(NameResolverEntry::operator==): Updated.
(waitData): Changed the argument type.
(addSocketForReadCheck): Changed the argument type.
(deleteSocketForReadCheck): Changed the argument type.
(addSocketForWriteCheck): Changed the argument type.
(deleteSocketForWriteCheck): Changed the argument type.
(addNameResolverCheck): Changed the argument type.
(deleteNameResolverCheck): Changed the argument type.
* src/DownloadEngine.cc
(FindCommand): Removed.
(run): Removed activeUuid. Added activeCommands instead.
(AccumulateActiveUuid): Renamed as AccumulateActiveCommand.
(AccumulateActiveCommand): New function object.
(waitData): Use AccumulateActiveCommand.
(addSocketForReadCheck): Use Command instead of CommandUuid.
(deleteSocketForReadCheck): Use Command instead of CommandUuid.
(addSocketForWriteCheck): Use Command instead of CommandUuid.
(deleteSocketForWriteCheck): Use Command instead of CommandUuid.
(addNameResolverCheck): Use Command instead of CommandUuid.
(deleteNameResolverCheck): Use Command instead of CommandUuid.
* src/AbstractCommand.cc
(disableReadCheckSocket): Updated according to the changes in
DownloadEngine.
(setReadCheckSocket): Updated according to the changes in
DownloadEngine.
(disableWriteCheckSocket): Updated according to the changes in
DownloadEngine.
(setWriteCheckSocket): Updated according to the changes in
DownloadEngine.
(setNameResolverCheck): Updated according to the changes in
DownloadEngine.
(disableNameResolverCheck): Updated according to the changes in
DownloadEngine.
* src/AbstractCommand.cc
(disableReadCheckSocket): Updated according to the changes in
DownloadEngine.
(setReadCheckSocket): Updated according to the changes in
DownloadEngine.
(disableWriteCheckSocket): Updated according to the changes in
DownloadEngine.
(setWriteCheckSocket): Updated according to the changes in
DownloadEngine.
* release 0.7.1
2006-08-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle the case where some BitTorrent tracker requires all letters
@ -108,6 +169,8 @@
* src/RequestSlot.h: Replaced Time.h with TimeA2.h.
* src/SleepCommand.h: Replaced Time.h with TimeA2.h.
* src/DownloadEngine.cc: Replaced Time.h with TimeA2.h.
* release 0.7.0
2006-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

3
TODO
View File

@ -12,4 +12,5 @@
* Query resource by location
* List available os, version, etc for metalink
* ipv6(RFC2428 for ftp)
* default prefix in libares.m4 must be the value of --prefex, not /usr/local
* Add some criteria to stop seeding.
* Add silent mode.

32
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for aria2c 0.7.0.
# Generated by GNU Autoconf 2.59 for aria2c 0.7.1.
#
# Report bugs to <tujikawa@rednoah.com>.
#
@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='aria2c'
PACKAGE_TARNAME='aria2c'
PACKAGE_VERSION='0.7.0'
PACKAGE_STRING='aria2c 0.7.0'
PACKAGE_VERSION='0.7.1'
PACKAGE_STRING='aria2c 0.7.1'
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.7.0 to adapt to many kinds of systems.
\`configure' configures aria2c 0.7.1 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.7.0:";;
short | recursive ) echo "Configuration of aria2c 0.7.1:";;
esac
cat <<\_ACEOF
@ -877,7 +877,7 @@ Optional Packages:
--with-gnutls use gnutls library if installed. Default: yes
--with-openssl use openssl library if installed. Default: yes
--with-libxml2 use libxml2 library if installed. Default: yes
--with-ares use ares library if installed. Default: yes
--with-libares use ares library if installed. Default: yes
--with-xml-prefix=PFX Prefix where libxml is installed (optional)
--with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)
--with-libgnutls-prefix=PFX Prefix where libgnutls is installed (optional)
@ -1002,7 +1002,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
aria2c configure 0.7.0
aria2c configure 0.7.1
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@ -1016,7 +1016,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.7.0, which was
It was created by aria2c $as_me 0.7.1, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@ -1659,7 +1659,7 @@ fi
# Define the identity of the package.
PACKAGE='aria2c'
VERSION='0.7.0'
VERSION='0.7.1'
cat >>confdefs.h <<_ACEOF
@ -1950,9 +1950,9 @@ else
with_libxml2=yes
fi;
# Check whether --with-ares or --without-ares was given.
if test "${with_ares+set}" = set; then
withval="$with_ares"
# Check whether --with-libares or --without-libares was given.
if test "${with_libares+set}" = set; then
withval="$with_libares"
with_libares=$withval
else
with_libares=yes
@ -4647,7 +4647,7 @@ else
fi;
if test "x$libares_prefix" = "x"; then
libares_prefix="/usr/local"
libares_prefix="/usr"
fi
libares_prefix_lib=$libares_prefix/lib
@ -4738,10 +4738,10 @@ _ACEOF
fi
LIBS=$LIBS_save
CPPFLAGS=$CPPFLAGS_save
fi
# Define variables based on the result of the checks for libraries.
@ -12101,7 +12101,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by aria2c $as_me 0.7.0, which was
This file was extended by aria2c $as_me 0.7.1, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -12164,7 +12164,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
aria2c config.status 0.7.0
aria2c config.status 0.7.1
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
#
AC_PREREQ(2.59)
AC_INIT(aria2c, 0.7.0, tujikawa@rednoah.com)
AC_INIT(aria2c, 0.7.1, tujikawa@rednoah.com)
AM_INIT_AUTOMAKE()
AM_PATH_CPPUNIT(1.10.2)
AC_CONFIG_SRCDIR([src/Socket.h])
@ -16,7 +16,7 @@ AC_SUBST(localedir)
AC_ARG_WITH([gnutls], [ --with-gnutls use gnutls library if installed. Default: yes], [with_gnutls=$withval], [with_gnutls=yes])
AC_ARG_WITH([openssl], [ --with-openssl use openssl library if installed. Default: yes], [with_openssl=$withval], [with_openssl=yes])
AC_ARG_WITH([libxml2], [ --with-libxml2 use libxml2 library if installed. Default: yes], [with_libxml2=$withval], [with_libxml2=yes])
AC_ARG_WITH([ares], [ --with-ares use ares library if installed. Default: yes], [with_libares=$withval], [with_libares=yes])
AC_ARG_WITH([libares], [ --with-libares use ares library if installed. Default: yes], [with_libares=$withval], [with_libares=yes])
AC_ARG_ENABLE([bittorrent], [ --enable-bittorrent enable BitTorrent support. Default: yes], [enable_bittorrent=$enableval], [enable_bittorrent=yes])
AC_ARG_ENABLE([metalink], [ --enable-metalink enable Metalink support. Default: yes], [enable_metalink=$enableval], [enable_metalink=yes])

View File

@ -6,7 +6,7 @@ AC_ARG_WITH([libares-prefix],
[libares_prefix=""])
if test "x$libares_prefix" = "x"; then
libares_prefix="/usr/local"
libares_prefix="/usr"
fi
libares_prefix_lib=$libares_prefix/lib
@ -27,7 +27,7 @@ if test "x$have_libares" = "xyes"; then
AC_SUBST(LIBARES_CPPFLAGS)
fi
LIBS=$LIBS_save
CPPFLAGS=$CPPFLAGS_save
])

View File

@ -9,7 +9,7 @@
# General Public License and is *not* in the public domain.
PACKAGE = aria2c
VERSION = 0.7.0
VERSION = 0.7.1
SHELL = /bin/sh

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
"POT-Creation-Date: 2006-08-08 01:22+0900\n"
"POT-Creation-Date: 2006-08-14 23:18+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -27,6 +27,7 @@ msgstr ""
msgid ""
"\n"
"The download was not complete because of errors. Check the log.\n"
"aria2 will resume download if the transfer is restarted."
msgstr ""
#: src/message.h:27
@ -790,3 +791,18 @@ msgstr ""
#: src/main.cc:614
msgid "daemon failed"
msgstr ""
#: src/main.cc:676
msgid ""
"Now verifying checksum.\n"
"This may take some time depending on your PC environment and the size of "
"file."
msgstr ""
#: src/main.cc:680
msgid "checksum OK."
msgstr ""
#: src/main.cc:683
msgid "checksum ERROR."
msgstr ""

BIN
po/de.gmo

Binary file not shown.

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: de\n"
"Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
"POT-Creation-Date: 2006-08-08 01:22+0900\n"
"POT-Creation-Date: 2006-08-14 23:18+0900\n"
"PO-Revision-Date: 2006-05-05 19:44+0900\n"
"Last-Translator: Hermann J. Beckers <hj.beckers@onlinehome.de>\n"
"Language-Team: deutsch <de@li.org>\n"
@ -26,9 +26,11 @@ msgstr ""
"Abruf ist vollständig. <%s>\n"
#: src/RequestInfo.h:92
#, fuzzy
msgid ""
"\n"
"The download was not complete because of errors. Check the log.\n"
"aria2 will resume download if the transfer is restarted."
msgstr ""
"\n"
"Abruf wegen Fehlern nicht vollständig. Überprüfen Sie die Log-Datei.\n"
@ -926,3 +928,18 @@ msgstr "Geben Sie zumindest eine URL an"
#: src/main.cc:614
msgid "daemon failed"
msgstr "Daemon-Start nicht erfolgreich"
#: src/main.cc:676
msgid ""
"Now verifying checksum.\n"
"This may take some time depending on your PC environment and the size of "
"file."
msgstr ""
#: src/main.cc:680
msgid "checksum OK."
msgstr ""
#: src/main.cc:683
msgid "checksum ERROR."
msgstr ""

BIN
po/ja.gmo

Binary file not shown.

View File

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: aria2c 0.2.1\n"
"Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
"POT-Creation-Date: 2006-08-08 01:22+0900\n"
"PO-Revision-Date: 2006-08-08 01:27+0900\n"
"POT-Creation-Date: 2006-08-14 23:18+0900\n"
"PO-Revision-Date: 2006-08-14 23:22+0900\n"
"Last-Translator: Tatsuhiro Tsujikawa <tujikawa@rednoah.com>\n"
"Language-Team: Japanese <ja@li.org>\n"
"MIME-Version: 1.0\n"
@ -29,9 +29,11 @@ msgstr ""
msgid ""
"\n"
"The download was not complete because of errors. Check the log.\n"
"aria2 will resume download if the transfer is restarted."
msgstr ""
"\n"
"ダウンロードはエラーのため完了していません. ログを確認してください.\n"
"次回のダウンロードはエラーの時点から再開できます."
#: src/message.h:27
#, c-format
@ -957,3 +959,20 @@ msgstr "
#: src/main.cc:614
msgid "daemon failed"
msgstr "デーモン起動に失敗"
#: src/main.cc:676
msgid ""
"Now verifying checksum.\n"
"This may take some time depending on your PC environment and the size of "
"file."
msgstr ""
"チェックサムを検査しています.\n"
"お使いの PC 環境とファイルサイズにより, ある程度の時間がかかります."
#: src/main.cc:680
msgid "checksum OK."
msgstr "チェックサム OK."
#: src/main.cc:683
msgid "checksum ERROR."
msgstr "チェックサム エラー."

BIN
po/ru.gmo

Binary file not shown.

View File

@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ru\n"
"Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
"POT-Creation-Date: 2006-08-08 01:22+0900\n"
"POT-Creation-Date: 2006-08-14 23:18+0900\n"
"PO-Revision-Date: 2006-07-28 18:04+0600\n"
"Last-Translator: Azamat H. Hackimov <azamat.hackimov@gmail.com>\n"
"Language-Team: <ru@li.org>\n"
@ -31,9 +31,11 @@ msgstr ""
"Скачивание завершено. <%s>\n"
#: src/RequestInfo.h:92
#, fuzzy
msgid ""
"\n"
"The download was not complete because of errors. Check the log.\n"
"aria2 will resume download if the transfer is restarted."
msgstr ""
"\n"
"Скачивание не завершено из-за ошибок. Проверьте лог-файл.\n"
@ -907,3 +909,18 @@ msgstr "укажите по крайней мере один URL"
#: src/main.cc:614
msgid "daemon failed"
msgstr "ошибка демона"
#: src/main.cc:676
msgid ""
"Now verifying checksum.\n"
"This may take some time depending on your PC environment and the size of "
"file."
msgstr ""
#: src/main.cc:680
msgid "checksum OK."
msgstr ""
#: src/main.cc:683
msgid "checksum ERROR."
msgstr ""

View File

@ -120,7 +120,7 @@ void AbstractCommand::onAbort(Exception* ex) {
void AbstractCommand::disableReadCheckSocket() {
if(checkSocketIsReadable) {
e->deleteSocketForReadCheck(readCheckTarget, getUuid());
e->deleteSocketForReadCheck(readCheckTarget, this);
checkSocketIsReadable = false;
readCheckTarget = SocketHandle();
}
@ -132,12 +132,12 @@ void AbstractCommand::setReadCheckSocket(const SocketHandle& socket) {
} else {
if(checkSocketIsReadable) {
if(readCheckTarget != socket) {
e->deleteSocketForReadCheck(readCheckTarget, getUuid());
e->addSocketForReadCheck(socket, getUuid());
e->deleteSocketForReadCheck(readCheckTarget, this);
e->addSocketForReadCheck(socket, this);
readCheckTarget = socket;
}
} else {
e->addSocketForReadCheck(socket, getUuid());
e->addSocketForReadCheck(socket, this);
checkSocketIsReadable = true;
readCheckTarget = socket;
}
@ -146,7 +146,7 @@ void AbstractCommand::setReadCheckSocket(const SocketHandle& socket) {
void AbstractCommand::disableWriteCheckSocket() {
if(checkSocketIsWritable) {
e->deleteSocketForWriteCheck(writeCheckTarget, getUuid());
e->deleteSocketForWriteCheck(writeCheckTarget, this);
checkSocketIsWritable = false;
writeCheckTarget = SocketHandle();
}
@ -158,12 +158,12 @@ void AbstractCommand::setWriteCheckSocket(const SocketHandle& socket) {
} else {
if(checkSocketIsWritable) {
if(writeCheckTarget != socket) {
e->deleteSocketForWriteCheck(writeCheckTarget, getUuid());
e->addSocketForWriteCheck(socket, getUuid());
e->deleteSocketForWriteCheck(writeCheckTarget, this);
e->addSocketForWriteCheck(socket, this);
writeCheckTarget = socket;
}
} else {
e->addSocketForWriteCheck(socket, getUuid());
e->addSocketForWriteCheck(socket, this);
checkSocketIsWritable = true;
writeCheckTarget = socket;
}
@ -172,11 +172,11 @@ void AbstractCommand::setWriteCheckSocket(const SocketHandle& socket) {
#ifdef HAVE_LIBARES
void AbstractCommand::setNameResolverCheck(const NameResolverHandle& resolver) {
e->addNameResolverCheck(resolver, getUuid());
e->addNameResolverCheck(resolver, this);
}
void AbstractCommand::disableNameResolverCheck(const NameResolverHandle& resolver) {
e->deleteNameResolverCheck(resolver, getUuid());
e->deleteNameResolverCheck(resolver, this);
}
bool AbstractCommand::resolveHostname(const string& hostname,

View File

@ -46,27 +46,11 @@ void DownloadEngine::cleanQueue() {
commands.clear();
}
class FindCommand {
private:
CommandUuid uuid;
public:
FindCommand(const CommandUuid& uuid):uuid(uuid) {}
bool operator()(const Command* command) {
if(command->getUuid() == uuid) {
return true;
} else {
return false;
}
}
};
void DownloadEngine::run() {
initStatistics();
Time cp;
cp.setTimeInSec(0);
CommandUuids activeUuids;
Commands activeCommands;
while(!commands.empty()) {
if(cp.elapsed(1)) {
cp.reset();
@ -79,22 +63,22 @@ void DownloadEngine::run() {
}
}
} else {
for(CommandUuids::iterator itr = activeUuids.begin();
itr != activeUuids.end(); itr++) {
Commands::iterator comItr = find_if(commands.begin(), commands.end(),
FindCommand(*itr));
for(Commands::iterator itr = activeCommands.begin();
itr != activeCommands.end(); itr++) {
Commands::iterator comItr = find(commands.begin(), commands.end(),
*itr);
assert(comItr != commands.end());
Command* com = *comItr;
Command* command = *itr;
commands.erase(comItr);
if(com->execute()) {
delete com;
if(command->execute()) {
delete command;
}
}
}
afterEachIteration();
activeUuids.clear();
activeCommands.clear();
if(!noWait && !commands.empty()) {
waitData(activeUuids);
waitData(activeCommands);
}
noWait = false;
calculateStatistics();
@ -146,34 +130,34 @@ public:
#endif // HAVE_LIBARES
};
class AccumulateActiveUuid {
class AccumulateActiveCommand {
private:
CommandUuids* activeUuids_ptr;
Commands* activeCommands_ptr;
fd_set* rfds_ptr;
fd_set* wfds_ptr;
public:
AccumulateActiveUuid(CommandUuids* activeUuids_ptr,
AccumulateActiveCommand(Commands* activeCommands_ptr,
fd_set* rfds_ptr,
fd_set* wfds_ptr):
activeUuids_ptr(activeUuids_ptr),
activeCommands_ptr(activeCommands_ptr),
rfds_ptr(rfds_ptr),
wfds_ptr(wfds_ptr) {}
void operator()(const SocketEntry& entry) {
if(FD_ISSET(entry.socket->getSockfd(), rfds_ptr) ||
FD_ISSET(entry.socket->getSockfd(), wfds_ptr)) {
activeUuids_ptr->push_back(entry.commandUuid);
activeCommands_ptr->push_back(entry.command);
}
/*
switch(entry.type) {
case SocketEntry::TYPE_RD:
if(FD_ISSET(entry.socket->getSockfd(), rfds_ptr)) {
activeUuids_ptr->push_back(entry.commandUuid);
activeCommands_ptr->push_back(entry.command);
}
break;
case SocketEntry::TYPE_WR:
if(FD_ISSET(entry.socket->getSockfd(), wfds_ptr)) {
activeUuids_ptr->push_back(entry.commandUuid);
activeCommands_ptr->push_back(entry.command);
}
break;
}
@ -185,7 +169,7 @@ public:
switch(entry.nameResolver->getStatus()) {
case NameResolver::STATUS_SUCCESS:
case NameResolver::STATUS_ERROR:
activeUuids_ptr->push_back(entry.commandUuid);
activeCommands_ptr->push_back(entry.command);
break;
default:
break;
@ -194,7 +178,7 @@ public:
#endif // HAVE_LIBARES
};
void DownloadEngine::waitData(CommandUuids& activeUuids) {
void DownloadEngine::waitData(Commands& activeCommands) {
fd_set rfds;
fd_set wfds;
int retval = 0;
@ -208,15 +192,15 @@ void DownloadEngine::waitData(CommandUuids& activeUuids) {
retval = select(fdmax+1, &rfds, &wfds, NULL, &tv);
if(retval > 0) {
for_each(socketEntries.begin(), socketEntries.end(),
AccumulateActiveUuid(&activeUuids, &rfds, &wfds));
AccumulateActiveCommand(&activeCommands, &rfds, &wfds));
#ifdef HAVE_LIBARES
for_each(nameResolverEntries.begin(), nameResolverEntries.end(),
AccumulateActiveUuid(&activeUuids, &rfds, &wfds));
AccumulateActiveCommand(&activeCommands, &rfds, &wfds));
#endif // HAVE_LIBARES
sort(activeUuids.begin(), activeUuids.end());
activeUuids.erase(unique(activeUuids.begin(),
activeUuids.end()),
activeUuids.end());
sort(activeCommands.begin(), activeCommands.end());
activeCommands.erase(unique(activeCommands.begin(),
activeCommands.end()),
activeCommands.end());
}
}
@ -257,33 +241,33 @@ bool DownloadEngine::deleteSocket(const SocketEntry& entry) {
}
bool DownloadEngine::addSocketForReadCheck(const SocketHandle& socket,
const CommandUuid& commandUuid) {
SocketEntry entry(socket, commandUuid, SocketEntry::TYPE_RD);
Command* command) {
SocketEntry entry(socket, command, SocketEntry::TYPE_RD);
return addSocket(entry);
}
bool DownloadEngine::deleteSocketForReadCheck(const SocketHandle& socket,
const CommandUuid& commandUuid) {
SocketEntry entry(socket, commandUuid, SocketEntry::TYPE_RD);
Command* command) {
SocketEntry entry(socket, command, SocketEntry::TYPE_RD);
return deleteSocket(entry);
}
bool DownloadEngine::addSocketForWriteCheck(const SocketHandle& socket,
const CommandUuid& commandUuid) {
SocketEntry entry(socket, commandUuid, SocketEntry::TYPE_WR);
Command* command) {
SocketEntry entry(socket, command, SocketEntry::TYPE_WR);
return addSocket(entry);
}
bool DownloadEngine::deleteSocketForWriteCheck(const SocketHandle& socket,
const CommandUuid& commandUuid) {
SocketEntry entry(socket, commandUuid, SocketEntry::TYPE_WR);
Command* command) {
SocketEntry entry(socket, command, SocketEntry::TYPE_WR);
return deleteSocket(entry);
}
#ifdef HAVE_LIBARES
bool DownloadEngine::addNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid) {
NameResolverEntry entry(resolver, uuid);
Command* command) {
NameResolverEntry entry(resolver, command);
NameResolverEntries::iterator itr = find(nameResolverEntries.begin(),
nameResolverEntries.end(),
entry);
@ -297,8 +281,8 @@ bool DownloadEngine::addNameResolverCheck(const NameResolverHandle& resolver,
}
bool DownloadEngine::deleteNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid) {
NameResolverEntry entry(resolver, uuid);
Command* command) {
NameResolverEntry entry(resolver, command);
NameResolverEntries::iterator itr = find(nameResolverEntries.begin(),
nameResolverEntries.end(),
entry);

View File

@ -34,7 +34,6 @@
typedef deque<SocketHandle> Sockets;
typedef deque<Command*> Commands;
typedef deque<CommandUuid> CommandUuids;
class SocketEntry {
public:
@ -44,18 +43,18 @@ public:
};
SocketHandle socket;
CommandUuid commandUuid;
Command* command;
TYPE type;
public:
SocketEntry(const SocketHandle& socket,
const CommandUuid& commandUuid,
Command* command,
TYPE type):
socket(socket), commandUuid(commandUuid), type(type) {}
socket(socket), command(command), type(type) {}
~SocketEntry() {}
bool operator==(const SocketEntry& entry) {
return socket == entry.socket &&
commandUuid == entry.commandUuid &&
command == entry.command &&
type == entry.type;
}
};
@ -66,16 +65,16 @@ typedef deque<SocketEntry> SocketEntries;
class NameResolverEntry {
public:
NameResolverHandle nameResolver;
CommandUuid commandUuid;
Command* command;
public:
NameResolverEntry(const NameResolverHandle& nameResolver,
const CommandUuid& commandUuid):
nameResolver(nameResolver), commandUuid(commandUuid) {}
Command* command):
nameResolver(nameResolver), command(command) {}
~NameResolverEntry() {}
bool operator==(const NameResolverEntry& entry) {
return nameResolver == entry.nameResolver &&
commandUuid == entry.commandUuid;
command == entry.command;
}
};
@ -85,7 +84,7 @@ typedef deque<NameResolverEntry> NameResolverEntries;
class DownloadEngine {
private:
void waitData(CommandUuids& activeUuids);
void waitData(Commands& activeCommands);
SocketEntries socketEntries;
#ifdef HAVE_LIBARES
NameResolverEntries nameResolverEntries;
@ -119,18 +118,18 @@ public:
void updateFdSet();
bool addSocketForReadCheck(const SocketHandle& socket,
const CommandUuid& commandUuid);
Command* command);
bool deleteSocketForReadCheck(const SocketHandle& socket,
const CommandUuid& commandUuid);
Command* command);
bool addSocketForWriteCheck(const SocketHandle& socket,
const CommandUuid& commandUuid);
Command* command);
bool deleteSocketForWriteCheck(const SocketHandle& socket,
const CommandUuid& command);
Command* command);
#ifdef HAVE_LIBARES
bool addNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid);
Command* command);
bool deleteNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid);
Command* command);
#endif // HAVE_LIBARES
};

View File

@ -29,6 +29,7 @@ FeatureConfig* FeatureConfig::featureConfig = 0;
#define FEATURE_BITTORRENT "bittorrent"
#define FEATURE_METALINK "metalink"
#define FEATURE_MESSAGE_DIGEST "message digest"
#define FEATURE_ASYNC_DNS "async dns"
FeatureConfig::FeatureConfig() {
static PortMap::value_type portArray[] = {
@ -71,6 +72,13 @@ FeatureConfig::FeatureConfig() {
false
#endif // ENABLE_MESSAGE_DIGEST
),
FeatureMap::value_type(FEATURE_ASYNC_DNS,
#ifdef HAVE_LIBARES
true
#else
false
#endif // HAVE_LIBARES
),
};
int featureArraySize = sizeof(featureArray)/sizeof(FeatureMap::value_type);

View File

@ -88,7 +88,7 @@ void PeerAbstractCommand::onAbort(Exception* ex) {
void PeerAbstractCommand::disableReadCheckSocket() {
if(checkSocketIsReadable) {
e->deleteSocketForReadCheck(readCheckTarget, getUuid());
e->deleteSocketForReadCheck(readCheckTarget, this);
checkSocketIsReadable = false;
readCheckTarget = SocketHandle();
}
@ -100,12 +100,12 @@ void PeerAbstractCommand::setReadCheckSocket(const SocketHandle& socket) {
} else {
if(checkSocketIsReadable) {
if(readCheckTarget != socket) {
e->deleteSocketForReadCheck(readCheckTarget, getUuid());
e->addSocketForReadCheck(socket, getUuid());
e->deleteSocketForReadCheck(readCheckTarget, this);
e->addSocketForReadCheck(socket, this);
readCheckTarget = socket;
}
} else {
e->addSocketForReadCheck(socket, getUuid());
e->addSocketForReadCheck(socket, this);
checkSocketIsReadable = true;
readCheckTarget = socket;
}
@ -114,7 +114,7 @@ void PeerAbstractCommand::setReadCheckSocket(const SocketHandle& socket) {
void PeerAbstractCommand::disableWriteCheckSocket() {
if(checkSocketIsWritable) {
e->deleteSocketForWriteCheck(writeCheckTarget, getUuid());
e->deleteSocketForWriteCheck(writeCheckTarget, this);
checkSocketIsWritable = false;
writeCheckTarget = SocketHandle();
}
@ -126,12 +126,12 @@ void PeerAbstractCommand::setWriteCheckSocket(const SocketHandle& socket) {
} else {
if(checkSocketIsWritable) {
if(writeCheckTarget != socket) {
e->deleteSocketForWriteCheck(writeCheckTarget, getUuid());
e->addSocketForWriteCheck(socket, getUuid());
e->deleteSocketForWriteCheck(writeCheckTarget, this);
e->addSocketForWriteCheck(socket, this);
writeCheckTarget = socket;
}
} else {
e->addSocketForWriteCheck(socket, getUuid());
e->addSocketForWriteCheck(socket, this);
checkSocketIsWritable = true;
writeCheckTarget = socket;
}

View File

@ -45,6 +45,7 @@ void FeatureConfigTest::testGetConfigurationSummary() {
+"ftp: yes\n"
+"bittorrent: yes\n"
+"metalink: yes\n"
+"message digest: yes\n",
+"message digest: yes\n"
+"async dns: yes\n",
FeatureConfig::getInstance()->getConfigurationSummary());
}