Parcourir la source

Move asio_link.cc and associated files from src/bin/auth into a new library,
src/lib/asiolink. No changes to the code itself have been made except for
the purely cosmetic one of changing the namespace and filenames from
"asio_link" to "asiolink".

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac327@2953 e5f2f494-b856-4b98-b285-d166d9295462

Evan Hunt il y a 14 ans
Parent
commit
6b2895175e

+ 2 - 0
configure.ac

@@ -431,6 +431,8 @@ AC_CONFIG_FILES([Makefile
                  src/bin/zonemgr/tests/Makefile
                  src/bin/usermgr/Makefile
                  src/lib/Makefile
+                 src/lib/asiolink/Makefile
+                 src/lib/asiolink/tests/Makefile
                  src/lib/bench/Makefile
                  src/lib/bench/example/Makefile
                  src/lib/bench/tests/Makefile

+ 4 - 19
src/bin/auth/Makefile.am

@@ -3,8 +3,9 @@ SUBDIRS = . tests
 AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
 AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
-AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
-AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/cc -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/asiolink
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/asiolink
 
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 
@@ -32,22 +33,6 @@ auth.spec: auth.spec.pre
 spec_config.h: spec_config.h.pre
 	$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@
 
-# This is a wrapper library solely used for b10-auth.  The ASIO header files
-# have some code fragments that would hit gcc's unused-parameter warning,
-# which would make the build fail with -Werror (our default setting).
-# We don't want to lower the warning level for our own code just for ASIO,
-# so as a workaround we extract the ASIO related code into a separate library,
-# only for which we accept the unused-parameter warning.
-lib_LIBRARIES = libasio_link.a
-libasio_link_a_SOURCES = asio_link.cc asio_link.h
-# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
-# B10_CXXFLAGS)
-libasio_link_a_CXXFLAGS = $(AM_CXXFLAGS)
-if USE_GXX
-libasio_link_a_CXXFLAGS += -Wno-unused-parameter
-endif
-libasio_link_a_CPPFLAGS = $(AM_CPPFLAGS)
-
 BUILT_SOURCES = spec_config.h 
 pkglibexec_PROGRAMS = b10-auth
 b10_auth_SOURCES = auth_srv.cc auth_srv.h
@@ -59,7 +44,7 @@ b10_auth_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
 b10_auth_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
 b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
-b10_auth_LDADD += libasio_link.a
+b10_auth_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.a
 b10_auth_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
 b10_auth_LDADD += $(SQLITE_LIBS)
 

+ 11 - 11
src/bin/auth/auth_srv.cc

@@ -21,6 +21,12 @@
 #include <iostream>
 #include <vector>
 
+#include <asiolink/asiolink.h>
+
+#include <config/ccsession.h>
+
+#include <cc/data.h>
+
 #include <exceptions/exceptions.h>
 
 #include <dns/buffer.h>
@@ -31,22 +37,16 @@
 #include <dns/rrset.h>
 #include <dns/rrttl.h>
 #include <dns/message.h>
-#include <config/ccsession.h>
-#include <cc/data.h>
-#include <exceptions/exceptions.h>
 
 #include <datasrc/query.h>
 #include <datasrc/data_source.h>
 #include <datasrc/static_datasrc.h>
 #include <datasrc/sqlite3_datasrc.h>
 
-#include <cc/data.h>
-
 #include <xfr/xfrout_client.h>
 
 #include <auth/common.h>
 #include <auth/auth_srv.h>
-#include <auth/asio_link.h>
 
 using namespace std;
 
@@ -58,7 +58,7 @@ using namespace isc::dns::rdata;
 using namespace isc::data;
 using namespace isc::config;
 using namespace isc::xfr;
-using namespace asio_link;
+using namespace asiolink;
 
 class AuthSrvImpl {
 private:
@@ -124,7 +124,7 @@ AuthSrvImpl::~AuthSrvImpl() {
 }
 
 // This is a derived class of \c DNSProvider, to serve as a
-// callback in the asio_link module.  It calls
+// callback in the asiolink module.  It calls
 // AuthSrv::processMessage() on a single DNS message.
 class MessageProcessor : public DNSProvider {
 public:
@@ -139,7 +139,7 @@ private:
 };
 
 // This is a derived class of \c CheckinProvider, to serve
-// as a callback in the asio_link module.  It checks for queued
+// as a callback in the asiolink module.  It checks for queued
 // configuration messages, and executes them if found.
 class ConfigChecker : public CheckinProvider {
 public:
@@ -165,12 +165,12 @@ AuthSrv::~AuthSrv() {
     delete dns_provider_;
 }
 
-asio_link::CheckinProvider*
+asiolink::CheckinProvider*
 AuthSrv::getCheckinProvider() {
     return (checkin_provider_);
 }
 
-asio_link::DNSProvider*
+asiolink::DNSProvider*
 AuthSrv::getDNSProvider() {
     return (dns_provider_);
 }

+ 7 - 7
src/bin/auth/auth_srv.h

@@ -22,7 +22,7 @@
 #include <cc/data.h>
 #include <config/ccsession.h>
 
-#include <auth/asio_link.h>
+#include <asiolink/asiolink.h>
 
 namespace isc {
 namespace dns {
@@ -36,7 +36,7 @@ class AbstractXfroutClient;
 };
 }
 
-namespace asio_link {
+namespace asiolink {
 class IOMessage;
 }
 
@@ -66,7 +66,7 @@ public:
     //@}
     /// \return \c true if the \message contains a response to be returned;
     /// otherwise \c false.
-    bool processMessage(const asio_link::IOMessage& io_message,
+    bool processMessage(const asiolink::IOMessage& io_message,
                         isc::dns::Message& message,
                         isc::dns::MessageRenderer& response_renderer);
     void setVerbose(bool on);
@@ -74,8 +74,8 @@ public:
     isc::data::ConstElementPtr updateConfig(isc::data::ConstElementPtr config);
     isc::config::ModuleCCSession* configSession() const;
     void setConfigSession(isc::config::ModuleCCSession* config_session);
-    asio_link::CheckinProvider* getCheckinProvider();
-    asio_link::DNSProvider* getDNSProvider();
+    asiolink::CheckinProvider* getCheckinProvider();
+    asiolink::DNSProvider* getDNSProvider();
 
     ///
     /// Note: this interface is tentative.  We'll revisit the ASIO and session
@@ -93,8 +93,8 @@ public:
     void setXfrinSession(isc::cc::AbstractSession* xfrin_session);
 private:
     AuthSrvImpl* impl_;
-    asio_link::CheckinProvider* checkin_provider_;
-    asio_link::DNSProvider* dns_provider_;
+    asiolink::CheckinProvider* checkin_provider_;
+    asiolink::DNSProvider* dns_provider_;
 };
 
 #endif // __AUTH_SRV_H

+ 10 - 10
src/bin/auth/main.cc

@@ -43,7 +43,7 @@
 #include <auth/common.h>
 #include <auth/change_user.h>
 #include <auth/auth_srv.h>
-#include <auth/asio_link.h>
+#include <asiolink/asiolink.h>
 
 using namespace std;
 using namespace isc::data;
@@ -64,7 +64,7 @@ const char* DNSPORT = "5300";
  * class itself? */
 AuthSrv *auth_server;
 
-asio_link::IOService* io_service;
+asiolink::IOService* io_service;
 
 ConstElementPtr
 my_config_handler(ConstElementPtr new_config) {
@@ -176,8 +176,8 @@ main(int argc, char* argv[]) {
         auth_server->setVerbose(verbose_mode);
         cout << "[b10-auth] Server created." << endl;
 
-        asio_link::CheckinProvider* checkin = auth_server->getCheckinProvider();
-        asio_link::DNSProvider* process = auth_server->getDNSProvider();
+        asiolink::CheckinProvider* checkin = auth_server->getCheckinProvider();
+        asiolink::DNSProvider* process = auth_server->getDNSProvider();
 
         if (address != NULL) {
             // XXX: we can only specify at most one explicit address.
@@ -186,11 +186,11 @@ main(int argc, char* argv[]) {
             // We don't bother to fix this problem, however.  The -a option
             // is a short term workaround until we support dynamic listening
             // port allocation.
-            io_service = new asio_link::IOService(*port, *address,
-                                                  checkin, process);
+            io_service = new asiolink::IOService(*port, *address,
+                                                 checkin, process);
         } else {
-            io_service = new asio_link::IOService(*port, use_ipv4, use_ipv6,
-                                                  checkin, process);
+            io_service = new asiolink::IOService(*port, use_ipv4, use_ipv6,
+                                                 checkin, process);
         }
         cout << "[b10-auth] IOService created." << endl;
 
@@ -212,9 +212,9 @@ main(int argc, char* argv[]) {
         xfrin_session_established = true;
         cout << "[b10-auth] Xfrin session channel established." << endl;
 
-        // XXX: with the current interface to asio_link we have to create
+        // XXX: with the current interface to asiolink we have to create
         // auth_server before io_service while Session needs io_service.
-        // In a next step of refactoring we should make asio_link independent
+        // In a next step of refactoring we should make asiolink independent
         // from auth_server, and create io_service, auth_server, and
         // sessions in that order.
         auth_server->setXfrinSession(xfrin_session);

+ 1 - 2
src/bin/auth/tests/Makefile.am

@@ -20,7 +20,6 @@ run_unittests_SOURCES += ../auth_srv.h ../auth_srv.cc
 run_unittests_SOURCES += ../change_user.h ../change_user.cc
 run_unittests_SOURCES += auth_srv_unittest.cc
 run_unittests_SOURCES += change_user_unittest.cc
-run_unittests_SOURCES += asio_link_unittest.cc
 run_unittests_SOURCES += run_unittests.cc
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
@@ -28,10 +27,10 @@ run_unittests_LDADD = $(GTEST_LDADD)
 run_unittests_LDADD += $(SQLITE_LIBS)
 run_unittests_LDADD +=  $(top_builddir)/src/lib/datasrc/libdatasrc.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/dns/libdns++.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
 run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
-run_unittests_LDADD += $(top_builddir)/src/bin/auth/libasio_link.a
 run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
 endif
 

+ 2 - 2
src/bin/auth/tests/auth_srv_unittest.cc

@@ -31,7 +31,7 @@
 #include <xfr/xfrout_client.h>
 
 #include <auth/auth_srv.h>
-#include <auth/asio_link.h>
+#include <asiolink/asiolink.h>
 
 #include <dns/tests/unittest_util.h>
 
@@ -41,7 +41,7 @@ using namespace isc::cc;
 using namespace isc::dns;
 using namespace isc::data;
 using namespace isc::xfr;
-using namespace asio_link;
+using namespace asiolink;
 
 namespace {
 const char* const CONFIG_TESTDB =

+ 1 - 1
src/lib/Makefile.am

@@ -1 +1 @@
-SUBDIRS = exceptions dns cc config datasrc python xfr bench
+SUBDIRS = exceptions dns asiolink cc config datasrc python xfr bench

+ 2 - 2
src/bin/auth/asio_link.cc

@@ -30,7 +30,7 @@
 #include <dns/message.h>
 #include <dns/messagerenderer.h>
 
-#include <asio_link.h>
+#include <asiolink.h>
 
 #include "coroutine.h"
 #include "yield.h"
@@ -42,7 +42,7 @@ using asio::ip::tcp;
 using namespace std;
 using namespace isc::dns;
 
-namespace asio_link {
+namespace asiolink {
 
 // Constructors and destructors for the callback provider base classes.
 DNSProvider::DNSProvider() {}

+ 8 - 8
src/bin/auth/asio_link.h

@@ -14,8 +14,8 @@
 
 // $Id$
 
-#ifndef __ASIO_LINK_H
-#define __ASIO_LINK_H 1
+#ifndef __ASIOLINK_H
+#define __ASIOLINK_H 1
 
 // IMPORTANT NOTE: only very few ASIO headers files can be included in
 // this file.  In particular, asio.hpp should never be included here.
@@ -38,10 +38,10 @@ namespace asio {
 class io_service;
 }
 
-/// \namespace asio_link
+/// \namespace asiolink
 /// \brief A wrapper interface for the ASIO library.
 ///
-/// The \c asio_link namespace is used to define a set of wrapper interfaces
+/// The \c asiolink namespace is used to define a set of wrapper interfaces
 /// for the ASIO library.
 ///
 /// BIND 10 uses the non-Boost version of ASIO because it's header-only,
@@ -59,7 +59,7 @@ class io_service;
 ///
 /// This wrapper interface is intended to centralize these
 /// problematic issues in a single sub module.  Other BIND 10 modules should
-/// simply include \c asio_link.h and use the wrapper API instead of
+/// simply include \c asiolink.h and use the wrapper API instead of
 /// including ASIO header files and using ASIO-specific classes directly.
 ///
 /// This wrapper may be used for other IO libraries if and when we want to
@@ -88,7 +88,7 @@ class io_service;
 /// the placeholder of callback handlers:
 /// http://think-async.com/Asio/asio-1.3.1/doc/asio/reference/asio_handler_allocate.html
 
-namespace asio_link {
+namespace asiolink {
 struct IOServiceImpl;
 
 /// \brief An exception that is thrown if an error occurs within the IO
@@ -497,8 +497,8 @@ private:
     IOServiceImpl* impl_;
 };
 
-}      // asio_link
-#endif // __ASIO_LINK_H
+}      // asiolink
+#endif // __ASIOLINK_H
 
 // Local Variables: 
 // mode: c++

src/bin/auth/coroutine.h → src/lib/asiolink/coroutine.h


+ 30 - 0
src/lib/asiolink/tests/Makefile.am

@@ -0,0 +1,30 @@
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/bin
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS =
+if HAVE_GTEST
+TESTS += run_unittests
+run_unittests_SOURCES = $(top_srcdir)/src/lib/dns/tests/unittest_util.h
+run_unittests_SOURCES += $(top_srcdir)/src/lib/dns/tests/unittest_util.cc
+run_unittests_SOURCES += asio_link_unittest.cc
+run_unittests_SOURCES += run_unittests.cc
+run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+run_unittests_LDADD = $(GTEST_LDADD)
+run_unittests_LDADD += $(SQLITE_LIBS)
+run_unittests_LDADD +=  $(top_builddir)/src/lib/dns/libdns++.la
+run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.a
+endif
+
+noinst_PROGRAMS = $(TESTS)

+ 2 - 2
src/bin/auth/tests/asio_link_unittest.cc

@@ -23,11 +23,11 @@
 
 #include <dns/tests/unittest_util.h>
 
-#include <auth/asio_link.h>
+#include <asiolink/asiolink.h>
 
 using isc::UnitTestUtil;
 using namespace std;
-using namespace asio_link;
+using namespace asiolink;
 
 namespace {
 const char* const TEST_PORT = "53535";

+ 28 - 0
src/lib/asiolink/tests/run_unittests.cc

@@ -0,0 +1,28 @@
+// Copyright (C) 2009  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.
+
+// $Id$
+
+#include <gtest/gtest.h>
+
+#include <dns/tests/unittest_util.h>
+
+int
+main(int argc, char* argv[])
+{
+    ::testing::InitGoogleTest(&argc, argv);
+    isc::UnitTestUtil::addDataPath(TEST_DATA_DIR);
+
+    return (RUN_ALL_TESTS());
+}

src/bin/auth/unyield.h → src/lib/asiolink/unyield.h


src/bin/auth/yield.h → src/lib/asiolink/yield.h