BIND 10 trac2156, updated. 60bed733ea6601cfc58f7ccb32d2a88da2cd2c18 [2156] Moved global socket statistics counters into io_service class

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Oct 23 10:37:33 UTC 2012


The branch, trac2156 has been updated
       via  60bed733ea6601cfc58f7ccb32d2a88da2cd2c18 (commit)
      from  82d02f9824ef2cd4e292392050514bb7da8c959b (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 60bed733ea6601cfc58f7ccb32d2a88da2cd2c18
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date:   Tue Oct 23 10:34:48 2012 +0900

    [2156] Moved global socket statistics counters into io_service class

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

Summary of changes:
 src/lib/asiodns/socketstatistics.h                |   60 ---------------------
 src/lib/asiolink/Makefile.am                      |    1 +
 src/lib/asiolink/io_service.cc                    |   22 +++++++-
 src/lib/asiolink/io_service.h                     |   14 +++++
 src/lib/{asiodns => asiolink}/socketstatistics.cc |    7 +--
 src/lib/asiolink/socketstatistics.h               |   58 ++++++++++++++++++++
 6 files changed, 96 insertions(+), 66 deletions(-)
 delete mode 100644 src/lib/asiodns/socketstatistics.h
 rename src/lib/{asiodns => asiolink}/socketstatistics.cc (87%)
 create mode 100644 src/lib/asiolink/socketstatistics.h

-----------------------------------------------------------------------
diff --git a/src/lib/asiodns/socketstatistics.cc b/src/lib/asiodns/socketstatistics.cc
deleted file mode 100644
index 82555ce..0000000
--- a/src/lib/asiodns/socketstatistics.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <statistics/counter.h>
-#include <asiodns/socketstatistics.h>
-
-namespace isc {
-namespace asiodns {
-
-// Global SocketCounter
-isc::statistics::Counter SocketCounter(SOCKET_ASIODNS_COUNTER_TYPES);
-
-// item names for socket statistics
-const std::string SocketCounterItemName[SOCKET_ASIODNS_COUNTER_TYPES] = {
-    "asiodns_fd_add_tcp",
-    "asiodns_fd_add_udp",
-    "asiodns_fetch_completed",
-    "asiodns_fetch_stopped",
-    "asiodns_socket_open_error",
-    "asiodns_read_data_error",
-    "asiodns_read_timeout",
-    "asiodns_send_data_error",
-    "asiodns_unknown_origin",
-    "asiodns_unknown_result",
-    "asiodns.ipv4.tcp.accept",
-    "asiodns.ipv6.tcp.accept",
-    "asiodns.ipv4.tcp.acceptfail",
-    "asiodns.ipv6.tcp.acceptfail",
-    "asiodns.tcp.open",
-};
-
-}   // namespace asiodns
-}   // namespace isc
diff --git a/src/lib/asiodns/socketstatistics.h b/src/lib/asiodns/socketstatistics.h
deleted file mode 100644
index 393915f..0000000
--- a/src/lib/asiodns/socketstatistics.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef __SOCKETSTATISTICS_H
-#define __SOCKETSTATISTICS_H 1
-
-#include <string>
-#include <statistics/counter.h>
-
-namespace isc {
-namespace asiodns {
-
-// enum for socket statistics
-enum SocketCounterType {
-    // Socket statistics
-    SOCKET_ASIODNS_FD_ADD_TCP,         ///< adding a new TCP server
-    SOCKET_ASIODNS_FD_ADD_UDP,         ///< adding a new UDP server
-    SOCKET_ASIODNS_FETCH_COMPLETED,    ///< upstream fetch has now completed
-    SOCKET_ASIODNS_FETCH_STOPPED,      ///< upstream fetch has been stopped
-    SOCKET_ASIODNS_SOCKET_OPEN_ERROR,  ///< error opening socket
-    SOCKET_ASIODNS_READ_DATA_ERROR,    ///< error reading data
-    SOCKET_ASIODNS_READ_TIMEOUT,       ///< receive timeout
-    SOCKET_ASIODNS_SEND_DATA_ERROR,    ///< error sending data
-    SOCKET_ASIODNS_UNKNOWN_ORIGIN,     ///< unknown origin for ASIO error
-    SOCKET_ASIODNS_UNKNOWN_RESULT,     ///< unknown result
-    SOCKET_ASIODNS_IPV4_TCP_ACCEPT,    ///< number of IPv4 TCP accept
-    SOCKET_ASIODNS_IPV6_TCP_ACCEPT,    ///< number of IPv6 TCP accept
-    SOCKET_ASIODNS_IPV4_TCP_ACCEPTFAIL, ///< number of IPv4 TCP acceptfail
-    SOCKET_ASIODNS_IPV6_TCP_ACCEPTFAIL, ///< number of IPv6 TCP acceptfail
-    SOCKET_ASIODNS_TCP_OPEN,           /// number of TCP OPEN
-    SOCKET_ASIODNS_COUNTER_TYPES       ///< The number of defined counters
-};
-
-// Global SocketCounter
-extern isc::statistics::Counter SocketCounter;
-extern const std::string SocketCounterItemName[SOCKET_ASIODNS_COUNTER_TYPES];
-
-/// This file defines a set of statistics items in Auth module for internal
-/// use. This file is intended to be included in statistics.cc.
-
-}   // namespace statistics
-}   // namespace isc
-
-#endif // __SOCKETSTATISTICS_H
-
-// Local Variables:
-// mode: c++
-// End:
-
diff --git a/src/lib/asiolink/Makefile.am b/src/lib/asiolink/Makefile.am
index 3505982..913daea 100644
--- a/src/lib/asiolink/Makefile.am
+++ b/src/lib/asiolink/Makefile.am
@@ -20,6 +20,7 @@ libb10_asiolink_la_LDFLAGS = -no-undefined -version-info 1:0:1
 libb10_asiolink_la_SOURCES  = asiolink.h
 libb10_asiolink_la_SOURCES += dummy_io_cb.h
 libb10_asiolink_la_SOURCES += interval_timer.cc interval_timer.h
+libb10_asiolink_la_SOURCES += socketstatistics.cc socketstatistics.h
 libb10_asiolink_la_SOURCES += io_address.cc io_address.h
 libb10_asiolink_la_SOURCES += io_asio_socket.h
 libb10_asiolink_la_SOURCES += io_endpoint.cc io_endpoint.h
diff --git a/src/lib/asiolink/io_service.cc b/src/lib/asiolink/io_service.cc
index 15fad0c..47257c2 100644
--- a/src/lib/asiolink/io_service.cc
+++ b/src/lib/asiolink/io_service.cc
@@ -20,6 +20,8 @@
 
 #include <asio.hpp>
 #include <asiolink/io_service.h>
+#include <statistics/counter.h>
+#include <asiolink/socketstatistics.h>
 
 namespace isc {
 namespace asiolink {
@@ -32,7 +34,8 @@ public:
     /// \brief The constructor
     IOServiceImpl() :
         io_service_(),
-        work_(io_service_)
+        work_(io_service_),
+	socket_counter_(isc::statistics::SOCKET_ASIOLINK_COUNTER_TYPES)
     {};
     /// \brief The destructor.
     ~IOServiceImpl() {};
@@ -56,6 +59,12 @@ public:
     /// This will return the control to the caller of the \c run() method.
     void stop() { io_service_.stop();} ;
 
+    void socket_counter_inc(isc::statistics::Counter::Type type) {
+        socket_counter_.inc(type);
+    }
+    const isc::statistics::Counter::Value& socket_counter_get(isc::statistics::Counter::Type type) {
+        return socket_counter_.get(type);
+    }
     /// \brief Return the native \c io_service object used in this wrapper.
     ///
     /// This is a short term work around to support other BIND 10 modules
@@ -66,6 +75,7 @@ public:
 private:
     asio::io_service io_service_;
     asio::io_service::work work_;
+    isc::statistics::Counter socket_counter_;
 };
 
 IOService::IOService() {
@@ -91,6 +101,16 @@ IOService::stop() {
     io_impl_->stop();
 }
 
+void
+IOService::socket_counter_inc(isc::statistics::Counter::Counter::Type type) {
+    io_impl_->socket_counter_inc(type);
+}
+
+const isc::statistics::Counter::Counter::Value&
+IOService::socket_counter_get(isc::statistics::Counter::Counter::Type type) const {
+    return io_impl_->socket_counter_get(type);
+}
+
 asio::io_service&
 IOService::get_io_service() {
     return (io_impl_->get_io_service());
diff --git a/src/lib/asiolink/io_service.h b/src/lib/asiolink/io_service.h
index 75aaee6..4e41ebd 100644
--- a/src/lib/asiolink/io_service.h
+++ b/src/lib/asiolink/io_service.h
@@ -15,6 +15,9 @@
 #ifndef __ASIOLINK_IO_SERVICE_H
 #define __ASIOLINK_IO_SERVICE_H 1
 
+#include <statistics/counter.h>
+#include <asiolink/socketstatistics.h>
+
 namespace asio {
     class io_service;
 }
@@ -70,6 +73,17 @@ public:
     /// generalized.
     asio::io_service& get_io_service();
 
+    /// \brief Return value of one of socket statistics counters.
+    ///
+    /// This method returns a value of one of socket statistics counters.
+    const isc::statistics::Counter::Value&
+        socket_counter_get(isc::statistics::Counter::Type) const;
+
+    /// \brief Increment a socket statistics counter.
+    ///
+    /// This method increment one of socket statistics counters.
+    void socket_counter_inc(isc::statistics::Counter::Type);
+
 private:
     IOServiceImpl* io_impl_;
 };
diff --git a/src/lib/asiolink/socketstatistics.cc b/src/lib/asiolink/socketstatistics.cc
new file mode 100644
index 0000000..6c9bf0a
--- /dev/null
+++ b/src/lib/asiolink/socketstatistics.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <statistics/counter.h>
+#include <asiolink/socketstatistics.h>
+
+namespace isc {
+namespace asiodns {
+
+// item names for socket statistics
+const std::string SocketCounterItemName[] = {
+    "asiodns_fd_add_tcp",
+    "asiodns_fd_add_udp",
+    "asiodns_fetch_completed",
+    "asiodns_fetch_stopped",
+    "asiodns_socket_open_error",
+    "asiodns_read_data_error",
+    "asiodns_read_timeout",
+    "asiodns_send_data_error",
+    "asiodns_unknown_origin",
+    "asiodns_unknown_result",
+    "asiodns.ipv4.tcp.accept",
+    "asiodns.ipv6.tcp.accept",
+    "asiodns.ipv4.tcp.acceptfail",
+    "asiodns.ipv6.tcp.acceptfail",
+    "asiodns.tcp.open",
+};
+
+}   // namespace asiodns
+}   // namespace isc
diff --git a/src/lib/asiolink/socketstatistics.h b/src/lib/asiolink/socketstatistics.h
new file mode 100644
index 0000000..cc2d34f
--- /dev/null
+++ b/src/lib/asiolink/socketstatistics.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __SOCKETSTATISTICS_H
+#define __SOCKETSTATISTICS_H 1
+
+#include <string>
+
+namespace isc {
+namespace statistics {
+
+// enum for socket statistics
+enum SocketCounterType {
+    // Socket statistics
+    SOCKET_ASIOLINK_FD_ADD_TCP,         ///< adding a new TCP server
+    SOCKET_ASIOLINK_FD_ADD_UDP,         ///< adding a new UDP server
+    SOCKET_ASIOLINK_FETCH_COMPLETED,    ///< upstream fetch has now completed
+    SOCKET_ASIOLINK_FETCH_STOPPED,      ///< upstream fetch has been stopped
+    SOCKET_ASIOLINK_SOCKET_OPEN_ERROR,  ///< error opening socket
+    SOCKET_ASIOLINK_READ_DATA_ERROR,    ///< error reading data
+    SOCKET_ASIOLINK_READ_TIMEOUT,       ///< receive timeout
+    SOCKET_ASIOLINK_SEND_DATA_ERROR,    ///< error sending data
+    SOCKET_ASIOLINK_UNKNOWN_ORIGIN,     ///< unknown origin for ASIO error
+    SOCKET_ASIOLINK_UNKNOWN_RESULT,     ///< unknown result
+    SOCKET_ASIOLINK_IPV4_TCP_ACCEPT,    ///< number of IPv4 TCP accept
+    SOCKET_ASIOLINK_IPV6_TCP_ACCEPT,    ///< number of IPv6 TCP accept
+    SOCKET_ASIOLINK_IPV4_TCP_ACCEPTFAIL, ///< number of IPv4 TCP acceptfail
+    SOCKET_ASIOLINK_IPV6_TCP_ACCEPTFAIL, ///< number of IPv6 TCP acceptfail
+    SOCKET_ASIOLINK_TCP_OPEN,           /// number of TCP OPEN
+    SOCKET_ASIOLINK_COUNTER_TYPES       ///< The number of defined counters
+};
+
+// Global SocketCounter
+extern const std::string SocketCounterItemName[SOCKET_ASIOLINK_COUNTER_TYPES];
+
+/// This file defines a set of statistics items in Auth module for internal
+/// use. This file is intended to be included in statistics.cc.
+
+}   // namespace statistics
+}   // namespace isc
+
+#endif // __SOCKETSTATISTICS_H
+
+// Local Variables:
+// mode: c++
+// End:
+



More information about the bind10-changes mailing list