summaryrefslogtreecommitdiff
path: root/src/DHTInteractionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-01-19 11:24:57 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-01-19 11:24:57 +0900
commit8b93b12488d12820470e14f0ebbb656728f7df83 (patch)
tree0d1f76f36d1606ea94b623e222430b7d7fe862e7 /src/DHTInteractionCommand.cc
parent7b2e797fdfa27794b0f4a96bba0c42b5e67a6050 (diff)
Reduce delay in tracker request
We eliminated 1 second delay between completion of name resolution for tracker request and time when it is actually issued. We also elimited 1 second delay after last torrent download exists and it is told to DHTInteractionCommand.
Diffstat (limited to 'src/DHTInteractionCommand.cc')
-rw-r--r--src/DHTInteractionCommand.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/DHTInteractionCommand.cc b/src/DHTInteractionCommand.cc
index 2eb87fae..ca6554c5 100644
--- a/src/DHTInteractionCommand.cc
+++ b/src/DHTInteractionCommand.cc
@@ -54,6 +54,7 @@
#include "UDPTrackerRequest.h"
#include "fmt.h"
#include "wallclock.h"
+#include "TrackerWatcherCommand.h"
namespace aria2 {
@@ -66,6 +67,7 @@ DHTInteractionCommand::DHTInteractionCommand(cuid_t cuid, DownloadEngine* e)
receiver_{nullptr},
taskQueue_{nullptr}
{
+ setStatusRealtime();
}
DHTInteractionCommand::~DHTInteractionCommand()
@@ -96,10 +98,12 @@ bool DHTInteractionCommand::execute()
// needs this.
if (e_->getRequestGroupMan()->downloadFinished() ||
(e_->isHaltRequested() && udpTrackerClient_->getNumWatchers() == 0)) {
+ A2_LOG_DEBUG("DHTInteractionCommand exiting");
return true;
}
else if (e_->isForceHaltRequested()) {
udpTrackerClient_->failAll();
+ A2_LOG_DEBUG("DHTInteractionCommand exiting");
return true;
}
@@ -122,8 +126,18 @@ bool DHTInteractionCommand::execute()
}
else {
// this may be udp tracker response. nothrow.
- udpTrackerClient_->receiveReply(data.data(), length, remoteAddr,
- remotePort, global::wallclock());
+ std::shared_ptr<UDPTrackerRequest> req;
+ if (udpTrackerClient_->receiveReply(req, data.data(), length,
+ remoteAddr, remotePort,
+ global::wallclock()) == 0) {
+ if (req->action == UDPT_ACT_ANNOUNCE) {
+ auto c = static_cast<TrackerWatcherCommand*>(req->user_data);
+ if (c) {
+ c->setStatus(Command::STATUS_ONESHOT_REALTIME);
+ e_->setNoWait(true);
+ }
+ }
+ }
}
}
}
@@ -150,7 +164,7 @@ bool DHTInteractionCommand::execute()
udpTrackerClient_->requestFail(UDPT_ERR_NETWORK);
}
}
- e_->addCommand(std::unique_ptr<Command>(this));
+ e_->addRoutineCommand(std::unique_ptr<Command>(this));
return false;
}