mirror of https://github.com/aria2/aria2
Fixed rounding error in DownloadEngine::run().
This fixes the bug that executeCommand() with Command::STATUS_ALL is not called in every interval correctly because of rounding error in timer.pull/1/head
parent
f8f651e8db
commit
59f251ba14
|
@ -141,6 +141,13 @@ void executeCommand(std::deque<Command*>& commands,
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Rounding error in millis
|
||||||
|
const int A2_DELTA = 10;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void DownloadEngine::run()
|
void DownloadEngine::run()
|
||||||
{
|
{
|
||||||
Timer cp;
|
Timer cp;
|
||||||
|
@ -148,7 +155,7 @@ void DownloadEngine::run()
|
||||||
while(!commands_.empty() || !routineCommands_.empty()) {
|
while(!commands_.empty() || !routineCommands_.empty()) {
|
||||||
global::wallclock.reset();
|
global::wallclock.reset();
|
||||||
calculateStatistics();
|
calculateStatistics();
|
||||||
if(cp.differenceInMillis(global::wallclock) >= refreshInterval_) {
|
if(cp.differenceInMillis(global::wallclock) >= refreshInterval_-A2_DELTA) {
|
||||||
refreshInterval_ = DEFAULT_REFRESH_INTERVAL;
|
refreshInterval_ = DEFAULT_REFRESH_INTERVAL;
|
||||||
cp = global::wallclock;
|
cp = global::wallclock;
|
||||||
executeCommand(commands_, Command::STATUS_ALL);
|
executeCommand(commands_, Command::STATUS_ALL);
|
||||||
|
|
Loading…
Reference in New Issue