[svn] commit: r1983 - in /trunk: ./ ext/asio/ ext/boost/ ext/boost/algorithm/ ext/boost/archive/ ext/boost/asio/ ext/boost/assign/ ext/boost/bind/ ext/boost/boost/ ext/boost/concept/ ext/boost/config/ ext/boost/date_time/ ext/boost/detail/ ext/boost/exception/ ext/boost/function/ ext/boost/functional/ ext/boost/integer/ ext/boost/iterator/ ext/boost/mpl/ ext/boost/optional/ ext/boost/preprocessor/ ext/boost/range/ ext/boost/regex/ ext/boost/serialization/ ext/boost/smart_ptr/ ext/boost/system/ ext/boost/type_traits/ ext/boost/utility/ src/bin/auth/ src/bin/auth/tests/ src/bin/host/ src/bin/xfrin/ src/lib/ src/lib/cc/ src/lib/config/ src/lib/config/tests/ src/lib/datasrc/ src/lib/datasrc/tests/ src/lib/dns/ src/lib/dns/rdata/generic/ src/lib/dns/tests/ src/lib/exceptions/ src/lib/xfr/
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat May 29 22:49:07 UTC 2010
Author: each
Date: Sat May 29 22:49:06 2010
New Revision: 1983
Log:
3. [func] each
bin/auth: removed custom query-processing code, changed
boost::asio code to use plain asio instead, and added asio
headers to the source tree. This allows building without
using an external boost library. (Trac #163, svn r1983)
Added:
trunk/ext/asio/
- copied from r1982, branches/trac168/ext/asio/
trunk/ext/boost/boost/
- copied from r1982, branches/trac168/ext/boost/boost/
trunk/src/bin/auth/asio_link.cc
- copied unchanged from r1982, branches/trac168/src/bin/auth/asio_link.cc
trunk/src/bin/auth/asio_link.h
- copied unchanged from r1982, branches/trac168/src/bin/auth/asio_link.h
Removed:
trunk/ext/boost/algorithm/
trunk/ext/boost/aligned_storage.hpp
trunk/ext/boost/any.hpp
trunk/ext/boost/archive/
trunk/ext/boost/array.hpp
trunk/ext/boost/asio/
trunk/ext/boost/asio.hpp
trunk/ext/boost/assert.hpp
trunk/ext/boost/assign/
trunk/ext/boost/assign.hpp
trunk/ext/boost/bimap.hpp
trunk/ext/boost/bind/
trunk/ext/boost/bind.hpp
trunk/ext/boost/blank.hpp
trunk/ext/boost/blank_fwd.hpp
trunk/ext/boost/call_traits.hpp
trunk/ext/boost/cast.hpp
trunk/ext/boost/cerrno.hpp
trunk/ext/boost/checked_delete.hpp
trunk/ext/boost/circular_buffer.hpp
trunk/ext/boost/circular_buffer_fwd.hpp
trunk/ext/boost/compressed_pair.hpp
trunk/ext/boost/concept/
trunk/ext/boost/concept_archetype.hpp
trunk/ext/boost/concept_check.hpp
trunk/ext/boost/config/
trunk/ext/boost/config.hpp
trunk/ext/boost/crc.hpp
trunk/ext/boost/cregex.hpp
trunk/ext/boost/cstdint.hpp
trunk/ext/boost/cstdlib.hpp
trunk/ext/boost/current_function.hpp
trunk/ext/boost/date_time/
trunk/ext/boost/date_time.hpp
trunk/ext/boost/detail/
trunk/ext/boost/dynamic_bitset.hpp
trunk/ext/boost/dynamic_bitset_fwd.hpp
trunk/ext/boost/dynamic_property_map.hpp
trunk/ext/boost/enable_shared_from_this.hpp
trunk/ext/boost/exception/
trunk/ext/boost/exception.hpp
trunk/ext/boost/exception_ptr.hpp
trunk/ext/boost/filesystem.hpp
trunk/ext/boost/flyweight.hpp
trunk/ext/boost/foreach.hpp
trunk/ext/boost/format.hpp
trunk/ext/boost/function/
trunk/ext/boost/function.hpp
trunk/ext/boost/function_equal.hpp
trunk/ext/boost/function_output_iterator.hpp
trunk/ext/boost/functional/
trunk/ext/boost/functional.hpp
trunk/ext/boost/generator_iterator.hpp
trunk/ext/boost/get_pointer.hpp
trunk/ext/boost/implicit_cast.hpp
trunk/ext/boost/indirect_reference.hpp
trunk/ext/boost/integer/
trunk/ext/boost/integer.hpp
trunk/ext/boost/integer_fwd.hpp
trunk/ext/boost/integer_traits.hpp
trunk/ext/boost/intrusive_ptr.hpp
trunk/ext/boost/io_fwd.hpp
trunk/ext/boost/is_placeholder.hpp
trunk/ext/boost/iterator/
trunk/ext/boost/iterator.hpp
trunk/ext/boost/iterator_adaptors.hpp
trunk/ext/boost/last_value.hpp
trunk/ext/boost/lexical_cast.hpp
trunk/ext/boost/limits.hpp
trunk/ext/boost/make_shared.hpp
trunk/ext/boost/math_fwd.hpp
trunk/ext/boost/mem_fn.hpp
trunk/ext/boost/memory_order.hpp
trunk/ext/boost/mpi.hpp
trunk/ext/boost/mpl/
trunk/ext/boost/multi_array.hpp
trunk/ext/boost/multi_index_container.hpp
trunk/ext/boost/multi_index_container_fwd.hpp
trunk/ext/boost/next_prior.hpp
trunk/ext/boost/non_type.hpp
trunk/ext/boost/noncopyable.hpp
trunk/ext/boost/nondet_random.hpp
trunk/ext/boost/none.hpp
trunk/ext/boost/none_t.hpp
trunk/ext/boost/operators.hpp
trunk/ext/boost/optional/
trunk/ext/boost/optional.hpp
trunk/ext/boost/parameter.hpp
trunk/ext/boost/pointee.hpp
trunk/ext/boost/pointer_cast.hpp
trunk/ext/boost/pointer_to_other.hpp
trunk/ext/boost/preprocessor/
trunk/ext/boost/preprocessor.hpp
trunk/ext/boost/program_options.hpp
trunk/ext/boost/progress.hpp
trunk/ext/boost/property_map.hpp
trunk/ext/boost/property_map_iterator.hpp
trunk/ext/boost/python.hpp
trunk/ext/boost/random.hpp
trunk/ext/boost/range/
trunk/ext/boost/range.hpp
trunk/ext/boost/rational.hpp
trunk/ext/boost/ref.hpp
trunk/ext/boost/regex/
trunk/ext/boost/regex.hpp
trunk/ext/boost/regex_fwd.hpp
trunk/ext/boost/scope_exit.hpp
trunk/ext/boost/scoped_array.hpp
trunk/ext/boost/scoped_ptr.hpp
trunk/ext/boost/serialization/
trunk/ext/boost/shared_array.hpp
trunk/ext/boost/shared_container_iterator.hpp
trunk/ext/boost/shared_ptr.hpp
trunk/ext/boost/signal.hpp
trunk/ext/boost/signals.hpp
trunk/ext/boost/signals2.hpp
trunk/ext/boost/smart_ptr/
trunk/ext/boost/smart_ptr.hpp
trunk/ext/boost/spirit.hpp
trunk/ext/boost/static_assert.hpp
trunk/ext/boost/strong_typedef.hpp
trunk/ext/boost/swap.hpp
trunk/ext/boost/system/
trunk/ext/boost/thread.hpp
trunk/ext/boost/throw_exception.hpp
trunk/ext/boost/timer.hpp
trunk/ext/boost/token_functions.hpp
trunk/ext/boost/token_iterator.hpp
trunk/ext/boost/tokenizer.hpp
trunk/ext/boost/type.hpp
trunk/ext/boost/type_traits/
trunk/ext/boost/type_traits.hpp
trunk/ext/boost/unordered_map.hpp
trunk/ext/boost/unordered_set.hpp
trunk/ext/boost/utility/
trunk/ext/boost/utility.hpp
trunk/ext/boost/variant.hpp
trunk/ext/boost/vector_property_map.hpp
trunk/ext/boost/version.hpp
trunk/ext/boost/visit_each.hpp
trunk/ext/boost/wave.hpp
trunk/ext/boost/weak_ptr.hpp
Modified:
trunk/ (props changed)
trunk/ChangeLog
trunk/README
trunk/configure.ac
trunk/src/bin/auth/Makefile.am
trunk/src/bin/auth/main.cc
trunk/src/bin/auth/tests/Makefile.am
trunk/src/bin/host/Makefile.am
trunk/src/bin/xfrin/ (props changed)
trunk/src/lib/Makefile.am
trunk/src/lib/cc/ (props changed)
trunk/src/lib/cc/Makefile.am
trunk/src/lib/cc/session.cc
trunk/src/lib/cc/session.h
trunk/src/lib/config/Makefile.am
trunk/src/lib/config/ccsession.cc
trunk/src/lib/config/ccsession.h
trunk/src/lib/config/tests/Makefile.am
trunk/src/lib/config/tests/fake_session.cc
trunk/src/lib/config/tests/fake_session.h
trunk/src/lib/datasrc/Makefile.am
trunk/src/lib/datasrc/tests/Makefile.am
trunk/src/lib/dns/ (props changed)
trunk/src/lib/dns/Makefile.am
trunk/src/lib/dns/rdata/generic/rrsig_46.cc (props changed)
trunk/src/lib/dns/tests/ (props changed)
trunk/src/lib/dns/tests/Makefile.am
trunk/src/lib/dns/tests/dnssectime_unittest.cc
trunk/src/lib/exceptions/Makefile.am
trunk/src/lib/xfr/Makefile.am
trunk/src/lib/xfr/xfrout_client.cc
trunk/src/lib/xfr/xfrout_client.h
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Sat May 29 22:49:06 2010
@@ -1,3 +1,8 @@
+ 3. [func] each
+ bin/auth: removed custom query-processing code, changed
+ boost::asio code to use plain asio instead, and added asio
+ headers to the source tree. This allows building without
+ using an external boost library. (Trac #163, svn r1983)
2. [func] jinmei
lib/dns: added a separate signature for Name::split() as a
convenient wrapper for common usage. (Trac #49, svn r1903)
Modified: trunk/README
==============================================================================
--- trunk/README (original)
+++ trunk/README Sat May 29 22:49:06 2010
@@ -37,9 +37,6 @@
See the Guide for detailed installation directions.
BUILDING
-
-We recommend using the Boost libraries as it provides a safer TCP
-implementation in BIND 10.
Simple build instructions:
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sat May 29 22:49:06 2010
@@ -87,9 +87,21 @@
# TODO: check for _sqlite3.py module
-# default compiler warning settings
+#
+# B10_CXXFLAGS is the default C++ compiler flags. This will (and should) be
+# used as the default value for each specifc AM_CXXFLAGS:
+# AM_CXXFLAGS = $(B10_CXXFLAGS)
+# AM_CXXFLAGS += ... # add module specific flags
+# We need this so that we can disable some specific compiler warnings per
+# module basis; since AM_CXXFLAGS are placed before CXXFLAGS, and since
+# gcc's -Wno-XXX option must be specified after -Wall or -Wextra, we cannot
+# specify the default warning flags in CXXFLAGS and let specific modules
+# "override" the default.
+#
+B10_CXXFLAGS=
+
if test "X$GCC" = "Xyes"; then
-CXXFLAGS="$CXXFLAGS -g -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
+B10_CXXFLAGS="-g -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
UNUSED_PARAM_ATTRIBUTE='__attribute__((unused))'
# Certain versions of gcc (g++) have a bug that incorrectly warns about
@@ -97,22 +109,26 @@
# translation unit. For these versions we have to disable -Werror.
werror_ok=0
CXXFLAGS_SAVED="$CXXFLAGS"
-CXXFLAGS="$CXXFLAGS -Werror"
+CXXFLAGS="$CXXFLAGS $B10_CXXFLAGS -Werror"
AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
AC_TRY_COMPILE([namespace { class Foo {}; }
namespace isc {class Bar {Foo foo_;};} ],,
[AC_MSG_RESULT(no)
- werror_ok=1],
+ werror_ok=1
+ B10_CXXFLAGS="$B10_CXXFLAGS -Werror"],
[AC_MSG_RESULT(yes)])
CXXFLAGS="$CXXFLAGS_SAVED"
-fi
+fi dnl GCC = yes
+
+AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
AC_DEFINE_UNQUOTED(UNUSED_PARAM, $UNUSED_PARAM_ATTRIBUTE, Define to compiler keyword indicating a function argument is intentionally unused)
-AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
# produce PIC unless we disable shared libraries. need this for python bindings.
if test $enable_shared != "no" -a "X$GCC" = "Xyes"; then
- CXXFLAGS="$CXXFLAGS -fPIC"
-fi
+ B10_CXXFLAGS="$B10_CXXFLAGS -fPIC"
+fi
+
+AC_SUBST(B10_CXXFLAGS)
# Checks for libraries.
@@ -192,52 +208,6 @@
BOOST_LDFLAGS="-L$withval"
fi])
AC_SUBST(BOOST_LDFLAGS)
-
-# Check availability of the Boost System library
-
-AC_MSG_CHECKING([for boost::system library])
-AC_ARG_WITH([boost-system],
-AC_HELP_STRING([--with-boost-system],
- [specify whether to use the boost system library]),
- [with_boost_system="$withval"], [with_boost_system="auto"])
-
-if test "$with_boost_system" != "no"; then
- LDFLAGS_SAVED="$LDFLAGS"
- LIBS_SAVED="$LIBS"
- CPPFLAGS_SAVED="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS -Iext"
-
- for BOOST_TRY_LIB in boost_system boost_system-mt; do
- LDFLAGS="$LDFLAGS_SAVED ${BOOST_LDFLAGS}"
- LIBS="$LIBS_SAVED -l${BOOST_TRY_LIB}"
- AC_TRY_LINK([#include <boost/system/error_code.hpp>],
- [ boost::system::error_code error_code;
- std::string message(error_code.message());
- return 0; ],
- [ AC_MSG_RESULT(yes)
- BOOST_SYSTEM_LIB="-l${BOOST_TRY_LIB}"
- ],[])
- if test "X${BOOST_SYSTEM_LIB}" != X; then
- break
- fi
- done
-
- LDFLAGS="$LDFLAGS_SAVED"
- CPPFLAGS="$CPPFLAGS_SAVED"
- LIBS="$LIBS_SAVED"
-fi
-
-if test "X${BOOST_SYSTEM_LIB}" = X; then
- AC_MSG_RESULT(no)
- if test "$with_boost_system" = "yes"; then
- AC_MSG_ERROR([boost system library is requested but not found])
- fi
-else
- AC_DEFINE(HAVE_BOOST_SYSTEM, 1, Define to 1 if boost system library is available)
-fi
-
-AM_CONDITIONAL(HAVE_BOOST_SYSTEM, test "X${BOOST_SYSTEM_LIB}" != X)
-AC_SUBST(BOOST_SYSTEM_LIB)
# Check availability of the Boost Python library
@@ -340,19 +310,49 @@
PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9, enable_features="$enable_features SQLite3")
+#
+# ASIO: we extensively use it as the C++ event management module.
+#
+# Use local ASIO headers from ext
+#
+CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/asio"
+#
+# kqueue portability: ASIO uses kqueue by default if it's available (it's
+# generally available in BSD variants). Unfortunately, some public
+# implementation of kqueue forces a conversion from a pointer to an integer,
+# which is prohibited in C++ unless reinterpret_cast, C++'s most evil beast
+# (and ASIO doesn't use it anyway) is used. This will cause build error for
+# some of our C++ files including ASIO header files. The following check
+# detects such cases and tells ASIO not to use kqueue if so.
+AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
+case $ac_cv_have_kqueue in
+yes)
+ AC_MSG_CHECKING([whether kqueue EV_SET compiles in C++])
+ AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/event.h>],
+[char* udata;
+EV_SET(NULL, 0, 0, 0, 0, 0, udata);],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT([no, disable kqueue for ASIO])
+ CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_KQUEUE=1"
+ ])
+esac
+
# Check for headers from required devel kits.
# boost/shared_ptr.hpp is in ext in svn but not in tarball.
CPPFLAGS_SAVED=$CPPFLAGS
if test "X$BOOST_INCLUDES" = "X"; then
# abs_top_srcdir not defined yet
# so this is only useful to check. We'll replace it after the check.
- CPPFLAGS="$CPPFLAGS -Iext"
+ CPPFLAGS="$CPPFLAGS -Iext/boost"
fi
AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp],,
AC_MSG_ERROR([Missing required header files.]))
CPPFLAGS=$CPPFLAGS_SAVED
if test "X$BOOST_INCLUDES" = "X"; then
- CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext"
+ CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/boost"
fi
AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
@@ -473,9 +473,9 @@
CPPFLAGS: $CPPFLAGS
CFLAGS: $CFLAGS
CXXFLAGS: $CXXFLAGS
+ B10_CXXFLAGS: $B10_CXXFLAGS
dnl includes too
Boost Python: $BOOST_PYTHON_LIB
- Boost System: $BOOST_SYSTEM_LIB
SQLite: $SQLITE_CFLAGS
$SQLITE_LIBS
Modified: trunk/src/bin/auth/Makefile.am
==============================================================================
--- trunk/src/bin/auth/Makefile.am (original)
+++ trunk/src/bin/auth/Makefile.am Sat May 29 22:49:06 2010
@@ -2,9 +2,8 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
-if GCC_WERROR_OK
-AM_CPPFLAGS += -Werror
-endif
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
pkglibexecdir = $(libexecdir)/@PACKAGE@
@@ -26,6 +25,19 @@
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) -Wno-unused-parameter
+libasio_link_a_CPPFLAGS = $(AM_CPPFLAGS)
+
BUILT_SOURCES = spec_config.h
pkglibexec_PROGRAMS = b10-auth
b10_auth_SOURCES = auth_srv.cc auth_srv.h
@@ -36,13 +48,10 @@
b10_auth_LDADD += $(top_builddir)/src/lib/config/.libs/libcfgclient.a
b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.a
b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a
+b10_auth_LDADD += $(top_builddir)/src/bin/auth/libasio_link.a
b10_auth_LDADD += $(SQLITE_LIBS)
-if HAVE_BOOST_SYSTEM
if HAVE_BOOST_PYTHON
b10_auth_LDADD += $(top_builddir)/src/lib/xfr/.libs/libxfr.a
-endif
-b10_auth_LDFLAGS = $(AM_LDFLAGS) $(BOOST_LDFLAGS)
-b10_auth_LDADD += $(BOOST_SYSTEM_LIB)
endif
# TODO: config.h.in is wrong because doesn't honor pkgdatadir
Modified: trunk/src/bin/auth/main.cc
==============================================================================
--- trunk/src/bin/auth/main.cc (original)
+++ trunk/src/bin/auth/main.cc Sat May 29 22:49:06 2010
@@ -28,10 +28,6 @@
#include <iostream>
#include <boost/foreach.hpp>
-#ifdef HAVE_BOOST_SYSTEM
-#include <boost/bind.hpp>
-#include <boost/asio.hpp>
-#endif // HAVE_BOOST_SYSTEM
#include <exceptions/exceptions.h>
@@ -43,26 +39,12 @@
#include <cc/data.h>
#include <config/ccsession.h>
-#if defined(HAVE_BOOST_SYSTEM) && defined(HAVE_BOOST_PYTHON)
-#define USE_XFROUT
-#include <xfr/xfrout_client.h>
-#endif
-
#include "spec_config.h"
#include "common.h"
#include "auth_srv.h"
+#include "asio_link.h"
using namespace std;
-#ifdef USE_XFROUT
-using namespace isc::xfr;
-#endif
-
-#ifdef HAVE_BOOST_SYSTEM
-using namespace boost::asio;
-using ip::udp;
-using ip::tcp;
-#endif // HAVE_BOOST_SYSTEM
-
using namespace isc::data;
using namespace isc::cc;
using namespace isc::config;
@@ -79,13 +61,8 @@
* todo: turn this around, and put handlers in the authserver
* class itself? */
AuthSrv *auth_server;
-#ifdef HAVE_BOOST_SYSTEM
-// TODO: this should be a property of AuthSrv, and AuthSrv needs
-// a stop() method (so the shutdown command can be handled)
-boost::asio::io_service io_service_;
-#else
-bool running;
-#endif // HAVE_BOOST_SYSTEM
+
+asio_link::IOService* io_service;
ElementPtr
my_config_handler(ElementPtr new_config) {
@@ -101,598 +78,11 @@
/* let's add that message to our answer as well */
answer->get("result")->add(args);
} else if (command == "shutdown") {
-#ifdef HAVE_BOOST_SYSTEM
- io_service_.stop();
-#else
- running = false;
-#endif // HAVE_BOOST_SYSTEM
+ io_service->stop();
}
return answer;
}
-
-#ifdef USE_XFROUT
-//TODO. The sample way for checking axfr query, the code should be merged to auth server class
-static bool
-check_axfr_query(char *msg_data, uint16_t msg_len)
-{
- if (msg_len < 15)
- return false;
-
- uint16_t query_type = *(uint16_t *)(msg_data + (msg_len - 4));
- if ( query_type == 0xFC00)
- return true;
-
- return false;
-}
-
-//TODO. Send the xfr query to xfrout module, the code should be merged to auth server class
-static void
-dispatch_axfr_query(int tcp_sock, char axfr_query[], uint16_t query_len)
-{
- std::string path = string(UNIX_SOCKET_FILE);
- XfroutClient xfr_client(path);
- try {
- xfr_client.connect();
- xfr_client.sendXfroutRequestInfo(tcp_sock, (uint8_t *)axfr_query, query_len);
- xfr_client.disconnect();
- }
- catch (const std::exception & err) {
- //if (verbose_mode)
- cerr << "error handle xfr query:" << err.what() << endl;
- }
-}
-#endif
-
-#ifdef HAVE_BOOST_SYSTEM
-//
-// Helper classes for asynchronous I/O using boost::asio
-//
-class TCPClient {
-public:
- TCPClient(io_service& io_service) :
- socket_(io_service),
- response_buffer_(0),
- responselen_buffer_(TCP_MESSAGE_LENGTHSIZE),
- response_renderer_(response_buffer_),
- dns_message_(Message::PARSE)
- {}
-
- void start() {
- async_read(socket_, boost::asio::buffer(data_, TCP_MESSAGE_LENGTHSIZE),
- boost::bind(&TCPClient::headerRead, this,
- placeholders::error,
- placeholders::bytes_transferred));
- }
-
- tcp::socket& getSocket() { return (socket_); }
-
- void headerRead(const boost::system::error_code& error,
- size_t bytes_transferred)
- {
- if (!error) {
- InputBuffer dnsbuffer(data_, bytes_transferred);
-
- uint16_t msglen = dnsbuffer.readUint16();
- async_read(socket_, boost::asio::buffer(data_, msglen),
-
- boost::bind(&TCPClient::requestRead, this,
- placeholders::error,
- placeholders::bytes_transferred));
- } else {
- delete this;
- }
- }
-
- void requestRead(const boost::system::error_code& error,
- size_t bytes_transferred)
- {
- if (!error) {
- InputBuffer dnsbuffer(data_, bytes_transferred);
-#ifdef USE_XFROUT
- if (check_axfr_query(data_, bytes_transferred)) {
- dispatch_axfr_query(socket_.native(), data_, bytes_transferred);
- // start to get new query ?
- start();
- } else {
-#endif
- if (auth_server->processMessage(dnsbuffer, dns_message_,
- response_renderer_, false)) {
- responselen_buffer_.writeUint16(response_buffer_.getLength());
- async_write(socket_,
- boost::asio::buffer(
- responselen_buffer_.getData(),
- responselen_buffer_.getLength()),
- boost::bind(&TCPClient::responseWrite, this,
- placeholders::error));
- } else {
- delete this;
- }
-#ifdef USE_XFROUT
- }
-#endif
- } else {
- delete this;
- }
- }
-
- void responseWrite(const boost::system::error_code& error) {
- if (!error) {
- async_write(socket_,
- boost::asio::buffer(response_buffer_.getData(),
- response_buffer_.getLength()),
- boost::bind(&TCPClient::handleWrite, this,
- placeholders::error));
- } else {
- delete this;
- }
- }
-
- void handleWrite(const boost::system::error_code& error) {
- if (!error) {
- start(); // handle next request, if any.
- } else {
- delete this;
- }
- }
-
-private:
- tcp::socket socket_;
- OutputBuffer response_buffer_;
- OutputBuffer responselen_buffer_;
- MessageRenderer response_renderer_;
- Message dns_message_;
- enum { MAX_LENGTH = 65535 };
- static const size_t TCP_MESSAGE_LENGTHSIZE = 2;
- char data_[MAX_LENGTH];
-};
-
-class TCPServer {
-public:
- TCPServer(io_service& io_service, int af, short port) :
- io_service_(io_service), acceptor_(io_service_),
- listening_(new TCPClient(io_service_))
- {
- tcp::endpoint endpoint(af == AF_INET6 ? tcp::v6() : tcp::v4(), port);
- acceptor_.open(endpoint.protocol());
- // Set v6-only (we use a different instantiation for v4,
- // otherwise asio will bind to both v4 and v6
- if (af == AF_INET6) {
- acceptor_.set_option(ip::v6_only(true));
- }
- acceptor_.set_option(tcp::acceptor::reuse_address(true));
- acceptor_.bind(endpoint);
- acceptor_.listen();
- acceptor_.async_accept(listening_->getSocket(),
- boost::bind(&TCPServer::handleAccept, this,
- listening_, placeholders::error));
- }
-
- ~TCPServer() { delete listening_; }
-
- void handleAccept(TCPClient* new_client,
- const boost::system::error_code& error)
- {
- if (!error) {
- assert(new_client == listening_);
- new_client->start();
- listening_ = new TCPClient(io_service_);
- acceptor_.async_accept(listening_->getSocket(),
- boost::bind(&TCPServer::handleAccept,
- this, listening_,
- placeholders::error));
- } else {
- delete new_client;
- }
- }
-
-private:
- io_service& io_service_;
- tcp::acceptor acceptor_;
- TCPClient* listening_;
-};
-
-class UDPServer {
-public:
- UDPServer(io_service& io_service, int af, short port) :
- io_service_(io_service),
- socket_(io_service, af == AF_INET6 ? udp::v6() : udp::v4()),
- response_buffer_(0),
- response_renderer_(response_buffer_),
- dns_message_(Message::PARSE)
- {
- // Set v6-only (we use a different instantiation for v4,
- // otherwise asio will bind to both v4 and v6
- if (af == AF_INET6) {
- socket_.set_option(boost::asio::ip::v6_only(true));
- socket_.bind(udp::endpoint(udp::v6(), port));
- } else {
- socket_.bind(udp::endpoint(udp::v4(), port));
- }
- startReceive();
- }
-
- void handleRequest(const boost::system::error_code& error,
- size_t bytes_recvd)
- {
- if (!error && bytes_recvd > 0) {
- InputBuffer request_buffer(data_, bytes_recvd);
-
- dns_message_.clear(Message::PARSE);
- response_renderer_.clear();
- if (auth_server->processMessage(request_buffer, dns_message_,
- response_renderer_, true)) {
- socket_.async_send_to(
- boost::asio::buffer(response_buffer_.getData(),
- response_buffer_.getLength()),
- sender_endpoint_,
- boost::bind(&UDPServer::sendCompleted,
- this,
- placeholders::error,
- placeholders::bytes_transferred));
- } else {
- startReceive();
- }
- } else {
- startReceive();
- }
- }
-
- void sendCompleted(const boost::system::error_code& error UNUSED_PARAM,
- size_t bytes_sent UNUSED_PARAM)
- {
- // Even if error occurred there's nothing to do. Simply handle
- // the next request.
- startReceive();
- }
-private:
- void startReceive() {
- socket_.async_receive_from(
- boost::asio::buffer(data_, MAX_LENGTH), sender_endpoint_,
- boost::bind(&UDPServer::handleRequest, this,
- placeholders::error,
- placeholders::bytes_transferred));
- }
-
-private:
- io_service& io_service_;
- udp::socket socket_;
- OutputBuffer response_buffer_;
- MessageRenderer response_renderer_;
- Message dns_message_;
- udp::endpoint sender_endpoint_;
- enum { MAX_LENGTH = 4096 };
- char data_[MAX_LENGTH];
-};
-
-struct ServerSet {
- ServerSet() : udp4_server(NULL), udp6_server(NULL),
- tcp4_server(NULL), tcp6_server(NULL)
- {}
- ~ServerSet() {
- delete udp4_server;
- delete udp6_server;
- delete tcp4_server;
- delete tcp6_server;
- }
- UDPServer* udp4_server;
- UDPServer* udp6_server;
- TCPServer* tcp4_server;
- TCPServer* tcp6_server;
-};
-
-void
-run_server(const char* port, const bool use_ipv4, const bool use_ipv6,
- AuthSrv* srv UNUSED_PARAM)
-{
- ServerSet servers;
- short portnum = atoi(port);
-
- if (use_ipv4) {
- servers.udp4_server = new UDPServer(io_service_, AF_INET, portnum);
- servers.tcp4_server = new TCPServer(io_service_, AF_INET, portnum);
- }
- if (use_ipv6) {
- servers.udp6_server = new UDPServer(io_service_, AF_INET6, portnum);
- servers.tcp6_server = new TCPServer(io_service_, AF_INET6, portnum);
- }
-
- cout << "Server started." << endl;
- io_service_.run();
-}
-#else // !HAVE_BOOST_SYSTEM
-struct SocketSet {
- SocketSet() : ups4(-1), tps4(-1), ups6(-1), tps6(-1) {}
- ~SocketSet() {
- if (ups4 >= 0) {
- close(ups4);
- }
- if (tps4 >= 0) {
- close(tps4);
- }
- if (ups6 >= 0) {
- close(ups6);
- }
- if (tps4 >= 0) {
- close(tps6);
- }
- }
- int ups4, tps4, ups6, tps6;
-};
-
-int
-getUDPSocket(int af, const char* port) {
- struct addrinfo hints, *res;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = af;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_flags = AI_PASSIVE;
- hints.ai_protocol = IPPROTO_UDP;
-
- int error = getaddrinfo(NULL, port, &hints, &res);
- if (error != 0) {
- isc_throw(FatalError, "getaddrinfo failed: " << gai_strerror(error));
- }
-
- int s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- if (s < 0) {
- isc_throw(FatalError, "failed to open socket");
- }
-
- if (af == AF_INET6) {
- int on = 1;
- if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
- cerr << "couldn't set IPV6_V6ONLY socket option" << endl;
- // proceed anyway
- }
- }
-
- if (bind(s, res->ai_addr, res->ai_addrlen) < 0) {
- isc_throw(FatalError, "binding socket failure");
- }
-
- return (s);
-}
-
-int
-getTCPSocket(int af, const char* port) {
- struct addrinfo hints, *res;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = af;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_PASSIVE;
- hints.ai_protocol = IPPROTO_TCP;
-
- int error = getaddrinfo(NULL, port, &hints, &res);
- if (error != 0) {
- isc_throw(FatalError, "getaddrinfo failed: " << gai_strerror(error));
- }
-
- int s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- if (s < 0) {
- isc_throw(FatalError, "failed to open socket");
- }
-
- int on = 1;
- if (af == AF_INET6) {
- if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
- cerr << "couldn't set IPV6_V6ONLY socket option" << endl;
- }
- // proceed anyway
- }
-
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) {
- cerr << "couldn't set SO_REUSEADDR socket option" << endl;
- }
-
- if (bind(s, res->ai_addr, res->ai_addrlen) < 0) {
- isc_throw(FatalError, "binding socket failure");
- }
-
- if (listen(s, 100) < 0) {
- isc_throw(FatalError, "failed to listen on a TCP socket");
- }
- return (s);
-}
-
-void
-processMessageUDP(const int fd, Message& dns_message,
- MessageRenderer& response_renderer)
-{
- struct sockaddr_storage ss;
- socklen_t sa_len = sizeof(ss);
- struct sockaddr* sa = static_cast<struct sockaddr*>((void*)&ss);
- char recvbuf[4096];
- int cc;
-
- dns_message.clear(Message::PARSE);
- response_renderer.clear();
- if ((cc = recvfrom(fd, recvbuf, sizeof(recvbuf), 0, sa, &sa_len)) > 0) {
- InputBuffer buffer(recvbuf, cc);
- if (auth_server->processMessage(buffer, dns_message, response_renderer,
- true)) {
- cc = sendto(fd, response_renderer.getData(),
- response_renderer.getLength(), 0, sa, sa_len);
- if (cc != response_renderer.getLength()) {
- cerr << "UDP send error" << endl;
- }
- }
- } else if (verbose_mode) {
- cerr << "UDP receive error" << endl;
- }
-}
-
-// XXX: this function does not handle partial reads or partial writes,
-// and is VERY UNSAFE - will probably be removed or rewritten
-void
-processMessageTCP(const int fd, Message& dns_message,
- MessageRenderer& response_renderer)
-{
- struct sockaddr_storage ss;
- socklen_t sa_len = sizeof(ss);
- struct sockaddr* sa = static_cast<struct sockaddr*>((void*)&ss);
- char sizebuf[2];
- int cc;
-
- int ts = accept(fd, sa, &sa_len);
- if (ts < 0) {
- if (verbose_mode) {
- cerr << "[XX] TCP accept failure:" << endl;
- return;
- }
- }
-
- if (verbose_mode) {
- cerr << "[XX] process TCP" << endl;
- }
- cc = recv(ts, sizebuf, 2, 0);
- if (cc < 0) {
- if (verbose_mode) {
- cerr << "[XX] TCP recv failure:" << endl;
- }
- close(ts);
- return;
- }
- if (verbose_mode) {
- cerr << "[XX] got: " << cc << endl;
- }
- uint16_t size, size_n;
- memcpy(&size_n, sizebuf, 2);
- size = ntohs(size_n);
- if (verbose_mode) {
- cerr << "[XX] got: " << size << endl;
- }
-
- vector<char> message_buffer;
- message_buffer.reserve(size);
- cc = 0;
- while (cc < size) {
- if (verbose_mode) {
- cerr << "[XX] cc now: " << cc << " of " << size << endl;
- }
- const int cc0 = recv(ts, &message_buffer[0] + cc, size - cc, 0);
- if (cc0 < 0) {
- if (verbose_mode) {
- cerr << "TCP receive error" << endl;
- close(ts);
- return;
- }
- }
- if (cc0 == 0) {
- // client closed connection
- close(ts);
- return;
- }
- cc += cc0;
- }
-
- InputBuffer buffer(&message_buffer[0], size);
- dns_message.clear(Message::PARSE);
- response_renderer.clear();
- if (auth_server->processMessage(buffer, dns_message, response_renderer,
- false)) {
- size = response_renderer.getLength();
- size_n = htons(size);
- if (send(ts, &size_n, 2, 0) == 2) {
- cc = send(ts, response_renderer.getData(),
- response_renderer.getLength(), 0);
- if (cc == -1) {
- if (verbose_mode) {
- cerr << "[AuthSrv] error in sending TCP response message" <<
- endl;
- }
- } else {
- if (verbose_mode) {
- cerr << "[XX] sent TCP response: " << cc << " bytes"
- << endl;
- }
- }
- } else {
- if (verbose_mode) {
- cerr << "TCP send error" << endl;
- }
- }
- }
-
- // TODO: we don't check for more queries on the stream atm
- close(ts);
-}
-
-void
-run_server(const char* port, const bool use_ipv4, const bool use_ipv6,
- AuthSrv* srv)
-{
- SocketSet socket_set;
- fd_set fds_base;
- int nfds = -1;
-
- FD_ZERO(&fds_base);
- if (use_ipv4) {
- socket_set.ups4 = getUDPSocket(AF_INET, port);
- FD_SET(socket_set.ups4, &fds_base);
- nfds = max(nfds, socket_set.ups4);
- socket_set.tps4 = getTCPSocket(AF_INET, port);
- FD_SET(socket_set.tps4, &fds_base);
- nfds = max(nfds, socket_set.tps4);
- }
- if (use_ipv6) {
- socket_set.ups6 = getUDPSocket(AF_INET6, port);
- FD_SET(socket_set.ups6, &fds_base);
- nfds = max(nfds, socket_set.ups6);
- socket_set.tps6 = getTCPSocket(AF_INET6, port);
- FD_SET(socket_set.tps6, &fds_base);
- nfds = max(nfds, socket_set.tps6);
- }
- ++nfds;
-
- cout << "Server started." << endl;
-
- if (srv->configSession() == NULL) {
- isc_throw(FatalError, "Config session not initalized");
- }
-
- int ss = srv->configSession()->getSocket();
- Message dns_message(Message::PARSE);
- OutputBuffer resonse_buffer(0);
- MessageRenderer response_renderer(resonse_buffer);
-
- running = true;
- while (running) {
- fd_set fds = fds_base;
- FD_SET(ss, &fds);
- ++nfds;
-
- if (srv->configSession()->hasQueuedMsgs()) {
- srv->configSession()->checkCommand();
- }
- int n = select(nfds, &fds, NULL, NULL, NULL);
- if (n < 0) {
- if (errno != EINTR) {
- isc_throw(FatalError, "select error");
- }
- continue;
- }
-
- if (socket_set.ups4 >= 0 && FD_ISSET(socket_set.ups4, &fds)) {
- processMessageUDP(socket_set.ups4, dns_message, response_renderer);
- }
- if (socket_set.ups6 >= 0 && FD_ISSET(socket_set.ups6, &fds)) {
- processMessageUDP(socket_set.ups6, dns_message, response_renderer);
- }
- if (socket_set.tps4 >= 0 && FD_ISSET(socket_set.tps4, &fds)) {
- processMessageTCP(socket_set.tps4, dns_message, response_renderer);
- }
- if (socket_set.tps6 >= 0 && FD_ISSET(socket_set.tps6, &fds)) {
- processMessageTCP(socket_set.tps6, dns_message, response_renderer);
- }
- if (FD_ISSET(ss, &fds)) {
- srv->configSession()->checkCommand();
- }
- }
-}
-#endif // HAVE_BOOST_SYSTEM
void
usage() {
@@ -755,22 +145,20 @@
auth_server = new AuthSrv;
auth_server->setVerbose(verbose_mode);
-#ifdef HAVE_BOOST_SYSTEM
- ModuleCCSession cs(specfile, io_service_, my_config_handler,
- my_command_handler);
-#else
ModuleCCSession cs(specfile, my_config_handler, my_command_handler);
-#endif
auth_server->setConfigSession(&cs);
auth_server->updateConfig(ElementPtr());
- run_server(port, use_ipv4, use_ipv6, auth_server);
+ io_service = new asio_link::IOService(auth_server, port, use_ipv4,
+ use_ipv6);
+ io_service->run();
} catch (const std::exception& ex) {
cerr << ex.what() << endl;
ret = 1;
}
+ delete io_service;
delete auth_server;
return (ret);
}
Modified: trunk/src/bin/auth/tests/Makefile.am
==============================================================================
--- trunk/src/bin/auth/tests/Makefile.am (original)
+++ trunk/src/bin/auth/tests/Makefile.am Sat May 29 22:49:06 2010
@@ -1,6 +1,8 @@
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 += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
@@ -21,10 +23,6 @@
run_unittests_LDADD += $(top_builddir)/src/lib/config/.libs/libcfgclient.a
run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.a
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a
-if HAVE_BOOST_SYSTEM
-run_unittests_LDFLAGS += $(BOOST_LDFLAGS)
-run_unittests_LDADD += $(BOOST_SYSTEM_LIB)
-endif
endif
noinst_PROGRAMS = $(TESTS)
Modified: trunk/src/bin/host/Makefile.am
==============================================================================
--- trunk/src/bin/host/Makefile.am (original)
+++ trunk/src/bin/host/Makefile.am Sat May 29 22:49:06 2010
@@ -1,5 +1,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
Modified: trunk/src/lib/Makefile.am
==============================================================================
--- trunk/src/lib/Makefile.am (original)
+++ trunk/src/lib/Makefile.am Sat May 29 22:49:06 2010
@@ -1,6 +1,4 @@
SUBDIRS = exceptions dns cc config datasrc python
if HAVE_BOOST_PYTHON
-if HAVE_BOOST_SYSTEM
SUBDIRS += xfr
endif
-endif
Modified: trunk/src/lib/cc/Makefile.am
==============================================================================
--- trunk/src/lib/cc/Makefile.am (original)
+++ trunk/src/lib/cc/Makefile.am Sat May 29 22:49:06 2010
@@ -1,4 +1,11 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+# ASIO header files used in session.cc will trigger "unused-parameter"
+# error. Unfortunately there doesn't seem to be an easy way to selectively
+# avoid the error. As a short term workaround we suppress this warning
+# for the entire this module. See also src/bin/auth/Makefile.am.
+AM_CXXFLAGS += -Wno-unused-parameter
lib_LIBRARIES = libcc.a
libcc_a_SOURCES = data.cc data.h session.cc session.h
Modified: trunk/src/lib/cc/session.cc
==============================================================================
--- trunk/src/lib/cc/session.cc (original)
+++ trunk/src/lib/cc/session.cc Sat May 29 22:49:06 2010
@@ -14,7 +14,7 @@
// $Id$
-#include "config.h"
+#include <config.h>
#include <stdint.h>
@@ -23,11 +23,12 @@
#include <iostream>
#include <sstream>
-#ifdef HAVE_BOOST_SYSTEM
#include <boost/bind.hpp>
#include <boost/function.hpp>
-#include <boost/asio.hpp>
-#endif
+
+#include <asio.hpp>
+#include <asio/error_code.hpp>
+#include <asio/system_error.hpp>
#include <exceptions/exceptions.h>
@@ -38,12 +39,10 @@
using namespace isc::cc;
using namespace isc::data;
-#ifdef HAVE_BOOST_SYSTEM
-// some of the boost::asio names conflict with socket API system calls
+// some of the asio names conflict with socket API system calls
// (e.g. write(2)) so we don't import the entire boost::asio namespace.
-using boost::asio::io_service;
-using boost::asio::ip::tcp;
-#endif
+using asio::io_service;
+using asio::ip::tcp;
#include <sys/types.h>
#include <sys/socket.h>
@@ -69,7 +68,6 @@
ElementPtr queue_;
};
-#ifdef HAVE_BOOST_SYSTEM
class ASIOSession : public SessionImpl {
public:
ASIOSession(io_service& io_service) :
@@ -83,7 +81,7 @@
virtual void readData(void* data, size_t datalen);
virtual void startRead(boost::function<void()> user_handler);
private:
- void internalRead(const boost::system::error_code& error,
+ void internalRead(const asio::error_code& error,
size_t bytes_transferred);
private:
@@ -91,12 +89,12 @@
tcp::socket socket_;
uint32_t data_length_;
boost::function<void()> user_handler_;
- boost::system::error_code error_;
+ asio::error_code error_;
};
void
ASIOSession::establish() {
- socket_.connect(tcp::endpoint(boost::asio::ip::address_v4::loopback(),
+ socket_.connect(tcp::endpoint(asio::ip::address_v4::loopback(),
9912), error_);
if (error_) {
isc_throw(SessionError, "Unable to connect to message queue");
@@ -112,9 +110,9 @@
void
ASIOSession::writeData(const void* data, size_t datalen) {
try {
- boost::asio::write(socket_, boost::asio::buffer(data, datalen));
- } catch (const boost::system::system_error& boost_ex) {
- isc_throw(SessionError, "ASIO write failed: " << boost_ex.what());
+ asio::write(socket_, asio::buffer(data, datalen));
+ } catch (const asio::system_error& asio_ex) {
+ isc_throw(SessionError, "ASIO write failed: " << asio_ex.what());
}
}
@@ -137,11 +135,11 @@
void
ASIOSession::readData(void* data, size_t datalen) {
try {
- boost::asio::read(socket_, boost::asio::buffer(data, datalen));
- } catch (const boost::system::system_error& boost_ex) {
+ asio::read(socket_, asio::buffer(data, datalen));
+ } catch (const asio::system_error& asio_ex) {
// to hide boost specific exceptions, we catch them explicitly
// and convert it to SessionError.
- isc_throw(SessionError, "ASIO read failed: " << boost_ex.what());
+ isc_throw(SessionError, "ASIO read failed: " << asio_ex.what());
}
}
@@ -149,15 +147,15 @@
ASIOSession::startRead(boost::function<void()> user_handler) {
data_length_ = 0;
user_handler_ = user_handler;
- async_read(socket_, boost::asio::buffer(&data_length_,
+ async_read(socket_, asio::buffer(&data_length_,
sizeof(data_length_)),
boost::bind(&ASIOSession::internalRead, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
-}
-
-void
-ASIOSession::internalRead(const boost::system::error_code& error,
+ asio::placeholders::error,
+ asio::placeholders::bytes_transferred));
+}
+
+void
+ASIOSession::internalRead(const asio::error_code& error,
size_t bytes_transferred)
{
if (!error) {
@@ -171,7 +169,6 @@
isc_throw(SessionError, "asynchronous read failed");
}
}
-#endif
class SocketSession : public SessionImpl {
public:
@@ -271,10 +268,8 @@
Session::Session() : impl_(new SocketSession)
{}
-#ifdef HAVE_BOOST_SYSTEM
Session::Session(io_service& io_service) : impl_(new ASIOSession(io_service))
{}
-#endif
Session::~Session() {
delete impl_;
Modified: trunk/src/lib/cc/session.h
==============================================================================
--- trunk/src/lib/cc/session.h (original)
+++ trunk/src/lib/cc/session.h Sat May 29 22:49:06 2010
@@ -25,10 +25,8 @@
#include "data.h"
-namespace boost {
namespace asio {
class io_service;
-}
}
namespace isc {
@@ -51,7 +49,7 @@
public:
Session();
- Session(boost::asio::io_service& ioservice);
+ Session(asio::io_service& ioservice);
~Session();
// XXX: quick hack to allow the user to watch the socket directly.
Modified: trunk/src/lib/config/Makefile.am
==============================================================================
--- trunk/src/lib/config/Makefile.am (original)
+++ trunk/src/lib/config/Makefile.am Sat May 29 22:49:06 2010
@@ -1,4 +1,5 @@
-AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib -Wno-strict-aliasing
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CXXFLAGS = $(B10_CXXFLAGS) -Wno-strict-aliasing
lib_LTLIBRARIES = libcfgclient.la
libcfgclient_la_SOURCES = config_data.h config_data.cc module_spec.h module_spec.cc ccsession.cc ccsession.h
Modified: trunk/src/lib/config/ccsession.cc
==============================================================================
--- trunk/src/lib/config/ccsession.cc (original)
+++ trunk/src/lib/config/ccsession.cc Sat May 29 22:49:06 2010
@@ -32,9 +32,7 @@
#include <sstream>
#include <cerrno>
-#ifdef HAVE_BOOST_SYSTEM
#include <boost/bind.hpp>
-#endif
#include <boost/foreach.hpp>
#include <cc/data.h>
@@ -188,7 +186,6 @@
return module_spec;
}
-#ifdef HAVE_BOOST_SYSTEM
void
ModuleCCSession::startCheck() {
// data available on the command channel. process it in the synchronous
@@ -201,7 +198,7 @@
ModuleCCSession::ModuleCCSession(
std::string spec_file_name,
- boost::asio::io_service& io_service,
+ asio::io_service& io_service,
isc::data::ElementPtr(*config_handler)(isc::data::ElementPtr new_config),
isc::data::ElementPtr(*command_handler)(
const std::string& command, const isc::data::ElementPtr args)
@@ -213,7 +210,6 @@
// register callback for asynchronous read
session_.startRead(boost::bind(&ModuleCCSession::startCheck, this));
}
-#endif
ModuleCCSession::ModuleCCSession(
std::string spec_file_name,
Modified: trunk/src/lib/config/ccsession.h
==============================================================================
--- trunk/src/lib/config/ccsession.h (original)
+++ trunk/src/lib/config/ccsession.h Sat May 29 22:49:06 2010
@@ -24,10 +24,8 @@
#include <cc/session.h>
#include <cc/data.h>
-namespace boost {
namespace asio {
class io_service;
-}
}
namespace isc {
@@ -133,7 +131,7 @@
isc::data::ElementPtr(*command_handler)(const std::string& command, const isc::data::ElementPtr args) = NULL
) throw (isc::cc::SessionError);
ModuleCCSession(std::string spec_file_name,
- boost::asio::io_service& io_service,
+ asio::io_service& io_service,
isc::data::ElementPtr(*config_handler)(isc::data::ElementPtr new_config) = NULL,
isc::data::ElementPtr(*command_handler)(const std::string& command, const isc::data::ElementPtr args) = NULL
) throw (isc::cc::SessionError);
Modified: trunk/src/lib/config/tests/Makefile.am
==============================================================================
--- trunk/src/lib/config/tests/Makefile.am (original)
+++ trunk/src/lib/config/tests/Makefile.am Sat May 29 22:49:06 2010
@@ -1,4 +1,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+AM_CXXFLAGS += -Wno-unused-parameter # see src/lib/cc/Makefile.am
CLEANFILES = *.gcno *.gcda
@@ -18,11 +21,6 @@
run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
run_unittests_LDADD += $(top_builddir)/src/lib/cc/data.o
-if HAVE_BOOST_SYSTEM
-run_unittests_LDFLAGS += $(AM_LDFLAGS) $(BOOST_LDFLAGS)
-run_unittests_LDADD += $(BOOST_SYSTEM_LIB)
-endif
-
endif
noinst_PROGRAMS = $(TESTS)
Modified: trunk/src/lib/config/tests/fake_session.cc
==============================================================================
--- trunk/src/lib/config/tests/fake_session.cc (original)
+++ trunk/src/lib/config/tests/fake_session.cc Sat May 29 22:49:06 2010
@@ -23,12 +23,6 @@
#include <iostream>
#include <sstream>
-#ifdef HAVE_BOOST_SYSTEM
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/asio.hpp>
-#endif
-
#include <boost/foreach.hpp>
#include <exceptions/exceptions.h>
@@ -39,13 +33,6 @@
using namespace std;
using namespace isc::cc;
using namespace isc::data;
-
-#ifdef HAVE_BOOST_SYSTEM
-// some of the boost::asio names conflict with socket API system calls
-// (e.g. write(2)) so we don't import the entire boost::asio namespace.
-using boost::asio::io_service;
-using boost::asio::ip::tcp;
-#endif
#include <sys/types.h>
#include <sys/socket.h>
@@ -144,11 +131,9 @@
{
}
-#ifdef HAVE_BOOST_SYSTEM
-Session::Session(io_service& io_service UNUSED_PARAM)
-{
-}
-#endif
+Session::Session(asio::io_service& io_service UNUSED_PARAM)
+{
+}
Session::~Session() {
}
Modified: trunk/src/lib/config/tests/fake_session.h
==============================================================================
--- trunk/src/lib/config/tests/fake_session.h (original)
+++ trunk/src/lib/config/tests/fake_session.h Sat May 29 22:49:06 2010
@@ -25,10 +25,8 @@
#include <cc/data.h>
-namespace boost {
namespace asio {
class io_service;
-}
}
// global variables so tests can insert
@@ -65,7 +63,7 @@
// public so tests can inspect them
Session();
- Session(boost::asio::io_service& ioservice);
+ Session(asio::io_service& ioservice);
~Session();
// XXX: quick hack to allow the user to watch the socket directly.
Modified: trunk/src/lib/datasrc/Makefile.am
==============================================================================
--- trunk/src/lib/datasrc/Makefile.am (original)
+++ trunk/src/lib/datasrc/Makefile.am Sat May 29 22:49:06 2010
@@ -3,6 +3,8 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += $(SQLITE_CFLAGS)
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
Modified: trunk/src/lib/datasrc/tests/Makefile.am
==============================================================================
--- trunk/src/lib/datasrc/tests/Makefile.am (original)
+++ trunk/src/lib/datasrc/tests/Makefile.am Sat May 29 22:49:06 2010
@@ -1,6 +1,8 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/lib/dns
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
Modified: trunk/src/lib/dns/Makefile.am
==============================================================================
--- trunk/src/lib/dns/Makefile.am (original)
+++ trunk/src/lib/dns/Makefile.am Sat May 29 22:49:06 2010
@@ -1,9 +1,7 @@
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
-if GCC_WERROR_OK
-AM_CPPFLAGS += -Werror
-endif
+AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
CLEANFILES += rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc
@@ -86,10 +84,11 @@
pyexec_LTLIBRARIES = bind10_dns.la
bind10_dns_la_SOURCES = python_dns.cc
bind10_dns_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
+bind10_dns_la_CXXFLAGS = $(AM_CXXFLAGS) $(B10_CXXFLAGS)
if GCC_WERROR_OK
# XXX: Boost.Python triggers strict aliasing violation, so if we use -Werror
# we need to suppress the warnings.
-bind10_dns_la_CPPFLAGS += -fno-strict-aliasing
+bind10_dns_la_CXXFLAGS += -fno-strict-aliasing
endif
bind10_dns_la_LDFLAGS = $(BOOST_LDFLAGS) $(PYTHON_LDFLAGS)
# Python prefers .so, while some OSes (specifically MacOS) use a different
Modified: trunk/src/lib/dns/tests/Makefile.am
==============================================================================
--- trunk/src/lib/dns/tests/Makefile.am (original)
+++ trunk/src/lib/dns/tests/Makefile.am Sat May 29 22:49:06 2010
@@ -1,6 +1,7 @@
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
+AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
Modified: trunk/src/lib/dns/tests/dnssectime_unittest.cc
==============================================================================
--- trunk/src/lib/dns/tests/dnssectime_unittest.cc (original)
+++ trunk/src/lib/dns/tests/dnssectime_unittest.cc Sat May 29 22:49:06 2010
@@ -64,7 +64,8 @@
TEST(DNSSECTimeTest, overflow) {
// Jan 1, Year 10,000.
if (sizeof(time_t) > 4) {
- EXPECT_THROW(timeToText(253402300800LL), InvalidTime);
+ EXPECT_THROW(timeToText(static_cast<time_t>(253402300800LL)),
+ InvalidTime);
}
}
Modified: trunk/src/lib/exceptions/Makefile.am
==============================================================================
--- trunk/src/lib/exceptions/Makefile.am (original)
+++ trunk/src/lib/exceptions/Makefile.am Sat May 29 22:49:06 2010
@@ -1,3 +1,4 @@
+AM_CXXFLAGS=$(B10_CXXFLAGS)
lib_LTLIBRARIES = libexceptions.la
libexceptions_la_SOURCES = exceptions.h exceptions.cc
Modified: trunk/src/lib/xfr/Makefile.am
==============================================================================
--- trunk/src/lib/xfr/Makefile.am (original)
+++ trunk/src/lib/xfr/Makefile.am Sat May 29 22:49:06 2010
@@ -2,11 +2,10 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
-AM_CPPFLAGS += -I$(top_srcdir)/ext -Wno-strict-aliasing
+AM_CPPFLAGS += -I$(top_srcdir)/ext
-if GCC_WERROR_OK
-AM_CPPFLAGS += -Werror
-endif
+AM_CXXFLAGS = $(B10_CXXFLAGS) -Wno-strict-aliasing
+AM_CXXFLAGS += -Wno-unused-parameter # see src/lib/cc/Makefile.am
CLEANFILES = *.gcno *.gcda
@@ -18,10 +17,11 @@
pyexec_LTLIBRARIES = bind10_xfr.la
bind10_xfr_la_SOURCES = python_xfr.cc fd_share.cc fd_share.h
bind10_xfr_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
+bind10_xfr_la_CXXFLAGS = $(AM_CXXFLAGS)
if GCC_WERROR_OK
# XXX: Boost.Python triggers strict aliasing violation, so if we use -Werror
# we need to suppress the warnings.
-bind10_xfr_la_CPPFLAGS += -fno-strict-aliasing
+bind10_xfr_la_CXXFLAGS += -fno-strict-aliasing
endif
bind10_xfr_la_LDFLAGS = $(BOOST_LDFLAGS) $(PYTHON_LDFLAGS)
# Python prefers .so, while some OSes (specifically MacOS) use a different
Modified: trunk/src/lib/xfr/xfrout_client.cc
==============================================================================
--- trunk/src/lib/xfr/xfrout_client.cc (original)
+++ trunk/src/lib/xfr/xfrout_client.cc Sat May 29 22:49:06 2010
@@ -17,46 +17,72 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
+
+#include <asio.hpp>
+
#include "fd_share.h"
#include "xfrout_client.h"
-using boost::asio::local::stream_protocol;
+using namespace std;
+using asio::local::stream_protocol;
namespace isc {
namespace xfr {
+struct XfroutClientImpl {
+ XfroutClientImpl(const string& file);
+ const std::string file_path_;
+ asio::io_service io_service_;
+ // The socket used to communicate with the xfrout server.
+ stream_protocol::socket socket_;
+};
+
+XfroutClientImpl::XfroutClientImpl(const string& file) :
+ file_path_(file), socket_(io_service_)
+{}
+
+XfroutClient::XfroutClient(const string& file) :
+ impl_(new XfroutClientImpl(file))
+{}
+
+XfroutClient::~XfroutClient()
+{
+ delete impl_;
+}
+
void
XfroutClient::connect() {
- socket_.connect(stream_protocol::endpoint(file_path_));
+ impl_->socket_.connect(stream_protocol::endpoint(impl_->file_path_));
}
void
XfroutClient::disconnect() {
- socket_.close();
+ impl_->socket_.close();
}
int
XfroutClient::sendXfroutRequestInfo(const int tcp_sock, uint8_t* msg_data,
const uint16_t msg_len)
{
- if (-1 == send_fd(socket_.native(), tcp_sock)) {
+ if (-1 == send_fd(impl_->socket_.native(), tcp_sock)) {
isc_throw(XfroutError,
"Fail to send socket descriptor to xfrout module");
}
// XXX: this shouldn't be blocking send, even though it's unlikely to block.
const uint8_t lenbuf[2] = { msg_len >> 8, msg_len & 0xff };
- if (send(socket_.native(), lenbuf, sizeof(lenbuf), 0) != sizeof(lenbuf)) {
+ if (send(impl_->socket_.native(), lenbuf, sizeof(lenbuf), 0) !=
+ sizeof(lenbuf)) {
isc_throw(XfroutError,
"failed to send XFR request length to xfrout module");
}
- if (send(socket_.native(), msg_data, msg_len, 0) != msg_len) {
+ if (send(impl_->socket_.native(), msg_data, msg_len, 0) != msg_len) {
isc_throw(XfroutError,
"failed to send XFR request data to xfrout module");
}
int databuf = 0;
- if (recv(socket_.native(), &databuf, sizeof(int), 0) != 0) {
+ if (recv(impl_->socket_.native(), &databuf, sizeof(int), 0) != 0) {
isc_throw(XfroutError,
"xfr query hasn't been processed properly by xfrout module");
}
Modified: trunk/src/lib/xfr/xfrout_client.h
==============================================================================
--- trunk/src/lib/xfr/xfrout_client.h (original)
+++ trunk/src/lib/xfr/xfrout_client.h Sat May 29 22:49:06 2010
@@ -17,13 +17,16 @@
#ifndef _XFROUT_CLIENT_H
#define _XFROUT_CLIENT_H
+#include <stdint.h>
+
#include <string>
-#include <boost/asio.hpp>
#include <exceptions/exceptions.h>
namespace isc {
namespace xfr {
+
+struct XfroutClientImpl;
class XfroutError: public Exception {
public:
@@ -31,22 +34,21 @@
isc::Exception(file, line, what) {}
};
-using boost::asio::local::stream_protocol;
class XfroutClient {
public:
- XfroutClient(const std::string& file):
- socket_(io_service_), file_path_(file) {}
-
+ XfroutClient(const std::string& file);
+ ~XfroutClient();
+private:
+ // make this class non copyable
+ XfroutClient(const XfroutClient& source);
+ XfroutClient& operator=(const XfroutClient& source);
+public:
void connect();
void disconnect();
int sendXfroutRequestInfo(int tcp_sock, uint8_t* msg_data,
uint16_t msg_len);
-
private:
- boost::asio::io_service io_service_;
- // The socket used to communicate with the xfrout server.
- stream_protocol::socket socket_;
- const std::string file_path_;
+ XfroutClientImpl* impl_;
};
} // End for namespace xfr
More information about the bind10-changes
mailing list