diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-03-26 17:12:52 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-03-26 17:20:27 +0900 |
| commit | d64089632e82a2548752c7a6baaa68365a795a74 (patch) | |
| tree | 57fc7b85a8c1290975d58fa4761b04a7695bf7e3 /src/DHTPingTask.cc | |
| parent | c81b1321122e8509b55c94c0cbca0d8d6d319f0c (diff) | |
| parent | a7cd943a06b1a5ff4515b57060b84037f8d01f9f (diff) | |
Merge branch 'master' into random-webseeding
Diffstat (limited to 'src/DHTPingTask.cc')
| -rw-r--r-- | src/DHTPingTask.cc | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/DHTPingTask.cc b/src/DHTPingTask.cc index cfb12356..6daf096e 100644 --- a/src/DHTPingTask.cc +++ b/src/DHTPingTask.cc @@ -44,29 +44,26 @@ namespace aria2 { -DHTPingTask::DHTPingTask -(const std::shared_ptr<DHTNode>& remoteNode, int numMaxRetry): - remoteNode_(remoteNode), - numMaxRetry_(numMaxRetry), - numRetry_(0), - pingSuccessful_(false), - timeout_(DHT_MESSAGE_TIMEOUT) -{} +DHTPingTask::DHTPingTask(const std::shared_ptr<DHTNode>& remoteNode, + int numMaxRetry) + : remoteNode_(remoteNode), + numMaxRetry_(numMaxRetry), + numRetry_(0), + pingSuccessful_(false), + timeout_(DHT_MESSAGE_TIMEOUT) +{ +} DHTPingTask::~DHTPingTask() {} void DHTPingTask::addMessage() { - getMessageDispatcher()->addMessageToQueue - (getMessageFactory()->createPingMessage(remoteNode_), - timeout_, - make_unique<DHTPingReplyMessageCallback<DHTPingTask>>(this)); + getMessageDispatcher()->addMessageToQueue( + getMessageFactory()->createPingMessage(remoteNode_), timeout_, + make_unique<DHTPingReplyMessageCallback<DHTPingTask>>(this)); } -void DHTPingTask::startup() -{ - addMessage(); -} +void DHTPingTask::startup() { addMessage(); } void DHTPingTask::onReceived(const DHTPingReplyMessage* message) { @@ -77,17 +74,15 @@ void DHTPingTask::onReceived(const DHTPingReplyMessage* message) void DHTPingTask::onTimeout(const std::shared_ptr<DHTNode>& node) { ++numRetry_; - if(numRetry_ >= numMaxRetry_) { + if (numRetry_ >= numMaxRetry_) { pingSuccessful_ = false; setFinished(true); - } else { + } + else { addMessage(); } } -bool DHTPingTask::isPingSuccessful() const -{ - return pingSuccessful_; -} +bool DHTPingTask::isPingSuccessful() const { return pingSuccessful_; } } // namespace aria2 |
