[svn] commit: r1953 - in /branches/trac168: ./ src/bin/auth/ src/bin/auth/tests/ src/bin/host/ src/lib/cc/ src/lib/config/ src/lib/config/tests/ src/lib/datasrc/ src/lib/datasrc/tests/ src/lib/dns/ src/lib/dns/tests/ src/lib/exceptions/ src/lib/xfr/
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 28 00:42:50 UTC 2010
Author: jinmei
Date: Fri May 28 00:42:50 2010
New Revision: 1953
Log:
addressed some portability issues with non boost ASIO:
- suppress the gcc unused parameters warning selectively (as a workaround) in a most portable way
- introduce B10_CXXFLAGS as the default to AM_CXXFLAGS to make the first change possible (that's why I modified so many other Makefile.am's even if they are irrelevant to asio)
- remove dependency on boost system library: it was only needed for the boost version of ASIO.
- hide details that require ASIO related definitions from xfr_client.h to avoid being hit by the 'unused parameter' problem accidentally.
Modified:
branches/trac168/configure.ac
branches/trac168/src/bin/auth/Makefile.am
branches/trac168/src/bin/auth/asio_link.cc
branches/trac168/src/bin/auth/main.cc
branches/trac168/src/bin/auth/tests/Makefile.am
branches/trac168/src/bin/host/Makefile.am
branches/trac168/src/lib/cc/Makefile.am
branches/trac168/src/lib/cc/session.cc
branches/trac168/src/lib/config/Makefile.am
branches/trac168/src/lib/config/tests/Makefile.am
branches/trac168/src/lib/datasrc/Makefile.am
branches/trac168/src/lib/datasrc/tests/Makefile.am
branches/trac168/src/lib/dns/Makefile.am
branches/trac168/src/lib/dns/tests/Makefile.am
branches/trac168/src/lib/exceptions/Makefile.am
branches/trac168/src/lib/xfr/Makefile.am
branches/trac168/src/lib/xfr/xfrout_client.cc
branches/trac168/src/lib/xfr/xfrout_client.h
Modified: branches/trac168/configure.ac
==============================================================================
--- branches/trac168/configure.ac (original)
+++ branches/trac168/configure.ac Fri May 28 00:42:50 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/boost"
-
- 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
@@ -476,9 +446,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: branches/trac168/src/bin/auth/Makefile.am
==============================================================================
--- branches/trac168/src/bin/auth/Makefile.am (original)
+++ branches/trac168/src/bin/auth/Makefile.am Fri May 28 00:42:50 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@
@@ -34,7 +33,10 @@
# only for which we accept the unused-parameter warning.
lib_LIBRARIES = libasio_link.a
libasio_link_a_SOURCES = asio_link.cc asio_link.h
-libasio_link_a_CPPFLAGS = $(AM_CPPFLAGS) -Wno-error=unused-parameter
+# 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
Modified: branches/trac168/src/bin/auth/asio_link.cc
==============================================================================
--- branches/trac168/src/bin/auth/asio_link.cc (original)
+++ branches/trac168/src/bin/auth/asio_link.cc Fri May 28 00:42:50 2010
@@ -14,11 +14,6 @@
// $Id$
-// Suppress "unused parameter" warnings that turn up in the ASIO code
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
#include <config.h>
#include <asio.hpp>
@@ -28,15 +23,66 @@
#include <dns/message.h>
#include <dns/messagerenderer.h>
+#if defined(HAVE_BOOST_PYTHON)
+#define USE_XFROUT
+#include <xfr/xfrout_client.h>
+#endif
+
#include <asio_link.h>
+#include "spec_config.h" // for XFROUT. should not be here.
#include "auth_srv.h"
using namespace asio;
using ip::udp;
using ip::tcp;
+using namespace std;
using namespace isc::dns;
+#ifdef USE_XFROUT
+using namespace isc::xfr;
+#endif
+
+namespace {
+// As a short term workaround, we have XFROUT specific code. We should soon
+// refactor the code with some abstraction so that we can separate this level
+// details from the (AS)IO module.
+#ifdef USE_XFROUT
+//TODO. The sample way for checking axfr query, the code should be merged to auth server class
+bool
+check_axfr_query(char* const msg_data, const uint16_t msg_len) {
+ if (msg_len < 15) {
+ return false;
+ }
+
+ const 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
+void
+dispatch_axfr_query(const int tcp_sock, char const axfr_query[],
+ const uint16_t query_len)
+{
+ string path(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 exception & err) {
+ //if (verbose_mode)
+ cerr << "error handle xfr query:" << err.what() << endl;
+ }
+}
+#endif
+}
namespace asio_link {
//
Modified: branches/trac168/src/bin/auth/main.cc
==============================================================================
--- branches/trac168/src/bin/auth/main.cc (original)
+++ branches/trac168/src/bin/auth/main.cc Fri May 28 00:42:50 2010
@@ -39,21 +39,12 @@
#include <cc/data.h>
#include <config/ccsession.h>
-#if 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
-
using namespace isc::data;
using namespace isc::cc;
using namespace isc::config;
@@ -92,39 +83,6 @@
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
void
usage() {
Modified: branches/trac168/src/bin/auth/tests/Makefile.am
==============================================================================
--- branches/trac168/src/bin/auth/tests/Makefile.am (original)
+++ branches/trac168/src/bin/auth/tests/Makefile.am Fri May 28 00:42:50 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
Modified: branches/trac168/src/bin/host/Makefile.am
==============================================================================
--- branches/trac168/src/bin/host/Makefile.am (original)
+++ branches/trac168/src/bin/host/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/cc/Makefile.am
==============================================================================
--- branches/trac168/src/lib/cc/Makefile.am (original)
+++ branches/trac168/src/lib/cc/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/cc/session.cc
==============================================================================
--- branches/trac168/src/lib/cc/session.cc (original)
+++ branches/trac168/src/lib/cc/session.cc Fri May 28 00:42:50 2010
@@ -14,12 +14,7 @@
// $Id$
-// Suppress "unused parameter" warnings that turn up in the ASIO code
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-#include "config.h"
+#include <config.h>
#include <stdint.h>
Modified: branches/trac168/src/lib/config/Makefile.am
==============================================================================
--- branches/trac168/src/lib/config/Makefile.am (original)
+++ branches/trac168/src/lib/config/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/config/tests/Makefile.am
==============================================================================
--- branches/trac168/src/lib/config/tests/Makefile.am (original)
+++ branches/trac168/src/lib/config/tests/Makefile.am Fri May 28 00:42:50 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
Modified: branches/trac168/src/lib/datasrc/Makefile.am
==============================================================================
--- branches/trac168/src/lib/datasrc/Makefile.am (original)
+++ branches/trac168/src/lib/datasrc/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/datasrc/tests/Makefile.am
==============================================================================
--- branches/trac168/src/lib/datasrc/tests/Makefile.am (original)
+++ branches/trac168/src/lib/datasrc/tests/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/dns/Makefile.am
==============================================================================
--- branches/trac168/src/lib/dns/Makefile.am (original)
+++ branches/trac168/src/lib/dns/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/dns/tests/Makefile.am
==============================================================================
--- branches/trac168/src/lib/dns/tests/Makefile.am (original)
+++ branches/trac168/src/lib/dns/tests/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/exceptions/Makefile.am
==============================================================================
--- branches/trac168/src/lib/exceptions/Makefile.am (original)
+++ branches/trac168/src/lib/exceptions/Makefile.am Fri May 28 00:42:50 2010
@@ -1,3 +1,4 @@
+AM_CXXFLAGS=$(B10_CXXFLAGS)
lib_LTLIBRARIES = libexceptions.la
libexceptions_la_SOURCES = exceptions.h exceptions.cc
Modified: branches/trac168/src/lib/xfr/Makefile.am
==============================================================================
--- branches/trac168/src/lib/xfr/Makefile.am (original)
+++ branches/trac168/src/lib/xfr/Makefile.am Fri May 28 00:42:50 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: branches/trac168/src/lib/xfr/xfrout_client.cc
==============================================================================
--- branches/trac168/src/lib/xfr/xfrout_client.cc (original)
+++ branches/trac168/src/lib/xfr/xfrout_client.cc Fri May 28 00:42:50 2010
@@ -17,46 +17,72 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
+
+#include <asio.hpp>
+
#include "fd_share.h"
#include "xfrout_client.h"
+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: branches/trac168/src/lib/xfr/xfrout_client.h
==============================================================================
--- branches/trac168/src/lib/xfr/xfrout_client.h (original)
+++ branches/trac168/src/lib/xfr/xfrout_client.h Fri May 28 00:42:50 2010
@@ -17,13 +17,16 @@
#ifndef _XFROUT_CLIENT_H
#define _XFROUT_CLIENT_H
+#include <stdint.h>
+
#include <string>
-#include <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 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:
- 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