mirror of https://github.com/aria2/aria2
2010-04-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use clock_gettime(CLOCK_MONOTONIC, ...) if it is available and usable to prevent from aria2 from being affected by system time change.pull/1/head
parent
bf0cf1f5d9
commit
0529e78187
|
@ -1,3 +1,9 @@
|
||||||
|
2010-04-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Use clock_gettime(CLOCK_MONOTONIC, ...) if it is available and
|
||||||
|
usable to prevent from aria2 from being affected by system time
|
||||||
|
change.
|
||||||
|
|
||||||
2010-04-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-04-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added aria2.pause and aria2.unpause XML-RPC method. aria2.pause
|
Added aria2.pause and aria2.unpause XML-RPC method. aria2.pause
|
||||||
|
|
|
@ -81,6 +81,9 @@
|
||||||
the CoreFoundation framework. */
|
the CoreFoundation framework. */
|
||||||
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
|
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `clock_gettime' function. */
|
||||||
|
#undef HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
/* Define to 1 if you have the `daemon' function. */
|
/* Define to 1 if you have the `daemon' function. */
|
||||||
#undef HAVE_DAEMON
|
#undef HAVE_DAEMON
|
||||||
|
|
||||||
|
@ -418,6 +421,9 @@
|
||||||
/* Define to 1 if you have the `strtoull' function. */
|
/* Define to 1 if you have the `strtoull' function. */
|
||||||
#undef HAVE_STRTOULL
|
#undef HAVE_STRTOULL
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `struct timespec'. */
|
||||||
|
#undef HAVE_STRUCT_TIMESPEC
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||||
#undef HAVE_SYS_IOCTL_H
|
#undef HAVE_SYS_IOCTL_H
|
||||||
|
|
||||||
|
|
|
@ -7431,6 +7431,63 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
|
||||||
|
$as_echo_n "checking for library containing clock_gettime... " >&6; }
|
||||||
|
if test "${ac_cv_search_clock_gettime+set}" = set; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
ac_func_search_save_LIBS=$LIBS
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
/* Override any GCC internal prototype to avoid an error.
|
||||||
|
Use char because int might match the return type of a GCC
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
#endif
|
||||||
|
char clock_gettime ();
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
return clock_gettime ();
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
for ac_lib in '' rt; do
|
||||||
|
if test -z "$ac_lib"; then
|
||||||
|
ac_res="none required"
|
||||||
|
else
|
||||||
|
ac_res=-l$ac_lib
|
||||||
|
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
|
||||||
|
fi
|
||||||
|
if ac_fn_cxx_try_link "$LINENO"; then :
|
||||||
|
ac_cv_search_clock_gettime=$ac_res
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext \
|
||||||
|
conftest$ac_exeext
|
||||||
|
if test "${ac_cv_search_clock_gettime+set}" = set; then :
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if test "${ac_cv_search_clock_gettime+set}" = set; then :
|
||||||
|
|
||||||
|
else
|
||||||
|
ac_cv_search_clock_gettime=no
|
||||||
|
fi
|
||||||
|
rm conftest.$ac_ext
|
||||||
|
LIBS=$ac_func_search_save_LIBS
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5
|
||||||
|
$as_echo "$ac_cv_search_clock_gettime" >&6; }
|
||||||
|
ac_res=$ac_cv_search_clock_gettime
|
||||||
|
if test "$ac_res" != no; then :
|
||||||
|
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
|
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
|
||||||
# for constant arguments. Useless!
|
# for constant arguments. Useless!
|
||||||
|
@ -8295,6 +8352,15 @@ cat >>confdefs.h <<_ACEOF
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
ac_fn_cxx_check_type "$LINENO" "struct timespec" "ac_cv_type_struct_timespec" "$ac_includes_default"
|
||||||
|
if test "x$ac_cv_type_struct_timespec" = x""yes; then :
|
||||||
|
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_STRUCT_TIMESPEC 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
|
||||||
|
@ -14496,6 +14562,7 @@ for ac_func in __argz_count \
|
||||||
__argz_next \
|
__argz_next \
|
||||||
__argz_stringify \
|
__argz_stringify \
|
||||||
atexit \
|
atexit \
|
||||||
|
clock_gettime \
|
||||||
ftruncate \
|
ftruncate \
|
||||||
getcwd \
|
getcwd \
|
||||||
gethostbyaddr \
|
gethostbyaddr \
|
||||||
|
|
|
@ -208,6 +208,8 @@ AM_CONDITIONAL([HAVE_LIBZ], [test "x$have_libz" = "xyes"])
|
||||||
# Set conditional for sqlite3
|
# Set conditional for sqlite3
|
||||||
AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
|
AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
|
||||||
|
|
||||||
|
AC_SEARCH_LIBS([clock_gettime], [rt])
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
|
@ -268,7 +270,7 @@ AC_TYPE_UINT64_T
|
||||||
AC_TYPE_UINT8_T
|
AC_TYPE_UINT8_T
|
||||||
AC_TYPE_PID_T
|
AC_TYPE_PID_T
|
||||||
AC_C_VOLATILE
|
AC_C_VOLATILE
|
||||||
AC_CHECK_TYPES([ptrdiff_t])
|
AC_CHECK_TYPES([ptrdiff_t, struct timespec])
|
||||||
AC_C_BIGENDIAN
|
AC_C_BIGENDIAN
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
|
|
||||||
|
@ -291,6 +293,7 @@ AC_CHECK_FUNCS([__argz_count \
|
||||||
__argz_next \
|
__argz_next \
|
||||||
__argz_stringify \
|
__argz_stringify \
|
||||||
atexit \
|
atexit \
|
||||||
|
clock_gettime \
|
||||||
ftruncate \
|
ftruncate \
|
||||||
getcwd \
|
getcwd \
|
||||||
gethostbyaddr \
|
gethostbyaddr \
|
||||||
|
|
|
@ -75,7 +75,7 @@ AbstractCommand::AbstractCommand(cuid_t cuid,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
const SocketHandle& s):
|
const SocketHandle& s):
|
||||||
Command(cuid), _requestGroup(requestGroup),
|
Command(cuid), checkPoint(global::wallclock), _requestGroup(requestGroup),
|
||||||
req(req), _fileEntry(fileEntry), e(e), socket(s),
|
req(req), _fileEntry(fileEntry), e(e), socket(s),
|
||||||
checkSocketIsReadable(false), checkSocketIsWritable(false),
|
checkSocketIsReadable(false), checkSocketIsWritable(false),
|
||||||
nameResolverCheck(false)
|
nameResolverCheck(false)
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class AsyncNameResolver;
|
||||||
|
|
||||||
class AbstractCommand : public Command {
|
class AbstractCommand : public Command {
|
||||||
private:
|
private:
|
||||||
Time checkPoint;
|
Timer checkPoint;
|
||||||
time_t timeout;
|
time_t timeout;
|
||||||
protected:
|
protected:
|
||||||
RequestGroup* _requestGroup;
|
RequestGroup* _requestGroup;
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ private:
|
||||||
|
|
||||||
time_t interval; // UNIT: sec
|
time_t interval; // UNIT: sec
|
||||||
DownloadEngine* e;
|
DownloadEngine* e;
|
||||||
Time checkPoint;
|
Timer checkPoint;
|
||||||
unsigned int _numNewConnection; // the number of the connection to establish.
|
unsigned int _numNewConnection; // the number of the connection to establish.
|
||||||
public:
|
public:
|
||||||
ActivePeerConnectionCommand(cuid_t cuid,
|
ActivePeerConnectionCommand(cuid_t cuid,
|
||||||
|
|
|
@ -51,7 +51,6 @@
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "wallclock.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -330,7 +329,7 @@ std::string AdaptiveURISelector::getFirstToTestUri
|
||||||
power = (int)pow(2.0, (float)counter);
|
power = (int)pow(2.0, (float)counter);
|
||||||
/* We test the mirror another time if it has not been
|
/* We test the mirror another time if it has not been
|
||||||
* tested since 2^counter days */
|
* tested since 2^counter days */
|
||||||
if(ss->getLastUpdated().difference(global::wallclock) > power*24*60*60) {
|
if(ss->getLastUpdated().difference() > power*24*60*60) {
|
||||||
return *i;
|
return *i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "a2time.h"
|
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
|
||||||
|
@ -216,7 +215,7 @@ BtLeecherStateChoke::executeChoke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Time& BtLeecherStateChoke::getLastRound() const
|
const Timer& BtLeecherStateChoke::getLastRound() const
|
||||||
{
|
{
|
||||||
return _lastRound;
|
return _lastRound;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class BtLeecherStateChoke {
|
||||||
private:
|
private:
|
||||||
int _round;
|
int _round;
|
||||||
|
|
||||||
Time _lastRound;
|
Timer _lastRound;
|
||||||
|
|
||||||
Logger* _logger;
|
Logger* _logger;
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
|
|
||||||
void executeChoke(const std::vector<SharedHandle<Peer> >& peerSet);
|
void executeChoke(const std::vector<SharedHandle<Peer> >& peerSet);
|
||||||
|
|
||||||
const Time& getLastRound() const;
|
const Timer& getLastRound() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -69,7 +69,7 @@ BtSeederStateChoke::PeerEntry::operator<(const PeerEntry& rhs) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(this->_recentUnchoking &&
|
if(this->_recentUnchoking &&
|
||||||
this->_lastAmUnchoking.isNewer(rhs._lastAmUnchoking)) {
|
(this->_lastAmUnchoking > rhs._lastAmUnchoking)) {
|
||||||
return true;
|
return true;
|
||||||
} else if(rhs._recentUnchoking) {
|
} else if(rhs._recentUnchoking) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class BtSeederStateChoke {
|
||||||
private:
|
private:
|
||||||
int _round;
|
int _round;
|
||||||
|
|
||||||
Time _lastRound;
|
Timer _lastRound;
|
||||||
|
|
||||||
Logger* _logger;
|
Logger* _logger;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ private:
|
||||||
private:
|
private:
|
||||||
SharedHandle<Peer> _peer;
|
SharedHandle<Peer> _peer;
|
||||||
size_t _outstandingUpload;
|
size_t _outstandingUpload;
|
||||||
Time _lastAmUnchoking;
|
Timer _lastAmUnchoking;
|
||||||
bool _recentUnchoking;
|
bool _recentUnchoking;
|
||||||
unsigned int _uploadSpeed;
|
unsigned int _uploadSpeed;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public:
|
||||||
|
|
||||||
void executeChoke(const std::vector<SharedHandle<Peer> >& peerSet);
|
void executeChoke(const std::vector<SharedHandle<Peer> >& peerSet);
|
||||||
|
|
||||||
const Time& getLastRound() const { return _lastRound; }
|
const Timer& getLastRound() const { return _lastRound; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -52,7 +52,7 @@ private:
|
||||||
|
|
||||||
time_t _timeout;
|
time_t _timeout;
|
||||||
|
|
||||||
Time _checkPoint;
|
Timer _checkPoint;
|
||||||
|
|
||||||
SharedHandle<BtRuntime> _btRuntime;
|
SharedHandle<BtRuntime> _btRuntime;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
#include "RealtimeCommand.h"
|
#include "RealtimeCommand.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ class CheckIntegrityEntry;
|
||||||
class CheckIntegrityCommand : public RealtimeCommand {
|
class CheckIntegrityCommand : public RealtimeCommand {
|
||||||
private:
|
private:
|
||||||
SharedHandle<CheckIntegrityEntry> _entry;
|
SharedHandle<CheckIntegrityEntry> _entry;
|
||||||
Time _timer;
|
|
||||||
public:
|
public:
|
||||||
CheckIntegrityCommand(cuid_t cuid,
|
CheckIntegrityCommand(cuid_t cuid,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define _D_CONSOLE_STAT_CALC_H_
|
#define _D_CONSOLE_STAT_CALC_H_
|
||||||
|
|
||||||
#include "StatCalc.h"
|
#include "StatCalc.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -72,9 +72,9 @@ protected:
|
||||||
class ConsoleStatCalc:public StatCalc
|
class ConsoleStatCalc:public StatCalc
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Time _cp;
|
Timer _cp;
|
||||||
|
|
||||||
Time _lastSummaryNotified;
|
Timer _lastSummaryNotified;
|
||||||
|
|
||||||
time_t _summaryInterval;
|
time_t _summaryInterval;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "DHTConstants.h"
|
#include "DHTConstants.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ private:
|
||||||
// This is sorted by last time seen.
|
// This is sorted by last time seen.
|
||||||
std::deque<SharedHandle<DHTNode> > _cachedNodes;
|
std::deque<SharedHandle<DHTNode> > _cachedNodes;
|
||||||
|
|
||||||
Time _lastUpdated;
|
Timer _lastUpdated;
|
||||||
|
|
||||||
Logger* _logger;
|
Logger* _logger;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ private:
|
||||||
|
|
||||||
size_t _numRetry;
|
size_t _numRetry;
|
||||||
|
|
||||||
Time _lastGetPeerTime;
|
Timer _lastGetPeerTime;
|
||||||
public:
|
public:
|
||||||
DHTGetPeersCommand(cuid_t cuid, RequestGroup* requestGroup,
|
DHTGetPeersCommand(cuid_t cuid, RequestGroup* requestGroup,
|
||||||
DownloadEngine* e);
|
DownloadEngine* e);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "DHTConstants.h"
|
#include "DHTConstants.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -57,7 +57,7 @@ private:
|
||||||
|
|
||||||
SharedHandle<DHTMessageCallback> _callback;
|
SharedHandle<DHTMessageCallback> _callback;
|
||||||
|
|
||||||
Time _dispatchedTime;
|
Timer _dispatchedTime;
|
||||||
|
|
||||||
time_t _timeout;
|
time_t _timeout;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "DHTConstants.h"
|
#include "DHTConstants.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -56,7 +56,7 @@ private:
|
||||||
|
|
||||||
unsigned int _condition;
|
unsigned int _condition;
|
||||||
|
|
||||||
Time _lastContact;
|
Timer _lastContact;
|
||||||
public:
|
public:
|
||||||
DHTNode();
|
DHTNode();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "DHTConstants.h"
|
#include "DHTConstants.h"
|
||||||
#include "PeerAddrEntry.h"
|
#include "PeerAddrEntry.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ private:
|
||||||
|
|
||||||
std::vector<PeerAddrEntry> _peerAddrEntries;
|
std::vector<PeerAddrEntry> _peerAddrEntries;
|
||||||
|
|
||||||
Time _lastUpdated;
|
Timer _lastUpdated;
|
||||||
public:
|
public:
|
||||||
DHTPeerAnnounceEntry(const unsigned char* infoHash);
|
DHTPeerAnnounceEntry(const unsigned char* infoHash);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
||||||
const Time& getLastUpdated() const
|
const Timer& getLastUpdated() const
|
||||||
{
|
{
|
||||||
return _lastUpdated;
|
return _lastUpdated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include "a2netcompat.h"
|
#include "a2netcompat.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "TimeA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
}
|
}
|
||||||
if(!desnodes.empty() &&
|
if(!desnodes.empty() &&
|
||||||
deserializer.getSerializedTime().
|
deserializer.getSerializedTime().
|
||||||
difference(global::wallclock) >= DHT_BUCKET_REFRESH_INTERVAL) {
|
difference() >= DHT_BUCKET_REFRESH_INTERVAL) {
|
||||||
SharedHandle<DHTBucketRefreshTask> task
|
SharedHandle<DHTBucketRefreshTask> task
|
||||||
(dynamic_pointer_cast<DHTBucketRefreshTask>(taskFactory->createBucketRefreshTask()));
|
(dynamic_pointer_cast<DHTBucketRefreshTask>(taskFactory->createBucketRefreshTask()));
|
||||||
task->setForceRefresh(true);
|
task->setForceRefresh(true);
|
||||||
|
|
|
@ -61,6 +61,7 @@ DefaultBtAnnounce::DefaultBtAnnounce
|
||||||
const Option* option):
|
const Option* option):
|
||||||
_downloadContext(downloadContext),
|
_downloadContext(downloadContext),
|
||||||
trackers(0),
|
trackers(0),
|
||||||
|
prevAnnounceTimer(0),
|
||||||
interval(DEFAULT_ANNOUNCE_INTERVAL),
|
interval(DEFAULT_ANNOUNCE_INTERVAL),
|
||||||
minInterval(DEFAULT_ANNOUNCE_INTERVAL),
|
minInterval(DEFAULT_ANNOUNCE_INTERVAL),
|
||||||
_userDefinedInterval(0),
|
_userDefinedInterval(0),
|
||||||
|
@ -70,9 +71,7 @@ DefaultBtAnnounce::DefaultBtAnnounce
|
||||||
option(option),
|
option(option),
|
||||||
logger(LogFactory::getInstance()),
|
logger(LogFactory::getInstance()),
|
||||||
_randomizer(SimpleRandomizer::getInstance())
|
_randomizer(SimpleRandomizer::getInstance())
|
||||||
{
|
{}
|
||||||
prevAnnounceTime.setTimeInSec(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
DefaultBtAnnounce::~DefaultBtAnnounce() {
|
DefaultBtAnnounce::~DefaultBtAnnounce() {
|
||||||
}
|
}
|
||||||
|
@ -80,7 +79,7 @@ DefaultBtAnnounce::~DefaultBtAnnounce() {
|
||||||
bool DefaultBtAnnounce::isDefaultAnnounceReady() {
|
bool DefaultBtAnnounce::isDefaultAnnounceReady() {
|
||||||
return
|
return
|
||||||
(trackers == 0 &&
|
(trackers == 0 &&
|
||||||
prevAnnounceTime.
|
prevAnnounceTimer.
|
||||||
difference(global::wallclock) >= (_userDefinedInterval==0?
|
difference(global::wallclock) >= (_userDefinedInterval==0?
|
||||||
minInterval:_userDefinedInterval) &&
|
minInterval:_userDefinedInterval) &&
|
||||||
!announceList.allTiersFailed());
|
!announceList.allTiersFailed());
|
||||||
|
@ -207,7 +206,7 @@ bool DefaultBtAnnounce::isAllAnnounceFailed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtAnnounce::resetAnnounce() {
|
void DefaultBtAnnounce::resetAnnounce() {
|
||||||
prevAnnounceTime = global::wallclock;
|
prevAnnounceTimer = global::wallclock;
|
||||||
announceList.resetTier();
|
announceList.resetTier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define _D_DEFAULT_BT_ANNOUNCE_H_
|
#define _D_DEFAULT_BT_ANNOUNCE_H_
|
||||||
|
|
||||||
#include "BtAnnounce.h"
|
#include "BtAnnounce.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "AnnounceList.h"
|
#include "AnnounceList.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -53,7 +53,7 @@ class DefaultBtAnnounce : public BtAnnounce {
|
||||||
private:
|
private:
|
||||||
SharedHandle<DownloadContext> _downloadContext;
|
SharedHandle<DownloadContext> _downloadContext;
|
||||||
unsigned int trackers;
|
unsigned int trackers;
|
||||||
Time prevAnnounceTime;
|
Timer prevAnnounceTimer;
|
||||||
time_t interval;
|
time_t interval;
|
||||||
time_t minInterval;
|
time_t minInterval;
|
||||||
time_t _userDefinedInterval;
|
time_t _userDefinedInterval;
|
||||||
|
|
|
@ -163,11 +163,11 @@ BtMessageHandle DefaultBtInteractive::receiveAndSendHandshake() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtInteractive::doPostHandshakeProcessing() {
|
void DefaultBtInteractive::doPostHandshakeProcessing() {
|
||||||
// Set time 0 to haveCheckPoint to cache http/ftp download piece completion
|
// Set time 0 to haveTimer to cache http/ftp download piece completion
|
||||||
haveCheckPoint.setTimeInSec(0);
|
haveTimer.reset(0);
|
||||||
keepAliveCheckPoint = global::wallclock;
|
keepAliveTimer = global::wallclock;
|
||||||
floodingCheckPoint = global::wallclock;
|
floodingTimer = global::wallclock;
|
||||||
_pexCheckPoint.setTimeInSec(0);
|
_pexTimer.reset(0);
|
||||||
if(peer->isExtendedMessagingEnabled()) {
|
if(peer->isExtendedMessagingEnabled()) {
|
||||||
addHandshakeExtendedMessageToQueue();
|
addHandshakeExtendedMessageToQueue();
|
||||||
}
|
}
|
||||||
|
@ -249,8 +249,8 @@ void DefaultBtInteractive::decideChoking() {
|
||||||
|
|
||||||
void DefaultBtInteractive::checkHave() {
|
void DefaultBtInteractive::checkHave() {
|
||||||
std::vector<size_t> indexes;
|
std::vector<size_t> indexes;
|
||||||
_pieceStorage->getAdvertisedPieceIndexes(indexes, cuid, haveCheckPoint);
|
_pieceStorage->getAdvertisedPieceIndexes(indexes, cuid, haveTimer);
|
||||||
haveCheckPoint = global::wallclock;
|
haveTimer = global::wallclock;
|
||||||
if(indexes.size() >= 20) {
|
if(indexes.size() >= 20) {
|
||||||
if(peer->isFastExtensionEnabled() && _pieceStorage->allDownloadFinished()) {
|
if(peer->isFastExtensionEnabled() && _pieceStorage->allDownloadFinished()) {
|
||||||
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
||||||
|
@ -266,10 +266,10 @@ void DefaultBtInteractive::checkHave() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtInteractive::sendKeepAlive() {
|
void DefaultBtInteractive::sendKeepAlive() {
|
||||||
if(keepAliveCheckPoint.difference(global::wallclock) >= keepAliveInterval) {
|
if(keepAliveTimer.difference(global::wallclock) >= keepAliveInterval) {
|
||||||
dispatcher->addMessageToQueue(messageFactory->createKeepAliveMessage());
|
dispatcher->addMessageToQueue(messageFactory->createKeepAliveMessage());
|
||||||
dispatcher->sendMessages();
|
dispatcher->sendMessages();
|
||||||
keepAliveCheckPoint = global::wallclock;
|
keepAliveTimer = global::wallclock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ size_t DefaultBtInteractive::receiveMessages() {
|
||||||
_peerStorage->updateTransferStatFor(peer);
|
_peerStorage->updateTransferStatFor(peer);
|
||||||
// pass through
|
// pass through
|
||||||
case BtRequestMessage::ID:
|
case BtRequestMessage::ID:
|
||||||
inactiveCheckPoint = global::wallclock;
|
inactiveTimer = global::wallclock;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ void DefaultBtInteractive::sendPendingMessage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtInteractive::detectMessageFlooding() {
|
void DefaultBtInteractive::detectMessageFlooding() {
|
||||||
if(floodingCheckPoint.
|
if(floodingTimer.
|
||||||
difference(global::wallclock) >= FLOODING_CHECK_INTERVAL) {
|
difference(global::wallclock) >= FLOODING_CHECK_INTERVAL) {
|
||||||
if(floodingStat.getChokeUnchokeCount() >= 2 ||
|
if(floodingStat.getChokeUnchokeCount() >= 2 ||
|
||||||
floodingStat.getKeepAliveCount() >= 2) {
|
floodingStat.getKeepAliveCount() >= 2) {
|
||||||
|
@ -430,13 +430,13 @@ void DefaultBtInteractive::detectMessageFlooding() {
|
||||||
} else {
|
} else {
|
||||||
floodingStat.reset();
|
floodingStat.reset();
|
||||||
}
|
}
|
||||||
floodingCheckPoint = global::wallclock;
|
floodingTimer = global::wallclock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtInteractive::checkActiveInteraction()
|
void DefaultBtInteractive::checkActiveInteraction()
|
||||||
{
|
{
|
||||||
time_t inactiveTime = inactiveCheckPoint.difference(global::wallclock);
|
time_t inactiveTime = inactiveTimer.difference(global::wallclock);
|
||||||
// To allow aria2 to accept mutially interested peer, disconnect unintersted
|
// To allow aria2 to accept mutially interested peer, disconnect unintersted
|
||||||
// peer.
|
// peer.
|
||||||
{
|
{
|
||||||
|
@ -463,7 +463,7 @@ void DefaultBtInteractive::checkActiveInteraction()
|
||||||
|
|
||||||
void DefaultBtInteractive::addPeerExchangeMessage()
|
void DefaultBtInteractive::addPeerExchangeMessage()
|
||||||
{
|
{
|
||||||
if(_pexCheckPoint.
|
if(_pexTimer.
|
||||||
difference(global::wallclock) >= UTPexExtensionMessage::DEFAULT_INTERVAL) {
|
difference(global::wallclock) >= UTPexExtensionMessage::DEFAULT_INTERVAL) {
|
||||||
UTPexExtensionMessageHandle m
|
UTPexExtensionMessageHandle m
|
||||||
(new UTPexExtensionMessage(peer->getExtensionMessageID("ut_pex")));
|
(new UTPexExtensionMessage(peer->getExtensionMessageID("ut_pex")));
|
||||||
|
@ -489,7 +489,7 @@ void DefaultBtInteractive::addPeerExchangeMessage()
|
||||||
}
|
}
|
||||||
BtMessageHandle msg = messageFactory->createBtExtendedMessage(m);
|
BtMessageHandle msg = messageFactory->createBtExtendedMessage(m);
|
||||||
dispatcher->addMessageToQueue(msg);
|
dispatcher->addMessageToQueue(msg);
|
||||||
_pexCheckPoint = global::wallclock;
|
_pexTimer = global::wallclock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,8 +510,8 @@ void DefaultBtInteractive::doInteractionProcessing() {
|
||||||
_utMetadataRequestFactory->create(requests, num, _pieceStorage);
|
_utMetadataRequestFactory->create(requests, num, _pieceStorage);
|
||||||
dispatcher->addMessageToQueue(requests);
|
dispatcher->addMessageToQueue(requests);
|
||||||
}
|
}
|
||||||
if(_perSecCheckPoint.difference(global::wallclock) >= 1) {
|
if(_perSecTimer.difference(global::wallclock) >= 1) {
|
||||||
_perSecCheckPoint = global::wallclock;
|
_perSecTimer = global::wallclock;
|
||||||
// Drop timeout request after queuing message to give a chance
|
// Drop timeout request after queuing message to give a chance
|
||||||
// to other connection to request piece.
|
// to other connection to request piece.
|
||||||
std::vector<size_t> indexes =
|
std::vector<size_t> indexes =
|
||||||
|
@ -533,8 +533,8 @@ void DefaultBtInteractive::doInteractionProcessing() {
|
||||||
|
|
||||||
detectMessageFlooding();
|
detectMessageFlooding();
|
||||||
|
|
||||||
if(_perSecCheckPoint.difference(global::wallclock) >= 1) {
|
if(_perSecTimer.difference(global::wallclock) >= 1) {
|
||||||
_perSecCheckPoint = global::wallclock;
|
_perSecTimer = global::wallclock;
|
||||||
dispatcher->checkRequestSlotAndDoNecessaryThing();
|
dispatcher->checkRequestSlotAndDoNecessaryThing();
|
||||||
}
|
}
|
||||||
checkHave();
|
checkHave();
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -126,13 +126,13 @@ private:
|
||||||
|
|
||||||
Logger* logger;
|
Logger* logger;
|
||||||
size_t allowedFastSetSize;
|
size_t allowedFastSetSize;
|
||||||
Time haveCheckPoint;
|
Timer haveTimer;
|
||||||
Time keepAliveCheckPoint;
|
Timer keepAliveTimer;
|
||||||
Time floodingCheckPoint;
|
Timer floodingTimer;
|
||||||
FloodingStat floodingStat;
|
FloodingStat floodingStat;
|
||||||
Time inactiveCheckPoint;
|
Timer inactiveTimer;
|
||||||
Time _pexCheckPoint;
|
Timer _pexTimer;
|
||||||
Time _perSecCheckPoint;
|
Timer _perSecTimer;
|
||||||
time_t keepAliveInterval;
|
time_t keepAliveInterval;
|
||||||
bool _utPexEnabled;
|
bool _utPexEnabled;
|
||||||
bool _dhtEnabled;
|
bool _dhtEnabled;
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "a2time.h"
|
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
#include "BtRuntime.h"
|
#include "BtRuntime.h"
|
||||||
#include "BtSeederStateChoke.h"
|
#include "BtSeederStateChoke.h"
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ private:
|
||||||
|
|
||||||
std::map<std::string, TransferStat> _peerTransferStatMap;
|
std::map<std::string, TransferStat> _peerTransferStatMap;
|
||||||
|
|
||||||
Time _lastTransferStatMapUpdated;
|
Timer _lastTransferStatMapUpdated;
|
||||||
|
|
||||||
TransferStat _cachedTransferStat;
|
TransferStat _cachedTransferStat;
|
||||||
|
|
||||||
|
|
|
@ -537,14 +537,14 @@ size_t DefaultPieceStorage::getPieceLength(size_t index)
|
||||||
|
|
||||||
void DefaultPieceStorage::advertisePiece(cuid_t cuid, size_t index)
|
void DefaultPieceStorage::advertisePiece(cuid_t cuid, size_t index)
|
||||||
{
|
{
|
||||||
HaveEntry entry(cuid, index);
|
HaveEntry entry(cuid, index, global::wallclock);
|
||||||
haves.push_front(entry);
|
haves.push_front(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DefaultPieceStorage::getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
DefaultPieceStorage::getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
||||||
cuid_t myCuid,
|
cuid_t myCuid,
|
||||||
const Time& lastCheckTime)
|
const Timer& lastCheckTime)
|
||||||
{
|
{
|
||||||
for(std::deque<HaveEntry>::const_iterator itr = haves.begin(),
|
for(std::deque<HaveEntry>::const_iterator itr = haves.begin(),
|
||||||
eoi = haves.end(); itr != eoi; ++itr) {
|
eoi = haves.end(); itr != eoi; ++itr) {
|
||||||
|
@ -552,7 +552,7 @@ DefaultPieceStorage::getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
||||||
if(have.getCuid() == myCuid) {
|
if(have.getCuid() == myCuid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(lastCheckTime.isNewer(have.getRegisteredTime())) {
|
if(lastCheckTime > have.getRegisteredTime()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
indexes.push_back(have.getIndex());
|
indexes.push_back(have.getIndex());
|
||||||
|
|
|
@ -56,17 +56,18 @@ class HaveEntry {
|
||||||
private:
|
private:
|
||||||
cuid_t cuid;
|
cuid_t cuid;
|
||||||
size_t index;
|
size_t index;
|
||||||
Time registeredTime;
|
Timer registeredTime;
|
||||||
public:
|
public:
|
||||||
HaveEntry(cuid_t cuid, size_t index):
|
HaveEntry(cuid_t cuid, size_t index, const Timer& registeredTime):
|
||||||
cuid(cuid),
|
cuid(cuid),
|
||||||
index(index) {}
|
index(index),
|
||||||
|
registeredTime(registeredTime) {}
|
||||||
|
|
||||||
cuid_t getCuid() const { return cuid; }
|
cuid_t getCuid() const { return cuid; }
|
||||||
|
|
||||||
size_t getIndex() const { return index; }
|
size_t getIndex() const { return index; }
|
||||||
|
|
||||||
const Time& getRegisteredTime() const { return registeredTime; }
|
const Timer& getRegisteredTime() const { return registeredTime; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultPieceStorage : public PieceStorage {
|
class DefaultPieceStorage : public PieceStorage {
|
||||||
|
@ -195,7 +196,7 @@ public:
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
||||||
cuid_t myCuid, const Time& lastCheckTime);
|
cuid_t myCuid, const Timer& lastCheckTime);
|
||||||
|
|
||||||
virtual void removeAdvertisedPiece(time_t elapsed);
|
virtual void removeAdvertisedPiece(time_t elapsed);
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ DownloadContext::DownloadContext(size_t pieceLength,
|
||||||
void DownloadContext::resetDownloadStartTime()
|
void DownloadContext::resetDownloadStartTime()
|
||||||
{
|
{
|
||||||
_downloadStartTime = global::wallclock;
|
_downloadStartTime = global::wallclock;
|
||||||
_downloadStopTime.setTimeInSec(0);
|
_downloadStopTime.reset(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadContext::resetDownloadStopTime()
|
void DownloadContext::resetDownloadStopTime()
|
||||||
|
@ -79,9 +79,9 @@ void DownloadContext::resetDownloadStopTime()
|
||||||
|
|
||||||
int64_t DownloadContext::calculateSessionTime() const
|
int64_t DownloadContext::calculateSessionTime() const
|
||||||
{
|
{
|
||||||
if(_downloadStopTime.isNewer(_downloadStartTime)) {
|
if(_downloadStopTime > _downloadStartTime) {
|
||||||
return
|
return
|
||||||
_downloadStopTime.getTimeInMillis()-_downloadStartTime.getTimeInMillis();
|
_downloadStartTime.differenceInMillis(_downloadStopTime);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "A2STR.h"
|
#include "A2STR.h"
|
||||||
#include "BDE.h"
|
#include "BDE.h"
|
||||||
#include "IntSequence.h"
|
#include "IntSequence.h"
|
||||||
|
@ -78,9 +78,9 @@ private:
|
||||||
|
|
||||||
BDE _attrs;
|
BDE _attrs;
|
||||||
|
|
||||||
Time _downloadStartTime;
|
Timer _downloadStartTime;
|
||||||
|
|
||||||
Time _downloadStopTime;
|
Timer _downloadStopTime;
|
||||||
|
|
||||||
SharedHandle<Signature> _signature;
|
SharedHandle<Signature> _signature;
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public:
|
||||||
|
|
||||||
void resetDownloadStopTime();
|
void resetDownloadStopTime();
|
||||||
|
|
||||||
const Time& getDownloadStopTime() const
|
const Timer& getDownloadStopTime() const
|
||||||
{
|
{
|
||||||
return _downloadStopTime;
|
return _downloadStopTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,6 @@
|
||||||
#include "StatCalc.h"
|
#include "StatCalc.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "TimeA2.h"
|
|
||||||
#include "a2time.h"
|
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
|
@ -80,7 +78,7 @@ namespace global {
|
||||||
|
|
||||||
// Global clock, this clock is reseted before executeCommand() call to
|
// Global clock, this clock is reseted before executeCommand() call to
|
||||||
// reduce the call gettimeofday() system call.
|
// reduce the call gettimeofday() system call.
|
||||||
Time wallclock;
|
Timer wallclock;
|
||||||
|
|
||||||
// 0 ... running
|
// 0 ... running
|
||||||
// 1 ... stop signal detected
|
// 1 ... stop signal detected
|
||||||
|
@ -141,8 +139,8 @@ static void executeCommand(std::deque<Command*>& commands,
|
||||||
|
|
||||||
void DownloadEngine::run()
|
void DownloadEngine::run()
|
||||||
{
|
{
|
||||||
Time cp;
|
Timer cp;
|
||||||
cp.setTimeInSec(0);
|
cp.reset(0);
|
||||||
while(!commands.empty() || !_routineCommands.empty()) {
|
while(!commands.empty() || !_routineCommands.empty()) {
|
||||||
global::wallclock.reset();
|
global::wallclock.reset();
|
||||||
if(cp.difference(global::wallclock) >= _refreshInterval) {
|
if(cp.difference(global::wallclock) >= _refreshInterval) {
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "a2netcompat.h"
|
#include "a2netcompat.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "a2io.h"
|
#include "a2io.h"
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
# include "AsyncNameResolver.h"
|
# include "AsyncNameResolver.h"
|
||||||
|
@ -92,7 +92,7 @@ private:
|
||||||
|
|
||||||
time_t _timeout;
|
time_t _timeout;
|
||||||
|
|
||||||
Time _registeredTime;
|
Timer _registeredTime;
|
||||||
public:
|
public:
|
||||||
SocketPoolEntry(const SharedHandle<SocketCore>& socket,
|
SocketPoolEntry(const SharedHandle<SocketCore>& socket,
|
||||||
const std::map<std::string, std::string>& option,
|
const std::map<std::string, std::string>& option,
|
||||||
|
@ -116,7 +116,7 @@ private:
|
||||||
// key = IP address:port, value = SocketPoolEntry
|
// key = IP address:port, value = SocketPoolEntry
|
||||||
std::multimap<std::string, SocketPoolEntry> _socketPool;
|
std::multimap<std::string, SocketPoolEntry> _socketPool;
|
||||||
|
|
||||||
Time _lastSocketPoolScan;
|
Timer _lastSocketPoolScan;
|
||||||
|
|
||||||
bool _noWait;
|
bool _noWait;
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get(), 1));
|
e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get()));
|
||||||
e->addRoutineCommand(new FileAllocationDispatcherCommand
|
e->addRoutineCommand(new FileAllocationDispatcherCommand
|
||||||
(e->newCUID(), e->_fileAllocationMan, e.get()));
|
(e->newCUID(), e->_fileAllocationMan, e.get()));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "a2time.h"
|
||||||
#include "a2netcompat.h"
|
#include "a2netcompat.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
|
#include "wallclock.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ bool FileAllocationCommand::executeInternal()
|
||||||
if(_fileAllocationEntry->finished()) {
|
if(_fileAllocationEntry->finished()) {
|
||||||
if(logger->debug()) {
|
if(logger->debug()) {
|
||||||
logger->debug(MSG_ALLOCATION_COMPLETED,
|
logger->debug(MSG_ALLOCATION_COMPLETED,
|
||||||
_timer.difference(),
|
_timer.difference(global::wallclock),
|
||||||
util::itos(_requestGroup->getTotalLength(), true).c_str());
|
util::itos(_requestGroup->getTotalLength(), true).c_str());
|
||||||
}
|
}
|
||||||
_e->_fileAllocationMan->dropPickedEntry();
|
_e->_fileAllocationMan->dropPickedEntry();
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "RealtimeCommand.h"
|
#include "RealtimeCommand.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class FileAllocationEntry;
|
||||||
class FileAllocationCommand : public RealtimeCommand {
|
class FileAllocationCommand : public RealtimeCommand {
|
||||||
private:
|
private:
|
||||||
SharedHandle<FileAllocationEntry> _fileAllocationEntry;
|
SharedHandle<FileAllocationEntry> _fileAllocationEntry;
|
||||||
Time _timer;
|
Timer _timer;
|
||||||
public:
|
public:
|
||||||
FileAllocationCommand(cuid_t cuid, RequestGroup* requestGroup,
|
FileAllocationCommand(cuid_t cuid, RequestGroup* requestGroup,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
|
|
|
@ -45,11 +45,9 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
FillRequestGroupCommand::FillRequestGroupCommand(cuid_t cuid,
|
FillRequestGroupCommand::FillRequestGroupCommand(cuid_t cuid,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e):
|
||||||
time_t interval):
|
|
||||||
Command(cuid),
|
Command(cuid),
|
||||||
_e(e),
|
_e(e)
|
||||||
_interval(interval)
|
|
||||||
{
|
{
|
||||||
setStatusRealtime();
|
setStatusRealtime();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "a2time.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -47,19 +47,12 @@ class DownloadEngine;
|
||||||
class FillRequestGroupCommand : public Command {
|
class FillRequestGroupCommand : public Command {
|
||||||
private:
|
private:
|
||||||
DownloadEngine* _e;
|
DownloadEngine* _e;
|
||||||
time_t _interval;
|
|
||||||
Time _checkPoint;
|
|
||||||
public:
|
public:
|
||||||
FillRequestGroupCommand(cuid_t cuid, DownloadEngine* e, time_t interval);
|
FillRequestGroupCommand(cuid_t cuid, DownloadEngine* e);
|
||||||
|
|
||||||
virtual ~FillRequestGroupCommand();
|
virtual ~FillRequestGroupCommand();
|
||||||
|
|
||||||
virtual bool execute();
|
virtual bool execute();
|
||||||
|
|
||||||
void setInterval(time_t interval)
|
|
||||||
{
|
|
||||||
_interval = interval;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -81,7 +81,7 @@ bool HttpServerBodyCommand::execute()
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(_socket->isReadable(0) || _httpServer->getContentLength() == 0) {
|
if(_socket->isReadable(0) || _httpServer->getContentLength() == 0) {
|
||||||
_timeout = global::wallclock;
|
_timeoutTimer = global::wallclock;
|
||||||
|
|
||||||
if(_httpServer->receiveBody()) {
|
if(_httpServer->receiveBody()) {
|
||||||
// Do something for requestpath and body
|
// Do something for requestpath and body
|
||||||
|
@ -108,7 +108,7 @@ bool HttpServerBodyCommand::execute()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(_timeout.difference(global::wallclock) >= 30) {
|
if(_timeoutTimer.difference(global::wallclock) >= 30) {
|
||||||
logger->info("HTTP request body timeout.");
|
logger->info("HTTP request body timeout.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ private:
|
||||||
DownloadEngine* _e;
|
DownloadEngine* _e;
|
||||||
SharedHandle<SocketCore> _socket;
|
SharedHandle<SocketCore> _socket;
|
||||||
SharedHandle<HttpServer> _httpServer;
|
SharedHandle<HttpServer> _httpServer;
|
||||||
Time _timeout;
|
Timer _timeoutTimer;
|
||||||
public:
|
public:
|
||||||
HttpServerBodyCommand(cuid_t cuid,
|
HttpServerBodyCommand(cuid_t cuid,
|
||||||
const SharedHandle<HttpServer>& httpServer,
|
const SharedHandle<HttpServer>& httpServer,
|
||||||
|
|
|
@ -93,7 +93,7 @@ bool HttpServerCommand::execute()
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(_socket->isReadable(0)) {
|
if(_socket->isReadable(0)) {
|
||||||
_timeout = global::wallclock;
|
_timeoutTimer = global::wallclock;
|
||||||
SharedHandle<HttpHeader> header;
|
SharedHandle<HttpHeader> header;
|
||||||
|
|
||||||
header = _httpServer->receiveRequest();
|
header = _httpServer->receiveRequest();
|
||||||
|
@ -128,7 +128,7 @@ bool HttpServerCommand::execute()
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(_timeout.difference(global::wallclock) >= 30) {
|
if(_timeoutTimer.difference(global::wallclock) >= 30) {
|
||||||
logger->info("HTTP request timeout.");
|
logger->info("HTTP request timeout.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ private:
|
||||||
DownloadEngine* _e;
|
DownloadEngine* _e;
|
||||||
SharedHandle<SocketCore> _socket;
|
SharedHandle<SocketCore> _socket;
|
||||||
SharedHandle<HttpServer> _httpServer;
|
SharedHandle<HttpServer> _httpServer;
|
||||||
Time _timeout;
|
Timer _timeoutTimer;
|
||||||
public:
|
public:
|
||||||
HttpServerCommand(cuid_t cuid, DownloadEngine* e,
|
HttpServerCommand(cuid_t cuid, DownloadEngine* e,
|
||||||
const SharedHandle<SocketCore>& socket);
|
const SharedHandle<SocketCore>& socket);
|
||||||
|
|
|
@ -93,7 +93,7 @@ bool HttpServerResponseCommand::execute()
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(_timeout.difference(global::wallclock) >= 10) {
|
if(_timeoutTimer.difference(global::wallclock) >= 10) {
|
||||||
if(logger->info()) {
|
if(logger->info()) {
|
||||||
logger->info("CUID#%s - HttpServer: Timeout while trasmitting"
|
logger->info("CUID#%s - HttpServer: Timeout while trasmitting"
|
||||||
" response.", util::itos(cuid).c_str());
|
" response.", util::itos(cuid).c_str());
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ private:
|
||||||
DownloadEngine* _e;
|
DownloadEngine* _e;
|
||||||
SharedHandle<SocketCore> _socket;
|
SharedHandle<SocketCore> _socket;
|
||||||
SharedHandle<HttpServer> _httpServer;
|
SharedHandle<HttpServer> _httpServer;
|
||||||
Time _timeout;
|
Timer _timeoutTimer;
|
||||||
public:
|
public:
|
||||||
HttpServerResponseCommand(cuid_t cuid,
|
HttpServerResponseCommand(cuid_t cuid,
|
||||||
const SharedHandle<HttpServer>& httpServer,
|
const SharedHandle<HttpServer>& httpServer,
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ private:
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
std::string _multicastAddress;
|
std::string _multicastAddress;
|
||||||
uint16_t _multicastPort;
|
uint16_t _multicastPort;
|
||||||
Time _timer;
|
Timer _timer;
|
||||||
time_t _interval;
|
time_t _interval;
|
||||||
std::string _request;
|
std::string _request;
|
||||||
Logger* _logger;
|
Logger* _logger;
|
||||||
|
|
|
@ -51,6 +51,7 @@ SRCS = Socket.h\
|
||||||
Base64.cc Base64.h\
|
Base64.cc Base64.h\
|
||||||
base32.cc base32.h\
|
base32.cc base32.h\
|
||||||
LogFactory.cc LogFactory.h\
|
LogFactory.cc LogFactory.h\
|
||||||
|
TimerA2.cc TimerA2.h\
|
||||||
TimeA2.cc TimeA2.h\
|
TimeA2.cc TimeA2.h\
|
||||||
SharedHandle.h\
|
SharedHandle.h\
|
||||||
HandleRegistry.h\
|
HandleRegistry.h\
|
||||||
|
|
|
@ -341,9 +341,9 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
||||||
DefaultDiskWriter.cc DefaultDiskWriter.h \
|
DefaultDiskWriter.cc DefaultDiskWriter.h \
|
||||||
DefaultDiskWriterFactory.cc DefaultDiskWriterFactory.h File.cc \
|
DefaultDiskWriterFactory.cc DefaultDiskWriterFactory.h File.cc \
|
||||||
File.h Option.cc Option.h Base64.cc Base64.h base32.cc \
|
File.h Option.cc Option.h Base64.cc Base64.h base32.cc \
|
||||||
base32.h LogFactory.cc LogFactory.h TimeA2.cc TimeA2.h \
|
base32.h LogFactory.cc LogFactory.h TimerA2.cc TimerA2.h \
|
||||||
SharedHandle.h HandleRegistry.h FeatureConfig.cc \
|
TimeA2.cc TimeA2.h SharedHandle.h HandleRegistry.h \
|
||||||
FeatureConfig.h DownloadEngineFactory.cc \
|
FeatureConfig.cc FeatureConfig.h DownloadEngineFactory.cc \
|
||||||
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
|
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
|
||||||
BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \
|
BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \
|
||||||
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
|
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
|
||||||
|
@ -800,11 +800,12 @@ am__objects_27 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
|
||||||
SimpleLogger.$(OBJEXT) AbstractDiskWriter.$(OBJEXT) \
|
SimpleLogger.$(OBJEXT) AbstractDiskWriter.$(OBJEXT) \
|
||||||
DefaultDiskWriter.$(OBJEXT) DefaultDiskWriterFactory.$(OBJEXT) \
|
DefaultDiskWriter.$(OBJEXT) DefaultDiskWriterFactory.$(OBJEXT) \
|
||||||
File.$(OBJEXT) Option.$(OBJEXT) Base64.$(OBJEXT) \
|
File.$(OBJEXT) Option.$(OBJEXT) Base64.$(OBJEXT) \
|
||||||
base32.$(OBJEXT) LogFactory.$(OBJEXT) TimeA2.$(OBJEXT) \
|
base32.$(OBJEXT) LogFactory.$(OBJEXT) TimerA2.$(OBJEXT) \
|
||||||
FeatureConfig.$(OBJEXT) DownloadEngineFactory.$(OBJEXT) \
|
TimeA2.$(OBJEXT) FeatureConfig.$(OBJEXT) \
|
||||||
SpeedCalc.$(OBJEXT) BitfieldMan.$(OBJEXT) \
|
DownloadEngineFactory.$(OBJEXT) SpeedCalc.$(OBJEXT) \
|
||||||
SimpleRandomizer.$(OBJEXT) HttpResponse.$(OBJEXT) \
|
BitfieldMan.$(OBJEXT) SimpleRandomizer.$(OBJEXT) \
|
||||||
HttpRequest.$(OBJEXT) AbstractProxyRequestCommand.$(OBJEXT) \
|
HttpResponse.$(OBJEXT) HttpRequest.$(OBJEXT) \
|
||||||
|
AbstractProxyRequestCommand.$(OBJEXT) \
|
||||||
AbstractProxyResponseCommand.$(OBJEXT) Netrc.$(OBJEXT) \
|
AbstractProxyResponseCommand.$(OBJEXT) Netrc.$(OBJEXT) \
|
||||||
AuthConfig.$(OBJEXT) AbstractAuthResolver.$(OBJEXT) \
|
AuthConfig.$(OBJEXT) AbstractAuthResolver.$(OBJEXT) \
|
||||||
DefaultAuthResolver.$(OBJEXT) NetrcAuthResolver.$(OBJEXT) \
|
DefaultAuthResolver.$(OBJEXT) NetrcAuthResolver.$(OBJEXT) \
|
||||||
|
@ -1103,9 +1104,9 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
|
||||||
DefaultDiskWriter.cc DefaultDiskWriter.h \
|
DefaultDiskWriter.cc DefaultDiskWriter.h \
|
||||||
DefaultDiskWriterFactory.cc DefaultDiskWriterFactory.h File.cc \
|
DefaultDiskWriterFactory.cc DefaultDiskWriterFactory.h File.cc \
|
||||||
File.h Option.cc Option.h Base64.cc Base64.h base32.cc \
|
File.h Option.cc Option.h Base64.cc Base64.h base32.cc \
|
||||||
base32.h LogFactory.cc LogFactory.h TimeA2.cc TimeA2.h \
|
base32.h LogFactory.cc LogFactory.h TimerA2.cc TimerA2.h \
|
||||||
SharedHandle.h HandleRegistry.h FeatureConfig.cc \
|
TimeA2.cc TimeA2.h SharedHandle.h HandleRegistry.h \
|
||||||
FeatureConfig.h DownloadEngineFactory.cc \
|
FeatureConfig.cc FeatureConfig.h DownloadEngineFactory.cc \
|
||||||
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
|
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
|
||||||
BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \
|
BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \
|
||||||
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
|
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
|
||||||
|
@ -1573,6 +1574,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeA2.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeA2.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeBasedCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeBasedCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimedHaltCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimedHaltCommand.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimerA2.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerWatcherCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerWatcherCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TransferStat.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TransferStat.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/URIResult.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/URIResult.Po@am__quote@
|
||||||
|
|
|
@ -370,13 +370,13 @@ bool Peer::isDHTEnabled() const
|
||||||
return _res->dhtEnabled();
|
return _res->dhtEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Time& Peer::getLastDownloadUpdate() const
|
const Timer& Peer::getLastDownloadUpdate() const
|
||||||
{
|
{
|
||||||
assert(_res);
|
assert(_res);
|
||||||
return _res->getLastDownloadUpdate();
|
return _res->getLastDownloadUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Time& Peer::getLastAmUnchoking() const
|
const Timer& Peer::getLastAmUnchoking() const
|
||||||
{
|
{
|
||||||
assert(_res);
|
assert(_res);
|
||||||
return _res->getLastAmUnchoking();
|
return _res->getLastAmUnchoking();
|
||||||
|
@ -393,7 +393,7 @@ void Peer::setIncomingPeer(bool incoming)
|
||||||
_incoming = incoming;
|
_incoming = incoming;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Peer::setFirstContactTime(const Time& time)
|
void Peer::setFirstContactTime(const Timer& time)
|
||||||
{
|
{
|
||||||
_firstContactTime = time;
|
_firstContactTime = time;
|
||||||
}
|
}
|
||||||
|
|
16
src/Peer.h
16
src/Peer.h
|
@ -43,7 +43,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "BtConstants.h"
|
#include "BtConstants.h"
|
||||||
#include "PeerStat.h"
|
#include "PeerStat.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
|
@ -68,9 +68,9 @@ private:
|
||||||
|
|
||||||
unsigned char _peerId[PEER_ID_LENGTH];
|
unsigned char _peerId[PEER_ID_LENGTH];
|
||||||
|
|
||||||
Time _firstContactTime;
|
Timer _firstContactTime;
|
||||||
|
|
||||||
Time _badConditionStartTime;
|
Timer _badConditionStartTime;
|
||||||
|
|
||||||
bool _seeder;
|
bool _seeder;
|
||||||
|
|
||||||
|
@ -146,14 +146,14 @@ public:
|
||||||
|
|
||||||
void releaseSessionResource();
|
void releaseSessionResource();
|
||||||
|
|
||||||
const Time& getFirstContactTime() const
|
const Timer& getFirstContactTime() const
|
||||||
{
|
{
|
||||||
return _firstContactTime;
|
return _firstContactTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFirstContactTime(const Time& time);
|
void setFirstContactTime(const Timer& time);
|
||||||
|
|
||||||
const Time& getBadConditionStartTime() const
|
const Timer& getBadConditionStartTime() const
|
||||||
{
|
{
|
||||||
return _badConditionStartTime;
|
return _badConditionStartTime;
|
||||||
}
|
}
|
||||||
|
@ -269,9 +269,9 @@ public:
|
||||||
|
|
||||||
void setExtension(const std::string& name, uint8_t id);
|
void setExtension(const std::string& name, uint8_t id);
|
||||||
|
|
||||||
const Time& getLastDownloadUpdate() const;
|
const Timer& getLastDownloadUpdate() const;
|
||||||
|
|
||||||
const Time& getLastAmUnchoking() const;
|
const Timer& getLastAmUnchoking() const;
|
||||||
|
|
||||||
uint64_t getCompletedLength() const;
|
uint64_t getCompletedLength() const;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class SocketCore;
|
||||||
|
|
||||||
class PeerAbstractCommand : public Command {
|
class PeerAbstractCommand : public Command {
|
||||||
private:
|
private:
|
||||||
Time checkPoint;
|
Timer checkPoint;
|
||||||
time_t timeout;
|
time_t timeout;
|
||||||
protected:
|
protected:
|
||||||
DownloadEngine* e;
|
DownloadEngine* e;
|
||||||
|
|
|
@ -36,9 +36,11 @@
|
||||||
#define _D_DHT_PEER_ADDR_ENTRY_H_
|
#define _D_DHT_PEER_ADDR_ENTRY_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "TimeA2.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class PeerAddrEntry {
|
class PeerAddrEntry {
|
||||||
|
@ -47,9 +49,10 @@ private:
|
||||||
|
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
|
|
||||||
Time _lastUpdated;
|
Timer _lastUpdated;
|
||||||
public:
|
public:
|
||||||
PeerAddrEntry(const std::string& ipaddr, uint16_t port, Time updated = Time()):
|
PeerAddrEntry
|
||||||
|
(const std::string& ipaddr, uint16_t port, Timer updated = Timer()):
|
||||||
_ipaddr(ipaddr), _port(port), _lastUpdated(updated) {}
|
_ipaddr(ipaddr), _port(port), _lastUpdated(updated) {}
|
||||||
|
|
||||||
const std::string& getIPAddress() const
|
const std::string& getIPAddress() const
|
||||||
|
@ -62,7 +65,7 @@ public:
|
||||||
return _port;
|
return _port;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Time& getLastUpdated() const
|
const Timer& getLastUpdated() const
|
||||||
{
|
{
|
||||||
return _lastUpdated;
|
return _lastUpdated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
#include "BtConstants.h"
|
#include "BtConstants.h"
|
||||||
#include "PeerStat.h"
|
#include "PeerStat.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ private:
|
||||||
bool _dhtEnabled;
|
bool _dhtEnabled;
|
||||||
PeerStat _peerStat;
|
PeerStat _peerStat;
|
||||||
|
|
||||||
Time _lastDownloadUpdate;
|
Timer _lastDownloadUpdate;
|
||||||
|
|
||||||
Time _lastAmUnchoking;
|
Timer _lastAmUnchoking;
|
||||||
|
|
||||||
WeakHandle<BtMessageDispatcher> _dispatcher;
|
WeakHandle<BtMessageDispatcher> _dispatcher;
|
||||||
public:
|
public:
|
||||||
|
@ -216,12 +216,12 @@ public:
|
||||||
|
|
||||||
void updateDownloadLength(size_t bytes);
|
void updateDownloadLength(size_t bytes);
|
||||||
|
|
||||||
const Time& getLastDownloadUpdate() const
|
const Timer& getLastDownloadUpdate() const
|
||||||
{
|
{
|
||||||
return _lastDownloadUpdate;
|
return _lastDownloadUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Time& getLastAmUnchoking() const
|
const Timer& getLastAmUnchoking() const
|
||||||
{
|
{
|
||||||
return _lastAmUnchoking;
|
return _lastAmUnchoking;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ private:
|
||||||
std::string _protocol;
|
std::string _protocol;
|
||||||
SpeedCalc downloadSpeed;
|
SpeedCalc downloadSpeed;
|
||||||
SpeedCalc uploadSpeed;
|
SpeedCalc uploadSpeed;
|
||||||
Time downloadStartTime;
|
Timer downloadStartTime;
|
||||||
PeerStat::STATUS status;
|
PeerStat::STATUS status;
|
||||||
unsigned int _avgDownloadSpeed;
|
unsigned int _avgDownloadSpeed;
|
||||||
unsigned int _avgUploadSpeed;
|
unsigned int _avgUploadSpeed;
|
||||||
|
@ -147,7 +147,7 @@ public:
|
||||||
status = PeerStat::IDLE;
|
status = PeerStat::IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Time& getDownloadStartTime() const {
|
const Timer& getDownloadStartTime() const {
|
||||||
return downloadStartTime;
|
return downloadStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -207,7 +207,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
virtual void getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
||||||
cuid_t myCuid,
|
cuid_t myCuid,
|
||||||
const Time& lastCheckTime) = 0;
|
const Timer& lastCheckTime) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes have entry if specified seconds have elapsed since its
|
* Removes have entry if specified seconds have elapsed since its
|
||||||
|
|
|
@ -39,12 +39,8 @@ namespace aria2 {
|
||||||
|
|
||||||
RequestSlot RequestSlot::nullSlot = RequestSlot();
|
RequestSlot RequestSlot::nullSlot = RequestSlot();
|
||||||
|
|
||||||
void RequestSlot::setDispatchedTime() {
|
void RequestSlot::setDispatchedTime(time_t sec) {
|
||||||
dispatchedTime = global::wallclock;
|
dispatchedTime.reset(sec);
|
||||||
}
|
|
||||||
|
|
||||||
void RequestSlot::setDispatchedTime(time_t secFromEpoch) {
|
|
||||||
dispatchedTime.setTimeInSec(secFromEpoch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RequestSlot::isTimeout(time_t timeoutSec) const {
|
bool RequestSlot::isTimeout(time_t timeoutSec) const {
|
||||||
|
|
|
@ -36,14 +36,15 @@
|
||||||
#define _D_REQUEST_SLOT_H_
|
#define _D_REQUEST_SLOT_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "Piece.h"
|
#include "Piece.h"
|
||||||
|
#include "wallclock.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class RequestSlot {
|
class RequestSlot {
|
||||||
private:
|
private:
|
||||||
Time dispatchedTime;
|
Timer dispatchedTime;
|
||||||
size_t index;
|
size_t index;
|
||||||
uint32_t begin;
|
uint32_t begin;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
@ -70,6 +71,7 @@ public:
|
||||||
|
|
||||||
RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex,
|
RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex,
|
||||||
const SharedHandle<Piece>& piece = SharedHandle<Piece>()):
|
const SharedHandle<Piece>& piece = SharedHandle<Piece>()):
|
||||||
|
dispatchedTime(global::wallclock),
|
||||||
index(index), begin(begin), length(length), blockIndex(blockIndex),
|
index(index), begin(begin), length(length), blockIndex(blockIndex),
|
||||||
_piece(piece) {}
|
_piece(piece) {}
|
||||||
|
|
||||||
|
@ -113,7 +115,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDispatchedTime();
|
|
||||||
void setDispatchedTime(time_t secFromEpoch);
|
void setDispatchedTime(time_t secFromEpoch);
|
||||||
|
|
||||||
bool isTimeout(time_t timeoutSec) const;
|
bool isTimeout(time_t timeoutSec) const;
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "BitfieldMan.h"
|
#include "BitfieldMan.h"
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ private:
|
||||||
// key: PeerStat's cuid, value: its download speed
|
// key: PeerStat's cuid, value: its download speed
|
||||||
std::map<cuid_t, unsigned int> _peerStatDlspdMap;
|
std::map<cuid_t, unsigned int> _peerStatDlspdMap;
|
||||||
|
|
||||||
Time _lastPeerStatDlspdMapUpdated;
|
Timer _lastPeerStatDlspdMapUpdated;
|
||||||
|
|
||||||
unsigned int _cachedDlspd;
|
unsigned int _cachedDlspd;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "wallclock.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@ void ServerStat::updateDownloadSpeed(unsigned int downloadSpeed)
|
||||||
if(downloadSpeed > 0) {
|
if(downloadSpeed > 0) {
|
||||||
_status = OK;
|
_status = OK;
|
||||||
}
|
}
|
||||||
_lastUpdated = global::wallclock;
|
_lastUpdated.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::setSingleConnectionAvgSpeed
|
void ServerStat::setSingleConnectionAvgSpeed
|
||||||
|
@ -183,7 +182,7 @@ void ServerStat::setStatusInternal(STATUS status)
|
||||||
_hostname.c_str(), _protocol.c_str());
|
_hostname.c_str(), _protocol.c_str());
|
||||||
}
|
}
|
||||||
_status = status;
|
_status = status;
|
||||||
_lastUpdated = global::wallclock;
|
_lastUpdated.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::setOK()
|
void ServerStat::setOK()
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include "ServerStat.h"
|
#include "ServerStat.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
#include "wallclock.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -144,12 +143,13 @@ bool ServerStatMan::load(std::istream& in)
|
||||||
class FindStaleServerStat {
|
class FindStaleServerStat {
|
||||||
private:
|
private:
|
||||||
time_t _timeout;
|
time_t _timeout;
|
||||||
|
Time _time;
|
||||||
public:
|
public:
|
||||||
FindStaleServerStat(time_t timeout):_timeout(timeout) {}
|
FindStaleServerStat(time_t timeout):_timeout(timeout) {}
|
||||||
|
|
||||||
bool operator()(const SharedHandle<ServerStat>& ss) const
|
bool operator()(const SharedHandle<ServerStat>& ss) const
|
||||||
{
|
{
|
||||||
return ss->getLastUpdated().difference(global::wallclock) >= _timeout;
|
return ss->getLastUpdated().difference(_time) >= _timeout;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,14 @@
|
||||||
#ifndef _D_SERVER_STAT_MAN_H_
|
#ifndef _D_SERVER_STAT_MAN_H_
|
||||||
#define _D_SERVER_STAT_MAN_H_
|
#define _D_SERVER_STAT_MAN_H_
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
#include "SharedHandle.h"
|
||||||
|
#include "a2time.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class ServerStat;
|
class ServerStat;
|
||||||
|
|
|
@ -44,7 +44,7 @@ SleepCommand::SleepCommand(cuid_t cuid, DownloadEngine* e,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
Command* nextCommand, time_t wait):
|
Command* nextCommand, time_t wait):
|
||||||
Command(cuid), engine(e), _requestGroup(requestGroup),
|
Command(cuid), engine(e), _requestGroup(requestGroup),
|
||||||
nextCommand(nextCommand), wait(wait) {}
|
nextCommand(nextCommand), wait(wait), checkPoint(global::wallclock) {}
|
||||||
|
|
||||||
SleepCommand::~SleepCommand() {
|
SleepCommand::~SleepCommand() {
|
||||||
delete nextCommand;
|
delete nextCommand;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define _D_SLEEP_COMMAND_H_
|
#define _D_SLEEP_COMMAND_H_
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ private:
|
||||||
RequestGroup* _requestGroup;
|
RequestGroup* _requestGroup;
|
||||||
Command* nextCommand;
|
Command* nextCommand;
|
||||||
time_t wait;
|
time_t wait;
|
||||||
Time checkPoint;
|
Timer checkPoint;
|
||||||
public:
|
public:
|
||||||
SleepCommand(cuid_t cuid, DownloadEngine* e, RequestGroup* requestGroup,
|
SleepCommand(cuid_t cuid, DownloadEngine* e, RequestGroup* requestGroup,
|
||||||
Command* nextCommand, time_t wait);
|
Command* nextCommand, time_t wait);
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define _D_SPEED_CALC_H_
|
#define _D_SPEED_CALC_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ class SpeedCalc {
|
||||||
private:
|
private:
|
||||||
uint64_t lengthArray[2];
|
uint64_t lengthArray[2];
|
||||||
int sw;
|
int sw;
|
||||||
Time cpArray[2];
|
Timer cpArray[2];
|
||||||
unsigned int maxSpeed;
|
unsigned int maxSpeed;
|
||||||
unsigned int prevSpeed;
|
unsigned int prevSpeed;
|
||||||
Time start;
|
Timer start;
|
||||||
uint64_t accumulatedLength;
|
uint64_t accumulatedLength;
|
||||||
time_t nextInterval;
|
time_t nextInterval;
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,11 @@
|
||||||
#define _D_STREAM_CHECK_INTEGRITY_ENTRY_H_
|
#define _D_STREAM_CHECK_INTEGRITY_ENTRY_H_
|
||||||
|
|
||||||
#include "PieceHashCheckIntegrityEntry.h"
|
#include "PieceHashCheckIntegrityEntry.h"
|
||||||
#include "TimeA2.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class StreamCheckIntegrityEntry:public PieceHashCheckIntegrityEntry
|
class StreamCheckIntegrityEntry:public PieceHashCheckIntegrityEntry
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
Time _timer;
|
|
||||||
public:
|
public:
|
||||||
StreamCheckIntegrityEntry(RequestGroup* requestGroup,
|
StreamCheckIntegrityEntry(RequestGroup* requestGroup,
|
||||||
Command* nextCommand = 0);
|
Command* nextCommand = 0);
|
||||||
|
|
|
@ -36,13 +36,10 @@
|
||||||
#define _D_STREAM_FILE_ALLOCATION_ENTRY_H_
|
#define _D_STREAM_FILE_ALLOCATION_ENTRY_H_
|
||||||
|
|
||||||
#include "FileAllocationEntry.h"
|
#include "FileAllocationEntry.h"
|
||||||
#include "TimeA2.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class StreamFileAllocationEntry : public FileAllocationEntry {
|
class StreamFileAllocationEntry : public FileAllocationEntry {
|
||||||
private:
|
|
||||||
Time _timer;
|
|
||||||
public:
|
public:
|
||||||
StreamFileAllocationEntry(RequestGroup* requestGroup,
|
StreamFileAllocationEntry(RequestGroup* requestGroup,
|
||||||
Command* nextCommand = 0);
|
Command* nextCommand = 0);
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define _D_TIME_BASED_COMMAND_H_
|
#define _D_TIME_BASED_COMMAND_H_
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ protected:
|
||||||
|
|
||||||
bool _routineCommand;
|
bool _routineCommand;
|
||||||
private:
|
private:
|
||||||
Time _checkPoint;
|
Timer _checkPoint;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* preProcess() is called each time when excute() is called.
|
* preProcess() is called each time when excute() is called.
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define _D_TIME_SEED_CRITERIA_H_
|
#define _D_TIME_SEED_CRITERIA_H_
|
||||||
|
|
||||||
#include "SeedCriteria.h"
|
#include "SeedCriteria.h"
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -45,7 +45,7 @@ class TimeSeedCriteria : public SeedCriteria {
|
||||||
private:
|
private:
|
||||||
// How much time the client does seeding in seconds.
|
// How much time the client does seeding in seconds.
|
||||||
time_t duration;
|
time_t duration;
|
||||||
Time watch;
|
Timer watch;
|
||||||
public:
|
public:
|
||||||
TimeSeedCriteria(time_t duration):duration(duration) {}
|
TimeSeedCriteria(time_t duration):duration(duration) {}
|
||||||
virtual ~TimeSeedCriteria() {}
|
virtual ~TimeSeedCriteria() {}
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
|
||||||
|
#include "TimerA2.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
namespace aria2 {
|
||||||
|
|
||||||
|
Timer::Timer()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer::Timer(const Timer& timer):_tv(timer._tv) {}
|
||||||
|
|
||||||
|
Timer::Timer(time_t sec)
|
||||||
|
{
|
||||||
|
reset(sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer::Timer(const struct timeval& tv):_tv(tv) {}
|
||||||
|
|
||||||
|
static bool useClockGettime()
|
||||||
|
{
|
||||||
|
static timespec ts;
|
||||||
|
static int r = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
return r == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer& Timer::operator=(const Timer& timer)
|
||||||
|
{
|
||||||
|
if(this != &timer) {
|
||||||
|
_tv = timer._tv;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Timer::operator<(const Timer& timer) const
|
||||||
|
{
|
||||||
|
return util::difftv(timer._tv, _tv) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Timer::operator>(const Timer& timer) const
|
||||||
|
{
|
||||||
|
return util::difftv(_tv, timer._tv) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static timeval getCurrentTime()
|
||||||
|
{
|
||||||
|
timeval tv;
|
||||||
|
if(useClockGettime()) {
|
||||||
|
timespec ts;
|
||||||
|
int r = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
assert(r == 0);
|
||||||
|
tv.tv_sec = ts.tv_sec+2678400; // 1month offset(24*3600*31)
|
||||||
|
tv.tv_usec = ts.tv_nsec/1000;
|
||||||
|
} else {
|
||||||
|
gettimeofday(&tv, 0);
|
||||||
|
}
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer::reset()
|
||||||
|
{
|
||||||
|
_tv = getCurrentTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer::reset(time_t sec)
|
||||||
|
{
|
||||||
|
_tv.tv_sec = sec;
|
||||||
|
_tv.tv_usec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Timer::elapsed(time_t sec) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
util::difftv(getCurrentTime(), _tv) >= static_cast<int64_t>(sec)*1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Timer::elapsedInMillis(int64_t millis) const
|
||||||
|
{
|
||||||
|
return util::difftv(getCurrentTime(), _tv)/1000 >= millis;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t Timer::difference() const
|
||||||
|
{
|
||||||
|
return util::difftv(getCurrentTime(), _tv)/1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t Timer::difference(const timeval& tv) const
|
||||||
|
{
|
||||||
|
return util::difftv(tv, _tv)/1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t Timer::differenceInMillis() const
|
||||||
|
{
|
||||||
|
return util::difftv(getCurrentTime(), _tv)/1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t Timer::differenceInMillis(const timeval& tv) const
|
||||||
|
{
|
||||||
|
return util::difftv(tv, _tv)/1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Timer::isZero() const
|
||||||
|
{
|
||||||
|
return _tv.tv_sec == 0 && _tv.tv_usec == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t Timer::getTimeInMicros() const
|
||||||
|
{
|
||||||
|
return (int64_t)_tv.tv_sec*1000*1000+_tv.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t Timer::getTimeInMillis() const
|
||||||
|
{
|
||||||
|
return (int64_t)_tv.tv_sec*1000+_tv.tv_usec/1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t Timer::getTime() const
|
||||||
|
{
|
||||||
|
return _tv.tv_sec;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer::advance(time_t sec)
|
||||||
|
{
|
||||||
|
_tv.tv_sec += sec;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace aria2
|
|
@ -0,0 +1,101 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#ifndef _D_TIMER_A2_H_
|
||||||
|
#define _D_TIMER_A2_H_
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "a2time.h"
|
||||||
|
|
||||||
|
namespace aria2 {
|
||||||
|
|
||||||
|
class Timer {
|
||||||
|
private:
|
||||||
|
timeval _tv;
|
||||||
|
|
||||||
|
int64_t difference(const struct timeval& tv) const;
|
||||||
|
|
||||||
|
int64_t differenceInMillis(const struct timeval& tv) const;
|
||||||
|
public:
|
||||||
|
// The time value is initialized so that it represents the time at which
|
||||||
|
// this object was created.
|
||||||
|
Timer();
|
||||||
|
Timer(const Timer& time);
|
||||||
|
Timer(time_t sec);
|
||||||
|
Timer(const struct timeval& tv);
|
||||||
|
|
||||||
|
Timer& operator=(const Timer& timer);
|
||||||
|
|
||||||
|
bool operator<(const Timer& timer) const;
|
||||||
|
|
||||||
|
bool operator>(const Timer& timer) const;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void reset(time_t sec);
|
||||||
|
|
||||||
|
bool elapsed(time_t sec) const;
|
||||||
|
|
||||||
|
bool elapsedInMillis(int64_t millis) const;
|
||||||
|
|
||||||
|
time_t difference() const;
|
||||||
|
|
||||||
|
time_t difference(const Timer& timer) const
|
||||||
|
{
|
||||||
|
return difference(timer._tv);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t differenceInMillis() const;
|
||||||
|
|
||||||
|
int64_t differenceInMillis(const Timer& timer) const
|
||||||
|
{
|
||||||
|
return differenceInMillis(timer._tv);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if this object's time value is zero.
|
||||||
|
bool isZero() const;
|
||||||
|
|
||||||
|
void advance(time_t sec);
|
||||||
|
|
||||||
|
// Returns this object's time value in seconds.
|
||||||
|
time_t getTime() const;
|
||||||
|
|
||||||
|
int64_t getTimeInMicros() const;
|
||||||
|
|
||||||
|
int64_t getTimeInMillis() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace aria2
|
||||||
|
|
||||||
|
#endif // _D_TIMER_A2_H_
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -50,7 +50,7 @@ class UTMetadataRequestTracker {
|
||||||
private:
|
private:
|
||||||
struct RequestEntry {
|
struct RequestEntry {
|
||||||
size_t _index;
|
size_t _index;
|
||||||
Time _dispatchedTime;
|
Timer _dispatchedTime;
|
||||||
|
|
||||||
RequestEntry(size_t index):_index(index) {}
|
RequestEntry(size_t index):_index(index) {}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
||||||
cuid_t myCuid, const Time& lastCheckTime)
|
cuid_t myCuid, const Timer& lastCheckTime)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
10
src/a2time.h
10
src/a2time.h
|
@ -61,4 +61,14 @@
|
||||||
# define suseconds_t uint64_t
|
# define suseconds_t uint64_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CLOCK_MONOTONIC
|
||||||
|
# define CLOCK_MONOTONIC 0
|
||||||
|
#endif // !CLOCK_MONOTONIC
|
||||||
|
#ifndef HAVE_STRUCT_TIMESPEC
|
||||||
|
# define timespec int
|
||||||
|
#endif // !HAVE_STRUCT_TIMESPEC
|
||||||
|
#ifndef HAVE_CLOCK_GETTIME
|
||||||
|
# define clock_gettime(ID, TP) (-1)
|
||||||
|
#endif // !HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
#endif // _D_A2TIME_H_
|
#endif // _D_A2TIME_H_
|
||||||
|
|
|
@ -32,14 +32,14 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "TimeA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace global {
|
namespace global {
|
||||||
|
|
||||||
// wallclock is defined in DownloadEngine.cc
|
// wallclock is defined in DownloadEngine.cc
|
||||||
extern Time wallclock;
|
extern Timer wallclock;
|
||||||
|
|
||||||
} // namespace global
|
} // namespace global
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,9 @@ void DHTPeerAnnounceEntryTest::testRemoveStalePeerAddrEntry()
|
||||||
DHTPeerAnnounceEntry entry(infohash);
|
DHTPeerAnnounceEntry entry(infohash);
|
||||||
|
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6881));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6881));
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.2", 6882, Time(0)));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.2", 6882, Timer(0)));
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.3", 6883));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.3", 6883));
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.4", 6884, Time(0)));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.4", 6884, Timer(0)));
|
||||||
|
|
||||||
entry.removeStalePeerAddrEntry(10);
|
entry.removeStalePeerAddrEntry(10);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void DHTPeerAnnounceEntryTest::testAddPeerAddrEntry()
|
||||||
memset(infohash, 0xff, DHT_ID_LENGTH);
|
memset(infohash, 0xff, DHT_ID_LENGTH);
|
||||||
|
|
||||||
DHTPeerAnnounceEntry entry(infohash);
|
DHTPeerAnnounceEntry entry(infohash);
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6881, Time(0)));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6881, Timer(0)));
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6882));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6882));
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, entry.countPeerAddrEntry());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, entry.countPeerAddrEntry());
|
||||||
|
@ -95,7 +95,7 @@ void DHTPeerAnnounceEntryTest::testGetPeers()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)0, peers.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)0, peers.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6881, Time(0)));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.1", 6881, Timer(0)));
|
||||||
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.2", 6882));
|
entry.addPeerAddrEntry(PeerAddrEntry("192.168.0.2", 6882));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,7 +214,7 @@ public:
|
||||||
|
|
||||||
virtual void getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
virtual void getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
||||||
cuid_t myCuid,
|
cuid_t myCuid,
|
||||||
const Time& lastCheckTime)
|
const Timer& lastCheckTime)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void removeAdvertisedPiece(time_t elapsed) {}
|
virtual void removeAdvertisedPiece(time_t elapsed) {}
|
||||||
|
|
|
@ -206,7 +206,7 @@ void UTPexExtensionMessageTest::testAddFreshPeer()
|
||||||
SharedHandle<Peer> p1(new Peer("192.168.0.1", 6881));
|
SharedHandle<Peer> p1(new Peer("192.168.0.1", 6881));
|
||||||
CPPUNIT_ASSERT(msg.addFreshPeer(p1));
|
CPPUNIT_ASSERT(msg.addFreshPeer(p1));
|
||||||
SharedHandle<Peer> p2(new Peer("10.1.1.2", 9999));
|
SharedHandle<Peer> p2(new Peer("10.1.1.2", 9999));
|
||||||
p2->setFirstContactTime(Time(Time().getTime()-61));
|
p2->setFirstContactTime(Timer(Timer().getTime()-61));
|
||||||
CPPUNIT_ASSERT(!msg.addFreshPeer(p2));
|
CPPUNIT_ASSERT(!msg.addFreshPeer(p2));
|
||||||
SharedHandle<Peer> p3(new Peer("10.1.1.3", 9999, true));
|
SharedHandle<Peer> p3(new Peer("10.1.1.3", 9999, true));
|
||||||
CPPUNIT_ASSERT(!msg.addFreshPeer(p3));
|
CPPUNIT_ASSERT(!msg.addFreshPeer(p3));
|
||||||
|
|
Loading…
Reference in New Issue