diff --git a/include/opendht/network_engine.h b/include/opendht/network_engine.h index b657c9d8..e53f3fa1 100644 --- a/include/opendht/network_engine.h +++ b/include/opendht/network_engine.h @@ -128,7 +128,7 @@ public: unsigned attempt_count {0}; /* number of attempt to process the request. */ time_point start {time_point::min()}; /* time when the request is created. */ time_point last_try {time_point::min()}; /* time of the last attempt to process the request. */ - time_point reply_time {time_point::min()}; /* time when we received the response from the node. */ + time_point reply_time {time_point::min()}; /* time when we received the response to the request. */ RequestStatus() {} RequestStatus(time_point start, time_point reply_time = time_point::min()) diff --git a/src/dht.cpp b/src/dht.cpp index 5370872a..128e7a61 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -738,6 +738,7 @@ Dht::Search::insertNode(std::shared_ptr node, time_point now, const Blob& } if (not token.empty()) { n->candidate = false; + n->last_get_reply = now; if (token.size() <= 64) n->token = token; expired = false; @@ -2388,8 +2389,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc } catch (DhtProtocolException& e) { DHT_LOG.ERROR("Can't parse message from %s: %s", e.getNodeId().toString().c_str(), e.what()); auto code = e.getCode(); - if (code == DhtProtocolException::INVALID_TID_SIZE - or code == DhtProtocolException::WRONG_NODE_INFO_BUF_LEN) { + if (code == DhtProtocolException::INVALID_TID_SIZE or code == DhtProtocolException::WRONG_NODE_INFO_BUF_LEN) { /* This is really annoying, as it means that we will time-out all our searches that go through this node. Kill it. */ @@ -2666,10 +2666,6 @@ Dht::onGetValuesDone(std::shared_ptr status, Netwo DHT_LOG.DEBUG("[search %s IPv%c] got reply to 'get'", sr->id.toString().c_str(), sr->af == AF_INET ? '4' : '6'); const auto& now = scheduler.time(); sr->insertNode(status->node, now, a.ntoken); - for (auto& sn : sr->nodes) { - if (sn.node->id == status->node->id) - sn.last_get_reply = status->reply_time; - } if (!a.values.empty()) { DHT_LOG.DEBUG("[search %s IPv%c] found %u values", sr->id.toString().c_str(), sr->af == AF_INET ? '4' : '6', diff --git a/src/network_engine.cpp b/src/network_engine.cpp index ab0a7e65..3377fadc 100644 --- a/src/network_engine.cpp +++ b/src/network_engine.cpp @@ -140,7 +140,8 @@ NetworkEngine::processMessage(const uint8_t *buf, size_t buflen, const sockaddr if (msg.error_code == DhtProtocolException::UNAUTHORIZED && msg.id != zeroes && (msg.tid.matches(TransPrefix::ANNOUNCE_VALUES, &ttid) - || msg.tid.matches(TransPrefix::LISTEN, &ttid))) { + || msg.tid.matches(TransPrefix::LISTEN, &ttid))) + { req->status->last_try = TIME_INVALID; req->status->reply_time = TIME_INVALID; onError(req->status, DhtProtocolException {DhtProtocolException::UNAUTHORIZED});