diff --git a/include/opendht/network_engine.h b/include/opendht/network_engine.h index 3a5ab8fe..3ad57509 100644 --- a/include/opendht/network_engine.h +++ b/include/opendht/network_engine.h @@ -276,7 +276,7 @@ public: */ Sp sendPing(Sp n, RequestCb&& on_done, RequestExpiredCb&& on_expired); - + /** * Send a "ping" request to a given node. * @@ -293,7 +293,7 @@ public: std::forward(on_done), std::forward(on_expired)); } - + /** * Send a "find node" request to a given node. * diff --git a/src/network_engine.cpp b/src/network_engine.cpp index 6f02742c..26f0880e 100644 --- a/src/network_engine.cpp +++ b/src/network_engine.cpp @@ -281,6 +281,9 @@ NetworkEngine::requestStep(Sp sreq) ++req.attempt_count; req.attempt_duration += req.attempt_duration + uniform_duration_distribution<>(0ms, ((duration)Node::MAX_RESPONSE_TIME)/4)(rd); + if (not req.parts.empty()){ + sendValueParts(req.tid, req.parts, node.getAddr()); + } } std::weak_ptr wreq = sreq; scheduler.add(req.last_try + req.attempt_duration, [this,wreq] { @@ -1175,9 +1178,8 @@ NetworkEngine::sendAnnounceValue(Sp n, } } ); + req->parts = std::move(v); sendRequest(req); - if (not v.empty()) - sendValueParts(tid, v, n->getAddr()); ++out_stats.put; return req; } diff --git a/src/request.h b/src/request.h index 2a0d9395..e2798cc7 100644 --- a/src/request.h +++ b/src/request.h @@ -115,6 +115,7 @@ private: on_done = {}; on_expired = {}; msg = {}; + parts = {}; } const Tid tid {0}; /* the request id. */ @@ -131,6 +132,7 @@ private: Blob msg {}; /* the serialized message. */ Tid socket; /* the socket used for further reponses. */ + std::vector parts; }; } /* namespace net */