From: Yoshitaka Aharen Date: Thu, 15 Nov 2012 04:59:21 +0000 (+0900) Subject: [2157] removed a member from QRAttributes X-Git-Tag: bind10-1.1.0beta1-release~85^2~5^2~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=425b14dc49047c29338e415f6360a15c81b4f48c;p=thirdparty%2Fkea.git [2157] removed a member from QRAttributes --- diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc index 3ab1d002ec..f29bb61d48 100644 --- a/src/bin/auth/auth_srv.cc +++ b/src/bin/auth/auth_srv.cc @@ -237,7 +237,8 @@ public: BaseSocketSessionForwarder& ddns_forwarder); ~AuthSrvImpl(); - bool processNormalQuery(const IOMessage& io_message, Message& message, + bool processNormalQuery(const IOMessage& io_message, + ConstEDNSPtr remote_edns, Message& message, OutputBuffer& buffer, auto_ptr tsig_context); bool processXfrQuery(const IOMessage& io_message, Message& message, @@ -571,13 +572,11 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message, try { // statistics: check EDNS // note: This can only be reliable after TSIG check succeeds. - { - ConstEDNSPtr edns = message.getEDNS(); - if (edns != NULL) { - impl_->stats_attrs_.setQueryEDNS(true, - edns->getVersion() != 0); - impl_->stats_attrs_.setQueryDO(edns->getDNSSECAwareness()); - } + ConstEDNSPtr edns = message.getEDNS(); + if (edns) { + impl_->stats_attrs_.setQueryEDNS(true, + edns->getVersion() != 0); + impl_->stats_attrs_.setQueryDO(edns->getDNSSECAwareness()); } // statistics: check OpCode @@ -612,8 +611,9 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message, send_answer = impl_->processXfrQuery(io_message, message, buffer, tsig_context); } else { - send_answer = impl_->processNormalQuery(io_message, message, - buffer, tsig_context); + send_answer = impl_->processNormalQuery(io_message, edns, + message, buffer, + tsig_context); } } } catch (const std::exception& ex) { @@ -628,11 +628,11 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message, } bool -AuthSrvImpl::processNormalQuery(const IOMessage& io_message, Message& message, +AuthSrvImpl::processNormalQuery(const IOMessage& io_message, + ConstEDNSPtr remote_edns, Message& message, OutputBuffer& buffer, auto_ptr tsig_context) { - ConstEDNSPtr remote_edns = message.getEDNS(); const bool dnssec_ok = remote_edns && remote_edns->getDNSSECAwareness(); const uint16_t remote_bufsize = remote_edns ? remote_edns->getUDPSize() : Message::DEFAULT_MAX_UDPSIZE; @@ -820,11 +820,10 @@ void AuthSrvImpl::resumeServer(DNSServer* server, Message& message, const bool done) { if (done) { - stats_attrs_.answerWasSent(); // isTruncated from MessageRenderer stats_attrs_.setResponseTruncated(renderer_.isTruncated()); } - counters_.inc(stats_attrs_, message); + counters_.inc(stats_attrs_, message, done); stats_attrs_.reset(); server->resume(done); } diff --git a/src/bin/auth/statistics.cc.pre b/src/bin/auth/statistics.cc.pre index e63f35d6e7..aa919201ee 100644 --- a/src/bin/auth/statistics.cc.pre +++ b/src/bin/auth/statistics.cc.pre @@ -238,11 +238,13 @@ Counters::incResponse(const QRAttributes& qrattrs, const Message& response) { } void -Counters::inc(const QRAttributes& qrattrs, const Message& response) { +Counters::inc(const QRAttributes& qrattrs, const Message& response, + const bool done) +{ // increment request counters incRequest(qrattrs); - if (qrattrs.answer_sent_) { + if (done) { // increment response counters if answer was sent incResponse(qrattrs, response); } diff --git a/src/bin/auth/statistics.h b/src/bin/auth/statistics.h index d6ac181a4f..054d30bf85 100644 --- a/src/bin/auth/statistics.h +++ b/src/bin/auth/statistics.h @@ -101,10 +101,6 @@ public: /// \throw None inline void setOrigin(const std::string& origin); - /// \brief Set if the answer has sent. - /// \throw None - inline void answerWasSent(); - /// \brief Set if the response is truncated. /// \throw None inline void setResponseTruncated(const bool is_truncated); @@ -163,11 +159,6 @@ QRAttributes::setQuerySig(const bool is_tsig, const bool is_sig0, req_is_badsig_ = is_badsig; } -inline void -QRAttributes::answerWasSent() { - answer_sent_ = true; -} - inline void QRAttributes::setResponseTruncated(const bool is_truncated) { res_is_truncated_ = is_truncated; @@ -256,10 +247,12 @@ public: /// /// \param qrattrs Query/Response attributes. /// \param response DNS response message. + /// \param done DNS response was sent to the client. /// /// \throw std::bad_alloc Internal resource allocation fails /// - void inc(const QRAttributes& qrattrs, const isc::dns::Message& response); + void inc(const QRAttributes& qrattrs, const isc::dns::Message& response, + const bool done); /// \brief Get statistics counters. /// diff --git a/src/bin/auth/tests/statistics_unittest.cc.pre b/src/bin/auth/tests/statistics_unittest.cc.pre index 1e04de2a75..8bf68b3fbd 100644 --- a/src/bin/auth/tests/statistics_unittest.cc.pre +++ b/src/bin/auth/tests/statistics_unittest.cc.pre @@ -113,13 +113,12 @@ TEST_F(CountersTest, incrementNormalQuery) { qrattrs.setQueryOpCode(Opcode::QUERY_CODE); qrattrs.setQueryEDNS(true, false); qrattrs.setQueryDO(true); - qrattrs.answerWasSent(); response.setRcode(Rcode::REFUSED()); response.addQuestion(Question(Name("example.com"), RRClass::IN(), RRType::AAAA())); - counters.inc(qrattrs, response); + counters.inc(qrattrs, response, true); expect_nonzero.clear(); expect_nonzero.insert("opcode.query");