diff options
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 |
