BIND 10 trac2156, updated. 40e62a2bed6e81c02c5965bea6165ad803956ad7 [2156] fixed SOCKET_OPEN_ERROR, SEND_DATA_ERROR, READ_DATA_ERROR, UNKNOWN_ORIGIN [2156] class name change in socketstatistics_unittest [2156] added some comments

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Aug 24 11:17:22 UTC 2012


The branch, trac2156 has been updated
       via  40e62a2bed6e81c02c5965bea6165ad803956ad7 (commit)
      from  239990eda9af74ec251311820e0350a6fa6d848b (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 40e62a2bed6e81c02c5965bea6165ad803956ad7
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date:   Fri Aug 24 20:13:59 2012 +0900

    [2156] fixed SOCKET_OPEN_ERROR,SEND_DATA_ERROR,READ_DATA_ERROR,UNKNOWN_ORIGIN
    [2156] class name change in socketstatistics_unittest
    [2156] added some comments

-----------------------------------------------------------------------

Summary of changes:
 src/bin/auth/statistics.cc                         |    6 +++--
 src/lib/asiodns/io_fetch.cc                        |   10 +++++++-
 src/lib/asiodns/io_fetch.h                         |    2 ++
 src/lib/asiodns/sync_udp_server.h                  |    1 +
 src/lib/asiodns/tcp_server.h                       |    1 +
 src/lib/asiodns/tests/socketstatistics_unittest.cc |   24 ++++++++++----------
 src/lib/asiodns/udp_server.h                       |    1 +
 7 files changed, 30 insertions(+), 15 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/statistics.cc b/src/bin/auth/statistics.cc
index 4157880..65d025c 100644
--- a/src/bin/auth/statistics.cc
+++ b/src/bin/auth/statistics.cc
@@ -303,9 +303,9 @@ CountersImpl::get(const Counters::item_node_name_set_type &trees) const {
             fillNodes(server_qr_counter_, QRCounterItemName, QR_COUNTER_TYPES,
                       "auth.server.qr.", item_tree);
         } else if (node == "auth.server.socket") {
-            // currently not implemented
             fillNodes(isc::asiodns::SocketCounter, SocketCounterItemName,
-                      SOCKET_ASIODNS_COUNTER_TYPES, "auth.server.socket.", item_tree);
+                      SOCKET_ASIODNS_COUNTER_TYPES, "auth.server.socket.",
+                      item_tree);
         } else if (node == "auth.zones") {
             // currently not implemented
         } else {
@@ -325,6 +325,8 @@ CountersImpl::dump() const {
 
     fillNodes(server_qr_counter_, QRCounterItemName, QR_COUNTER_TYPES,
               "auth.server.qr.", item_tree);
+    fillNodes(isc::asiodns::SocketCounter, SocketCounterItemName,
+              SOCKET_ASIODNS_COUNTER_TYPES, "auth.server.socket.", item_tree);
 
     return (item_tree);
 }
diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc
index 74ca441..a91cd1d 100644
--- a/src/lib/asiodns/io_fetch.cc
+++ b/src/lib/asiodns/io_fetch.cc
@@ -416,7 +416,15 @@ void IOFetch::logIOFailure(asio::error_code ec) {
            (data_->origin == ASIODNS_UNKNOWN_ORIGIN));
 
     static const char* PROTOCOL[2] = {"TCP", "UDP"};
-    isc::asiodns::SocketCounter.inc(SOCKET_ASIODNS_UNKNOWN_RESULT);
+    if (data_->origin == ASIODNS_OPEN_SOCKET) {
+        isc::asiodns::SocketCounter.inc(SOCKET_ASIODNS_SOCKET_OPEN_ERROR);
+    } else if (data_->origin == ASIODNS_SEND_DATA) {
+        isc::asiodns::SocketCounter.inc(SOCKET_ASIODNS_SEND_DATA_ERROR);
+    } else if (data_->origin == ASIODNS_READ_DATA) {
+        isc::asiodns::SocketCounter.inc(SOCKET_ASIODNS_READ_DATA_ERROR);
+    } else if (data_->origin == ASIODNS_UNKNOWN_ORIGIN) {
+        isc::asiodns::SocketCounter.inc(SOCKET_ASIODNS_UNKNOWN_ORIGIN);
+    }
     LOG_ERROR(logger, data_->origin).arg(ec.value()).
         arg((data_->remote_snd->getProtocol() == IPPROTO_TCP) ?
                      PROTOCOL[0] : PROTOCOL[1]).
diff --git a/src/lib/asiodns/io_fetch.h b/src/lib/asiodns/io_fetch.h
index 78c2da9..a90a61f 100644
--- a/src/lib/asiodns/io_fetch.h
+++ b/src/lib/asiodns/io_fetch.h
@@ -197,6 +197,7 @@ public:
     ///
     /// This method can be called at any point.  It terminates the current
     /// query with the specified reason.
+    /// This method changes isc::asiodns::SocketCounter.
     ///
     /// \param reason Reason for terminating the query
     void stop(Result reason = STOPPED);
@@ -215,6 +216,7 @@ private:
     /// \brief Log I/O Failure
     ///
     /// Records an I/O failure to the log file
+    /// This method changes isc::asiodns::SocketCounter.
     ///
     /// \param ec ASIO error code
     void logIOFailure(asio::error_code ec);
diff --git a/src/lib/asiodns/sync_udp_server.h b/src/lib/asiodns/sync_udp_server.h
index 9718422..6ccd423 100644
--- a/src/lib/asiodns/sync_udp_server.h
+++ b/src/lib/asiodns/sync_udp_server.h
@@ -49,6 +49,7 @@ public:
     /// \param checkin the callbackprovider for non-DNS events
     /// \param lookup the callbackprovider for DNS lookup events
     /// \param answer the callbackprovider for DNS answer events
+    /// This method changes isc::asiodns::SocketCounter.
     /// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6
     /// \throw isc::asiolink::IOError when a low-level error happens, like the
     ///     fd is not a valid descriptor.
diff --git a/src/lib/asiodns/tcp_server.h b/src/lib/asiodns/tcp_server.h
index 01695e4..52cc1f6 100644
--- a/src/lib/asiodns/tcp_server.h
+++ b/src/lib/asiodns/tcp_server.h
@@ -44,6 +44,7 @@ public:
     /// \param checkin the callbackprovider for non-DNS events
     /// \param lookup the callbackprovider for DNS lookup events
     /// \param answer the callbackprovider for DNS answer events
+    /// This method changes isc::asiodns::SocketCounter.
     /// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6
     /// \throw isc::asiolink::IOError when a low-level error happens, like the
     ///     fd is not a valid descriptor or it can't be listened on.
diff --git a/src/lib/asiodns/tests/socketstatistics_unittest.cc b/src/lib/asiodns/tests/socketstatistics_unittest.cc
index bae9b72..69f6577 100644
--- a/src/lib/asiodns/tests/socketstatistics_unittest.cc
+++ b/src/lib/asiodns/tests/socketstatistics_unittest.cc
@@ -62,7 +62,7 @@ const size_t MAX_SIZE = 64 * 1024;  // Should be able to take 64kB
 const bool DEBUG = false;
 
 /// \brief Test fixture for the asiolink::IOFetch.
-class IOFetchTest2 : public virtual ::testing::Test, public virtual IOFetch::Callback
+class StatisticsIOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Callback
 {
 public:
     IOService       service_;       ///< Service to run the query
@@ -97,7 +97,7 @@ public:
                                             ///  all data in the tcp response
 
     /// \brief Constructor
-    IOFetchTest2() :
+    StatisticsIOFetchTest() :
         service_(),
         expected_(IOFetch::NOTSET),
         run_(false),
@@ -252,7 +252,7 @@ public:
         // Initiate a read on the socket.
         cumulative_ = 0;
         socket->async_receive(asio::buffer(receive_buffer_, sizeof(receive_buffer_)),
-            boost::bind(&IOFetchTest2::tcpReceiveHandler, this, socket, _1, _2));
+            boost::bind(&StatisticsIOFetchTest::tcpReceiveHandler, this, socket, _1, _2));
     }
 
     /// \brief Completion handler for receiving TCP data
@@ -288,7 +288,7 @@ public:
         if (!complete) {
             socket->async_receive(asio::buffer((receive_buffer_ + cumulative_),
                 (sizeof(receive_buffer_) - cumulative_)),
-                boost::bind(&IOFetchTest2::tcpReceiveHandler, this, socket, _1, _2));
+                boost::bind(&StatisticsIOFetchTest::tcpReceiveHandler, this, socket, _1, _2));
             return;
         }
 
@@ -373,7 +373,7 @@ public:
         // ... and send it.  The amount sent is also passed as the first
         // argument of the send callback, as a check.
         socket->async_send(asio::buffer(send_ptr, amount),
-                           boost::bind(&IOFetchTest2::tcpSendHandler, this,
+                           boost::bind(&StatisticsIOFetchTest::tcpSendHandler, this,
                                        amount, socket, _1, _2));
     }
 
@@ -416,7 +416,7 @@ public:
             // socket over which data should be sent as an argument to that
             // function.
             timer_.expires_from_now(boost::posix_time::milliseconds(SEND_INTERVAL));
-            timer_.async_wait(boost::bind(&IOFetchTest2::tcpSendData, this,
+            timer_.async_wait(boost::bind(&StatisticsIOFetchTest::tcpSendData, this,
                                           socket));
         }
     }
@@ -556,7 +556,7 @@ public:
         tcp::acceptor acceptor(service_.get_io_service(),
                                tcp::endpoint(tcp::v4(), TEST_PORT));
         acceptor.async_accept(socket,
-            boost::bind(&IOFetchTest2::tcpAcceptHandler, this, &socket, _1));
+            boost::bind(&StatisticsIOFetchTest::tcpAcceptHandler, this, &socket, _1));
 
         // Post the TCP fetch object to send the query and receive the response.
         service_.get_io_service().post(tcp_fetch_);
@@ -590,7 +590,7 @@ public:
         socket.async_receive_from(asio::buffer(receive_buffer_,
                                                sizeof(receive_buffer_)),
                                   remote,
-                                  boost::bind(&IOFetchTest2::udpReceiveHandler,
+                                  boost::bind(&StatisticsIOFetchTest::udpReceiveHandler,
                                               this, &remote, &socket,
                                               _1, _2, bad_qid, second_send));
         service_.get_io_service().post(udp_fetch_);
@@ -619,8 +619,8 @@ TEST(StatisticsItemsTest, SocketItemNamesCheck) {
               "asiodns_unknown_result");
 }
 
-// UDP Stop test - see IOFetchTest2::stopTest() header.
-TEST_F(IOFetchTest2, UdpStop) {
+// UDP Stop test - see StatisticsIOFetchTest::stopTest() header.
+TEST_F(StatisticsIOFetchTest, UdpStop) {
     int a = isc::asiodns::SocketCounter.get(SOCKET_ASIODNS_FETCH_STOPPED);
     stopTest(IOFetch::UDP, udp_fetch_);
     int b = isc::asiodns::SocketCounter.get(SOCKET_ASIODNS_FETCH_STOPPED);
@@ -629,14 +629,14 @@ TEST_F(IOFetchTest2, UdpStop) {
 
 // Do the same tests for TCP transport
 
-TEST_F(IOFetchTest2, TcpStop) {
+TEST_F(StatisticsIOFetchTest, TcpStop) {
     int a = isc::asiodns::SocketCounter.get(SOCKET_ASIODNS_FETCH_STOPPED);
     stopTest(IOFetch::TCP, tcp_fetch_);
     int b = isc::asiodns::SocketCounter.get(SOCKET_ASIODNS_FETCH_STOPPED);
     EXPECT_EQ(a+1, b);
 }
 
-TEST_F(IOFetchTest2, TcpTimeout) {
+TEST_F(StatisticsIOFetchTest, TcpTimeout) {
     int a = isc::asiodns::SocketCounter.get(SOCKET_ASIODNS_READ_TIMEOUT);
     timeoutTest(IOFetch::TCP, tcp_fetch_);
     int b = isc::asiodns::SocketCounter.get(SOCKET_ASIODNS_READ_TIMEOUT);
diff --git a/src/lib/asiodns/udp_server.h b/src/lib/asiodns/udp_server.h
index b32c06c..9d4c2e3 100644
--- a/src/lib/asiodns/udp_server.h
+++ b/src/lib/asiodns/udp_server.h
@@ -46,6 +46,7 @@ public:
     /// \param checkin the callbackprovider for non-DNS events
     /// \param lookup the callbackprovider for DNS lookup events
     /// \param answer the callbackprovider for DNS answer events
+    /// This method changes isc::asiodns::SocketCounter.
     /// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6
     /// \throw isc::asiolink::IOError when a low-level error happens, like the
     ///     fd is not a valid descriptor.



More information about the bind10-changes mailing list