BIND 10 trac495, updated. 28c720f2b0319ee8b2ee21cea1105e411a31360c [trac495] use gettimeofday for rtt calc
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Feb 28 09:50:13 UTC 2011
The branch, trac495 has been updated
via 28c720f2b0319ee8b2ee21cea1105e411a31360c (commit)
from d82bd9a601e95a301e268c21a8ddcfea560d38dc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 28c720f2b0319ee8b2ee21cea1105e411a31360c
Author: Jelte Jansen <jelte at isc.org>
Date: Mon Feb 28 10:50:01 2011 +0100
[trac495] use gettimeofday for rtt calc
-----------------------------------------------------------------------
Summary of changes:
src/lib/asiolink/recursive_query.cc | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/asiolink/recursive_query.cc b/src/lib/asiolink/recursive_query.cc
index d79848a..2975981 100644
--- a/src/lib/asiolink/recursive_query.cc
+++ b/src/lib/asiolink/recursive_query.cc
@@ -171,7 +171,7 @@ private:
std::string cur_zone_;
boost::shared_ptr<ResolverNSASCallback> nsas_callback_;
isc::nsas::NameserverAddress current_ns_address;
- time_t current_ns_qsent_time;
+ struct timeval current_ns_qsent_time;
// perform a single lookup; first we check the cache to see
// if we have a response for our query stored already. if
@@ -195,10 +195,7 @@ private:
// We need to keep track of the Address, so that we can update
// the RTT
current_ns_address = address;
- time(¤t_ns_qsent_time);
- std::cout << "[XX] ORIG SND TIME: " << current_ns_qsent_time << std::endl;
- std::cout << "[XX] SENDING: " << question_.toText() << std::endl;
- std::cout << "[XX] TO AUTH: " << current_ns_address.getAddress().toText() << std::endl;
+ gettimeofday(¤t_ns_qsent_time, NULL);
IOFetch query(IPPROTO_UDP, io_, question_,
current_ns_address.getAddress(),
53, buffer_, this,
@@ -516,14 +513,19 @@ public:
// we got an answer
// Update the NSAS with the time it took
- time_t cur_time;
- time(&cur_time);
- if (cur_time == current_ns_qsent_time) {
- dlog("[XX] well, that was fast. 0 ms? setting it to 1...");
- ++cur_time;
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ uint32_t rtt;
+ if (cur_time.tv_sec >= current_ns_qsent_time.tv_sec &&
+ cur_time.tv_usec > current_ns_qsent_time.tv_usec) {
+ rtt = 1000 * (cur_time.tv_sec - current_ns_qsent_time.tv_sec);
+ rtt += (cur_time.tv_usec - current_ns_qsent_time.tv_usec) / 1000;
+ } else {
+ rtt = 1;
}
- current_ns_address.updateRTT(
- static_cast<uint32_t>(cur_time - current_ns_qsent_time));
+
+ dlog("RTT: " + boost::lexical_cast<std::string>(rtt));
+ current_ns_address.updateRTT(rtt);
Message incoming(Message::PARSE);
InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
More information about the bind10-changes
mailing list