[svn] commit: r3374 - in /branches/trac364: ./ src/bin/ src/bin/auth/benchmarks/ src/bin/auth/tests/ src/bin/bind10/ src/bin/bind10/tests/ src/bin/cmdctl/ src/bin/loadzone/tests/error/ src/bin/stats/ src/bin/stats/test/ src/bin/stats/tests/ src/bin/stats/tests/isc/ src/bin/stats/tests/isc/util/ src/bin/xfrin/ src/bin/xfrin/tests/ src/bin/xfrout/ src/bin/zonemgr/ src/bin/zonemgr/tests/ src/lib/cc/ src/lib/cc/tests/ src/lib/config/ src/lib/config/testdata/ src/lib/config/tests/ src/lib/datasrc/ src/lib/datasrc/tests/ src/lib/dns/ src/lib/dns/rdata/ src/lib/dns/rdata/ch_3/ src/lib/dns/rdata/generic/ src/lib/dns/rdata/hs_4/ src/lib/dns/tests/ src/lib/dns/util/ src/lib/exceptions/ src/lib/exceptions/tests/ src/lib/python/isc/ src/lib/python/isc/config/ src/lib/python/isc/config/tests/ src/lib/python/isc/datasrc/ src/lib/python/isc/net/ src/lib/python/isc/notify/ src/lib/python/isc/notify/tests/ src/lib/python/isc/util/ src/lib/python/isc/util/tests/ src/lib/xfr/
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Oct 27 13:42:53 UTC 2010
Author: zhanglikun
Date: Wed Oct 27 13:42:53 2010
New Revision: 3374
Log:
Merge trunk back to this branch
Added:
branches/trac364/src/bin/stats/Makefile.am
- copied unchanged from r3367, trunk/src/bin/stats/Makefile.am
branches/trac364/src/bin/stats/b10-stats.8
- copied unchanged from r3367, trunk/src/bin/stats/b10-stats.8
branches/trac364/src/bin/stats/b10-stats.xml
- copied unchanged from r3367, trunk/src/bin/stats/b10-stats.xml
branches/trac364/src/bin/stats/run_b10-stats.sh.in
- copied unchanged from r3367, trunk/src/bin/stats/run_b10-stats.sh.in
branches/trac364/src/bin/stats/run_b10-stats_stub.sh.in
- copied unchanged from r3367, trunk/src/bin/stats/run_b10-stats_stub.sh.in
branches/trac364/src/bin/stats/stats.py.in
- copied, changed from r3367, trunk/src/bin/stats/stats.py.in
branches/trac364/src/bin/stats/stats.spec.pre.in
- copied unchanged from r3367, trunk/src/bin/stats/stats.spec.pre.in
branches/trac364/src/bin/stats/stats_stub.py.in
- copied, changed from r3367, trunk/src/bin/stats/stats_stub.py.in
branches/trac364/src/bin/stats/tests/
- copied from r3367, trunk/src/bin/stats/tests/
branches/trac364/src/bin/stats/tests/isc/util/
- copied from r3367, trunk/src/bin/stats/tests/isc/utils/
branches/trac364/src/lib/python/isc/net/
- copied from r3367, trunk/src/lib/python/isc/net/
branches/trac364/src/lib/python/isc/util/socketserver_mixin.py
branches/trac364/src/lib/python/isc/util/tests/socketserver_mixin_test.py
Removed:
branches/trac364/src/bin/stats/statsd.py
branches/trac364/src/bin/stats/statsd.txt
branches/trac364/src/bin/stats/test/
branches/trac364/src/bin/stats/test_total.py
branches/trac364/src/bin/xfrin/xfrin.spec.pre.in
branches/trac364/src/lib/config/testdata/
Modified:
branches/trac364/ (props changed)
branches/trac364/ChangeLog
branches/trac364/configure.ac
branches/trac364/src/bin/Makefile.am
branches/trac364/src/bin/auth/benchmarks/query_bench.cc
branches/trac364/src/bin/auth/tests/Makefile.am
branches/trac364/src/bin/auth/tests/run_unittests.cc
branches/trac364/src/bin/bind10/bind10.py.in
branches/trac364/src/bin/bind10/run_bind10.sh.in
branches/trac364/src/bin/bind10/tests/bind10_test.py
branches/trac364/src/bin/cmdctl/Makefile.am
branches/trac364/src/bin/cmdctl/cmdctl.py.in (contents, props changed)
branches/trac364/src/bin/loadzone/tests/error/error.known
branches/trac364/src/bin/stats/tests/isc/Makefile.am
branches/trac364/src/bin/stats/tests/isc/util/process.py
branches/trac364/src/bin/xfrin/Makefile.am
branches/trac364/src/bin/xfrin/tests/xfrin_test.py
branches/trac364/src/bin/xfrin/xfrin.py.in
branches/trac364/src/bin/xfrout/xfrout.py.in
branches/trac364/src/bin/zonemgr/tests/Makefile.am
branches/trac364/src/bin/zonemgr/tests/zonemgr_test.py
branches/trac364/src/bin/zonemgr/zonemgr.py.in
branches/trac364/src/bin/zonemgr/zonemgr.spec.pre.in
branches/trac364/src/lib/cc/data.cc
branches/trac364/src/lib/cc/tests/run_unittests.cc
branches/trac364/src/lib/config/ccsession.cc
branches/trac364/src/lib/config/ccsession.h
branches/trac364/src/lib/config/config_data.h
branches/trac364/src/lib/config/module_spec.cc
branches/trac364/src/lib/config/module_spec.h
branches/trac364/src/lib/config/tests/ccsession_unittests.cc
branches/trac364/src/lib/config/tests/module_spec_unittests.cc
branches/trac364/src/lib/config/tests/run_unittests.cc
branches/trac364/src/lib/datasrc/static_datasrc.cc
branches/trac364/src/lib/datasrc/tests/run_unittests.cc
branches/trac364/src/lib/dns/gen-rdatacode.py.in
branches/trac364/src/lib/dns/message.cc
branches/trac364/src/lib/dns/message.h
branches/trac364/src/lib/dns/name.h
branches/trac364/src/lib/dns/question.cc
branches/trac364/src/lib/dns/rdata.cc
branches/trac364/src/lib/dns/rdata/ch_3/a_1.cc
branches/trac364/src/lib/dns/rdata/generic/cname_5.cc
branches/trac364/src/lib/dns/rdata/generic/dname_39.cc
branches/trac364/src/lib/dns/rdata/generic/dnskey_48.cc
branches/trac364/src/lib/dns/rdata/generic/ds_43.cc
branches/trac364/src/lib/dns/rdata/generic/mx_15.cc
branches/trac364/src/lib/dns/rdata/generic/mx_15.h
branches/trac364/src/lib/dns/rdata/generic/ns_2.cc
branches/trac364/src/lib/dns/rdata/generic/nsec3_50.cc
branches/trac364/src/lib/dns/rdata/generic/nsec3param_51.cc
branches/trac364/src/lib/dns/rdata/generic/opt_41.cc
branches/trac364/src/lib/dns/rdata/generic/ptr_12.cc
branches/trac364/src/lib/dns/rdata/generic/rrsig_46.cc
branches/trac364/src/lib/dns/rdata/generic/soa_6.cc
branches/trac364/src/lib/dns/rdata/generic/soa_6.h
branches/trac364/src/lib/dns/rdata/hs_4/a_1.cc
branches/trac364/src/lib/dns/rdata/template.cc
branches/trac364/src/lib/dns/rrclass-placeholder.h
branches/trac364/src/lib/dns/rrclass.cc
branches/trac364/src/lib/dns/rrparamregistry-placeholder.cc
branches/trac364/src/lib/dns/rrset.cc
branches/trac364/src/lib/dns/rrset.h
branches/trac364/src/lib/dns/rrsetlist.cc
branches/trac364/src/lib/dns/rrttl.cc
branches/trac364/src/lib/dns/rrtype-placeholder.h
branches/trac364/src/lib/dns/rrtype.cc
branches/trac364/src/lib/dns/tests/Makefile.am
branches/trac364/src/lib/dns/tests/buffer_unittest.cc
branches/trac364/src/lib/dns/tests/name_unittest.cc
branches/trac364/src/lib/dns/tests/question_unittest.cc
branches/trac364/src/lib/dns/tests/rdata_cname_unittest.cc
branches/trac364/src/lib/dns/tests/rdata_dname_unittest.cc
branches/trac364/src/lib/dns/tests/rdata_ns_unittest.cc
branches/trac364/src/lib/dns/tests/rdata_opt_unittest.cc
branches/trac364/src/lib/dns/tests/rdata_ptr_unittest.cc
branches/trac364/src/lib/dns/tests/rdata_unittest.cc
branches/trac364/src/lib/dns/tests/rrclass_unittest.cc
branches/trac364/src/lib/dns/tests/rrparamregistry_unittest.cc
branches/trac364/src/lib/dns/tests/rrset_unittest.cc
branches/trac364/src/lib/dns/tests/rrttl_unittest.cc
branches/trac364/src/lib/dns/tests/rrtype_unittest.cc
branches/trac364/src/lib/dns/util/sha1.cc
branches/trac364/src/lib/exceptions/exceptions.cc
branches/trac364/src/lib/exceptions/tests/run_unittests.cc
branches/trac364/src/lib/python/isc/Makefile.am
branches/trac364/src/lib/python/isc/config/ccsession.py
branches/trac364/src/lib/python/isc/config/module_spec.py
branches/trac364/src/lib/python/isc/config/tests/ccsession_test.py
branches/trac364/src/lib/python/isc/config/tests/cfgmgr_test.py
branches/trac364/src/lib/python/isc/config/tests/unittest_fakesession.py
branches/trac364/src/lib/python/isc/datasrc/master.py
branches/trac364/src/lib/python/isc/notify/notify_out.py
branches/trac364/src/lib/python/isc/notify/tests/notify_out_test.py
branches/trac364/src/lib/python/isc/util/Makefile.am
branches/trac364/src/lib/python/isc/util/__init__.py
branches/trac364/src/lib/python/isc/util/tests/Makefile.am
branches/trac364/src/lib/xfr/python_xfr.cc
branches/trac364/src/lib/xfr/xfrout_client.cc
Modified: branches/trac364/ChangeLog
==============================================================================
--- branches/trac364/ChangeLog (original)
+++ branches/trac364/ChangeLog Wed Oct 27 13:42:53 2010
@@ -1,13 +1,61 @@
- 105. [func]* zhanglikun
+ 113. [func]* zhanglikun
Folder name 'utils'(the folder in /src/lib/python/isc/) has been
renamed to 'util'. Programs that used 'import isc.utils.process'
now need to use 'import isc.util.process'. The folder
/src/lib/python/isc/Util is removed since it isn't used by any
program. (Trac #364, rTBD)
+ 112. [func] zhang likun
+ Add one mixin class to override the naive serve_forever() provided
+ in python library socketserver. Instead of polling for shutdwon
+ every poll_interval seconds, one socketpair is used to wake up
+ the waiting server.(Trac #352, svn r3366)
+
+ 111. [bug]* zhanglikun, Michal Vaner
+ Make sure process xfrin/xfrout/zonemgr/cmdctl can be stoped
+ properly when user enter "ctrl+c" or 'Boss shutdown' command
+ through bindctl.
+
+ The ZonemgrRefresh.run_timer and NotifyOut.dispatcher spawn
+ a thread themselves.
+ (Trac #335, svn r3273)
+
+ 110. [func] Michal Vaner
+ Added isc.net.check module to check ip addresses and ports for
+ correctness and isc.net.addr to hold IP address. The bind10, xfrin
+ and cmdctl programs are modified to use it.
+ (Trac #353, svn r3240)
+
+ 109. [func] naokikambe
+ Added the initial version of the stats module for the statistics
+ feature of BIND 10, which supports the restricted features and
+ items and reports via bindctl command (Trac #191, r3218)
+ Added the document of the stats module, which is about how stats
+ module collects the data (Trac #170, [wiki:StatsModule])
+
+ 108. [func] jerry
+ src/bin/zonemgr: Provide customizable configurations for
+ lowerbound_refresh, lowerbound_retry, max_transfer_timeout and
+ jitter_scope. (Trac #340, r3205)
+
+ 107. [func] zhang likun
+ Remove the parameter 'db_file' for command 'retransfer' of
+ xfrin module. xfrin.spec will not be generated by script.
+ (Trac #329, r3171)
+
+ 106. [bug] zhang likun
+ When xfrin can't connect with one zone's master, it should tell
+ the bad news to zonemgr, so that zonemgr can reset the timer for
+ that zone. (Trac #329, r3170)
+
+ 105. [bug] Michal Vaner
+ Python processes: they no longer take 100% CPU while idle
+ due to a busy loop in reading command session in a nonblocking way.
+ (Trac #349, svn r3153), (Trac #382, svn r3294)
+
104. [bug] jerry
bin/zonemgr: zonemgr should be attempting to refresh expired zones.
- (Trac #336, r3139)
+ (Trac #336, r3139)
103. [bug] jerry
lib/python/isc/log: Fixed an issue with python logging,
Modified: branches/trac364/configure.ac
==============================================================================
--- branches/trac364/configure.ac (original)
+++ branches/trac364/configure.ac Wed Oct 27 13:42:53 2010
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
-AC_INIT(bind10-devel, 20100701, bind10-dev at isc.org)
+AC_INIT(bind10-devel, 20101013, bind10-dev at isc.org)
AC_CONFIG_SRCDIR(README)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h])
@@ -261,7 +261,6 @@
[ --with-gtest=PATH specify a path to gtest header files (PATH/include) and library (PATH/lib)],
gtest_path="$withval", gtest_path="no")
-
USE_LCOV="no"
if test "$lcov" != "no"; then
# force gtest if not set
@@ -435,7 +434,7 @@
fi
AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
- [regenerate man pages [default=no]])] ,enable_man=yes, enable_man=no)
+ [regenerate man pages [default=no]])], enable_man=yes, enable_man=no)
AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
@@ -472,6 +471,13 @@
src/bin/xfrout/tests/Makefile
src/bin/zonemgr/Makefile
src/bin/zonemgr/tests/Makefile
+ src/bin/stats/Makefile
+ src/bin/stats/tests/Makefile
+ src/bin/stats/tests/isc/Makefile
+ src/bin/stats/tests/isc/cc/Makefile
+ src/bin/stats/tests/isc/config/Makefile
+ src/bin/stats/tests/isc/util/Makefile
+ src/bin/stats/tests/testdata/Makefile
src/bin/usermgr/Makefile
src/bin/tests/Makefile
src/lib/Makefile
@@ -491,6 +497,8 @@
src/lib/python/isc/config/tests/Makefile
src/lib/python/isc/log/Makefile
src/lib/python/isc/log/tests/Makefile
+ src/lib/python/isc/net/Makefile
+ src/lib/python/isc/net/tests/Makefile
src/lib/python/isc/notify/Makefile
src/lib/python/isc/notify/tests/Makefile
src/lib/config/Makefile
@@ -515,7 +523,6 @@
src/bin/cmdctl/cmdctl.spec.pre
src/bin/xfrin/tests/xfrin_test
src/bin/xfrin/xfrin.py
- src/bin/xfrin/xfrin.spec.pre
src/bin/xfrin/run_b10-xfrin.sh
src/bin/xfrout/xfrout.py
src/bin/xfrout/xfrout.spec.pre
@@ -525,6 +532,12 @@
src/bin/zonemgr/zonemgr.spec.pre
src/bin/zonemgr/tests/zonemgr_test
src/bin/zonemgr/run_b10-zonemgr.sh
+ src/bin/stats/stats.py
+ src/bin/stats/stats_stub.py
+ src/bin/stats/stats.spec.pre
+ src/bin/stats/run_b10-stats.sh
+ src/bin/stats/run_b10-stats_stub.sh
+ src/bin/stats/tests/stats_test
src/bin/bind10/bind10.py
src/bin/bind10/tests/bind10_test
src/bin/bind10/run_bind10.sh
@@ -558,6 +571,9 @@
chmod +x src/bin/xfrin/run_b10-xfrin.sh
chmod +x src/bin/xfrout/run_b10-xfrout.sh
chmod +x src/bin/zonemgr/run_b10-zonemgr.sh
+ chmod +x src/bin/stats/tests/stats_test
+ chmod +x src/bin/stats/run_b10-stats.sh
+ chmod +x src/bin/stats/run_b10-stats_stub.sh
chmod +x src/bin/bind10/run_bind10.sh
chmod +x src/bin/cmdctl/tests/cmdctl_test
chmod +x src/bin/xfrin/tests/xfrin_test
Modified: branches/trac364/src/bin/Makefile.am
==============================================================================
--- branches/trac364/src/bin/Makefile.am (original)
+++ branches/trac364/src/bin/Makefile.am Wed Oct 27 13:42:53 2010
@@ -1,4 +1,4 @@
SUBDIRS = bind10 bindctl cfgmgr loadzone msgq host cmdctl auth xfrin xfrout \
- usermgr zonemgr tests
+ usermgr zonemgr stats tests
check-recursive: all-recursive
Modified: branches/trac364/src/bin/auth/benchmarks/query_bench.cc
==============================================================================
--- branches/trac364/src/bin/auth/benchmarks/query_bench.cc (original)
+++ branches/trac364/src/bin/auth/benchmarks/query_bench.cc Wed Oct 27 13:42:53 2010
@@ -38,6 +38,7 @@
using namespace std;
using namespace isc;
+using namespace isc::data;
using namespace isc::dns;
using namespace isc::xfr;
using namespace isc::bench;
Modified: branches/trac364/src/bin/auth/tests/Makefile.am
==============================================================================
--- branches/trac364/src/bin/auth/tests/Makefile.am (original)
+++ branches/trac364/src/bin/auth/tests/Makefile.am Wed Oct 27 13:42:53 2010
@@ -4,7 +4,7 @@
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_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(top_builddir)/src/bin/auth/tests/testdata\"
+AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/bin/auth/tests/testdata\"
AM_CXXFLAGS = $(B10_CXXFLAGS)
Modified: branches/trac364/src/bin/auth/tests/run_unittests.cc
==============================================================================
--- branches/trac364/src/bin/auth/tests/run_unittests.cc (original)
+++ branches/trac364/src/bin/auth/tests/run_unittests.cc Wed Oct 27 13:42:53 2010
@@ -19,8 +19,7 @@
#include <dns/tests/unittest_util.h>
int
-main(int argc, char* argv[])
-{
+main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
isc::UnitTestUtil::addDataPath(TEST_DATA_DIR);
isc::UnitTestUtil::addDataPath(TEST_DATA_BUILDDIR);
Modified: branches/trac364/src/bin/bind10/bind10.py.in
==============================================================================
--- branches/trac364/src/bin/bind10/bind10.py.in (original)
+++ branches/trac364/src/bin/bind10/bind10.py.in Wed Oct 27 13:42:53 2010
@@ -64,6 +64,7 @@
import isc.cc
import isc.util.process
+import isc.net.parse
# Assign this process some longer name
isc.util.process.rename(sys.argv[0])
@@ -72,6 +73,9 @@
# The VERSION string consists of the module name, the module version
# number, and the overall BIND 10 version number (set in configure.ac).
VERSION = "bind10 20100916 (BIND 10 @PACKAGE_VERSION@)"
+
+# This is for bind10.boottime of stats module
+_BASETIME = time.gmtime()
class RestartSchedule:
"""
@@ -180,35 +184,10 @@
def respawn(self):
self._spawn()
-class IPAddr:
- """Stores an IPv4 or IPv6 address."""
- family = None
- addr = None
-
- def __init__(self, addr):
- try:
- a = socket.inet_pton(socket.AF_INET, addr)
- self.family = socket.AF_INET
- self.addr = a
- return
- except:
- pass
-
- try:
- a = socket.inet_pton(socket.AF_INET6, addr)
- self.family = socket.AF_INET6
- self.addr = a
- return
- except Exception as e:
- raise e
-
- def __str__(self):
- return socket.inet_ntop(self.family, self.addr)
-
class BoB:
"""Boss of BIND class."""
- def __init__(self, msgq_socket_file=None, auth_port=5300, address='',
+ def __init__(self, msgq_socket_file=None, auth_port=5300, address=None,
nocache=False, verbose=False, setuid=None, username=None):
"""Initialize the Boss of BIND. This is a singleton (only one
can run).
@@ -222,7 +201,7 @@
self.auth_port = auth_port
self.address = None
if address:
- self.address = IPAddr(address)
+ self.address = address
self.cc_session = None
self.ccs = None
self.processes = {}
@@ -424,6 +403,27 @@
sys.stdout.write("[bind10] Started b10-zonemgr(PID %d)\n" %
zonemgr.pid)
+ # start b10-stats
+ stats_args = ['b10-stats']
+ if self.verbose:
+ sys.stdout.write("[bind10] Starting b10-stats\n")
+ stats_args += ['-v']
+ try:
+ statsd = ProcessInfo("b10-stats", stats_args,
+ c_channel_env)
+ except Exception as e:
+ c_channel.process.kill()
+ bind_cfgd.process.kill()
+ xfrout.process.kill()
+ auth.process.kill()
+ xfrind.process.kill()
+ zonemgr.process.kill()
+ return "Unable to start b10-stats; " + str(e)
+
+ self.processes[statsd.pid] = statsd
+ if self.verbose:
+ sys.stdout.write("[bind10] Started b10-stats (PID %d)\n" % statsd.pid)
+
# start the b10-cmdctl
# XXX: we hardcode port 8080
cmdctl_args = ['b10-cmdctl']
@@ -440,6 +440,7 @@
auth.process.kill()
xfrind.process.kill()
zonemgr.process.kill()
+ statsd.process.kill()
return "Unable to start b10-cmdctl; " + str(e)
self.processes[cmd_ctrld.pid] = cmd_ctrld
if self.verbose:
@@ -453,12 +454,13 @@
def stop_all_processes(self):
"""Stop all processes."""
cmd = { "command": ['shutdown']}
- self.cc_session.group_sendmsg(cmd, 'Boss', 'Cmdctl')
- self.cc_session.group_sendmsg(cmd, "Boss", "ConfigManager")
- self.cc_session.group_sendmsg(cmd, "Boss", "Auth")
- self.cc_session.group_sendmsg(cmd, "Boss", "Xfrout")
- self.cc_session.group_sendmsg(cmd, "Boss", "Xfrin")
- self.cc_session.group_sendmsg(cmd, "Boss", "Zonemgr")
+ self.cc_session.group_sendmsg(cmd, 'Cmdctl', 'Cmdctl')
+ self.cc_session.group_sendmsg(cmd, "ConfigManager", "ConfigManager")
+ self.cc_session.group_sendmsg(cmd, "Auth", "Auth")
+ self.cc_session.group_sendmsg(cmd, "Xfrout", "Xfrout")
+ self.cc_session.group_sendmsg(cmd, "Xfrin", "Xfrin")
+ self.cc_session.group_sendmsg(cmd, "Zonemgr", "Zonemgr")
+ self.cc_session.group_sendmsg(cmd, "Boss", "Stats")
def stop_process(self, process):
"""Stop the given process, friendly-like."""
@@ -475,7 +477,9 @@
except:
pass
# XXX: some delay probably useful... how much is uncertain
- time.sleep(0.5)
+ # I have changed the delay from 0.5 to 1, but sometime it's
+ # still not enough.
+ time.sleep(1)
self.reap_children()
# next try sending a SIGTERM
processes_to_stop = list(self.processes.values())
@@ -582,7 +586,7 @@
# the Python signal handler has been set up to write
# down a pipe, waking up our select() bit
pass
-
+
def get_signame(signal_number):
"""Return the symbolic name for a signal."""
for sig in dir(signal):
@@ -604,26 +608,24 @@
def check_port(option, opt_str, value, parser):
"""Function to insure that the port we are passed is actually
a valid port number. Used by OptionParser() on startup."""
- if not re.match('^(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)$', value):
- raise OptionValueError("%s requires a port number (0-65535)" % opt_str)
- if (opt_str == '-m' or opt_str == '--msgq-port'):
- parser.values.msgq_port = value
- elif (opt_str == '-p' or opt_str == '--port'):
- parser.values.auth_port = value
- else:
- raise OptionValueError("Unknown option " + opt_str)
-
+ try:
+ if opt_str in ['-p', '--port']:
+ parser.values.auth_port = isc.net.parse.port_parse(value)
+ else:
+ raise OptionValueError("Unknown option " + opt_str)
+ except ValueError as e:
+ raise OptionValueError(str(e))
+
def check_addr(option, opt_str, value, parser):
"""Function to insure that the address we are passed is actually
a valid address. Used by OptionParser() on startup."""
try:
- IPAddr(value)
- except:
+ if opt_str in ['-a', '--address']:
+ parser.values.address = isc.net.parse.addr_parse(value)
+ else:
+ raise OptionValueError("Unknown option " + opt_str)
+ except ValueError:
raise OptionValueError("%s requires a valid IPv4 or IPv6 address" % opt_str)
- if (opt_str == '-a' or opt_str == '--address'):
- parser.values.address = value
- else:
- raise OptionValueError("Unknown option " + opt_str)
def process_rename(option, opt_str, value, parser):
"""Function that renames the process if it is requested by a option."""
@@ -646,8 +648,8 @@
help="UNIX domain socket file the b10-msgq daemon will use")
parser.add_option("-n", "--no-cache", action="store_true", dest="nocache",
default=False, help="disable hot-spot cache in b10-auth")
- parser.add_option("-p", "--port", dest="auth_port", type="string",
- action="callback", callback=check_port, default="5300",
+ parser.add_option("-p", "--port", dest="auth_port", type="int",
+ action="callback", callback=check_port, default=5300,
help="port the b10-auth daemon will use (default 5300)")
parser.add_option("-u", "--user", dest="user",
type="string", default=None,
@@ -710,8 +712,11 @@
signal.signal(signal.SIGINT, fatal_signal)
signal.signal(signal.SIGTERM, fatal_signal)
+ # Block SIGPIPE, as we don't want it to end this process
+ signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+
# Go bob!
- boss_of_bind = BoB(options.msgq_socket_file, int(options.auth_port),
+ boss_of_bind = BoB(options.msgq_socket_file, options.auth_port,
options.address, options.nocache, options.verbose,
setuid, username)
startup_result = boss_of_bind.startup()
@@ -719,6 +724,17 @@
sys.stderr.write("[bind10] Error on startup: %s\n" % startup_result)
sys.exit(1)
sys.stdout.write("[bind10] BIND 10 started\n")
+
+ # send "bind10.boot_time" to b10-stats
+ time.sleep(1) # wait a second
+ if options.verbose:
+ sys.stdout.write("[bind10] send \"bind10.boot_time\" to b10-stats\n")
+ cmd = isc.config.ccsession.create_command('set',
+ { "stats_data": {
+ 'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
+ }
+ })
+ boss_of_bind.cc_session.group_sendmsg(cmd, 'Stats')
# In our main loop, we check for dead processes or messages
# on the c-channel.
Modified: branches/trac364/src/bin/bind10/run_bind10.sh.in
==============================================================================
--- branches/trac364/src/bin/bind10/run_bind10.sh.in (original)
+++ branches/trac364/src/bin/bind10/run_bind10.sh.in Wed Oct 27 13:42:53 2010
@@ -20,7 +20,7 @@
BIND10_PATH=@abs_top_builddir@/src/bin/bind10
-PATH=@abs_top_builddir@/src/bin/msgq:@abs_top_builddir@/src/bin/auth:@abs_top_builddir@/src/bin/cfgmgr:@abs_top_builddir@/src/bin/cmdctl:@abs_top_builddir@/src/bin/xfrin:@abs_top_builddir@/src/bin/xfrout:@abs_top_builddir@/src/bin/zonemgr:$PATH
+PATH=@abs_top_builddir@/src/bin/msgq:@abs_top_builddir@/src/bin/auth:@abs_top_builddir@/src/bin/cfgmgr:@abs_top_builddir@/src/bin/cmdctl:@abs_top_builddir@/src/bin/stats:@abs_top_builddir@/src/bin/xfrin:@abs_top_builddir@/src/bin/xfrout:@abs_top_builddir@/src/bin/zonemgr:$PATH
export PATH
PYTHONPATH=@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/lib/dns/python/.libs:@abs_top_builddir@/src/lib/xfr/.libs
Modified: branches/trac364/src/bin/bind10/tests/bind10_test.py
==============================================================================
--- branches/trac364/src/bin/bind10/tests/bind10_test.py (original)
+++ branches/trac364/src/bin/bind10/tests/bind10_test.py Wed Oct 27 13:42:53 2010
@@ -1,4 +1,4 @@
-from bind10 import ProcessInfo, BoB, IPAddr
+from bind10 import ProcessInfo, BoB
# XXX: environment tests are currently disabled, due to the preprocessor
# setup that we have now complicating the environment
@@ -8,6 +8,7 @@
import os
import signal
import socket
+from isc.net.addr import IPAddr
class TestProcessInfo(unittest.TestCase):
def setUp(self):
@@ -72,28 +73,6 @@
self.assertTrue(type(pi.pid) is int)
self.assertNotEqual(pi.pid, old_pid)
-class TestIPAddr(unittest.TestCase):
- def test_v6ok(self):
- addr = IPAddr('2001:4f8::1')
- self.assertEqual(addr.family, socket.AF_INET6)
- self.assertEqual(addr.addr, socket.inet_pton(socket.AF_INET6, '2001:4f8::1'))
-
- def test_v4ok(self):
- addr = IPAddr('127.127.127.127')
- self.assertEqual(addr.family, socket.AF_INET)
- self.assertEqual(addr.addr, socket.inet_aton('127.127.127.127'))
-
- def test_badaddr(self):
- self.assertRaises(socket.error, IPAddr, 'foobar')
- self.assertRaises(socket.error, IPAddr, 'foo::bar')
- self.assertRaises(socket.error, IPAddr, '123')
- self.assertRaises(socket.error, IPAddr, '123.456.789.0')
- self.assertRaises(socket.error, IPAddr, '127/8')
- self.assertRaises(socket.error, IPAddr, '0/0')
- self.assertRaises(socket.error, IPAddr, '1.2.3.4/32')
- self.assertRaises(socket.error, IPAddr, '0')
- self.assertRaises(socket.error, IPAddr, '')
-
class TestBoB(unittest.TestCase):
def test_init(self):
bob = BoB()
@@ -127,7 +106,7 @@
self.assertEqual(bob.runnable, False)
def test_init_alternate_address(self):
- bob = BoB(None, 5300, '127.127.127.127')
+ bob = BoB(None, 5300, IPAddr('127.127.127.127'))
self.assertEqual(bob.verbose, False)
self.assertEqual(bob.auth_port, 5300)
self.assertEqual(bob.msgq_socket_file, None)
Modified: branches/trac364/src/bin/cmdctl/Makefile.am
==============================================================================
--- branches/trac364/src/bin/cmdctl/Makefile.am (original)
+++ branches/trac364/src/bin/cmdctl/Makefile.am Wed Oct 27 13:42:53 2010
@@ -15,7 +15,7 @@
b10_cmdctl_DATA = $(CMDCTL_CONFIGURATIONS)
b10_cmdctl_DATA += cmdctl.spec
-
+
EXTRA_DIST = $(CMDCTL_CONFIGURATIONS)
CLEANFILES= b10-cmdctl cmdctl.pyc cmdctl.spec
Modified: branches/trac364/src/bin/cmdctl/cmdctl.py.in
==============================================================================
--- branches/trac364/src/bin/cmdctl/cmdctl.py.in (original)
+++ branches/trac364/src/bin/cmdctl/cmdctl.py.in Wed Oct 27 13:42:53 2010
@@ -1,6 +1,7 @@
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
+# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -43,8 +44,11 @@
import signal
from isc.config import ccsession
import isc.util.process
+import isc.net.parse
from optparse import OptionParser, OptionValueError
from hashlib import sha1
+from isc.util import socketserver_mixin
+
try:
import threading
except ImportError:
@@ -323,8 +327,8 @@
def _handle_msg_from_msgq(self):
'''Process all the received commands with module session. '''
while self._serving:
- self._module_cc.check_command()
-
+ self._module_cc.check_command(False)
+
def _parse_command_result(self, rcode, reply):
'''Ignore the error reason when command rcode isn't 0, '''
if rcode != 0:
@@ -439,7 +443,9 @@
return (keyfile, certfile, accountsfile)
-class SecureHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
+class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
+ socketserver.ThreadingMixIn,
+ http.server.HTTPServer):
'''Make the server address can be reused.'''
allow_reuse_address = True
@@ -447,6 +453,7 @@
CommandControlClass,
idle_timeout = 1200, verbose = False):
'''idle_timeout: the max idle time for login'''
+ socketserver_mixin.NoPollMixIn.__init__(self)
try:
http.server.HTTPServer.__init__(self, server_address, RequestHandlerClass)
except socket.error as err:
@@ -564,22 +571,17 @@
httpd.serve_forever()
def check_port(option, opt_str, value, parser):
- if (value < 0) or (value > 65535):
- raise OptionValueError('%s requires a port number (0-65535)' % opt_str)
- parser.values.port = value
+ try:
+ parser.values.port = isc.net.parse.port_parse(value)
+ except ValueError as e:
+ raise OptionValueError(str(e))
def check_addr(option, opt_str, value, parser):
- ipstr = value
- ip_family = socket.AF_INET
- if (ipstr.find(':') != -1):
- ip_family = socket.AF_INET6
-
try:
- socket.inet_pton(ip_family, ipstr)
- except:
- raise OptionValueError("%s invalid ip address" % ipstr)
-
- parser.values.addr = value
+ isc.net.parse.addr_parse(value)
+ parser.values.addr = value
+ except ValueError as e:
+ raise OptionValueError(str(e))
def set_cmd_options(parser):
parser.add_option('-p', '--port', dest = 'port', type = 'int',
Modified: branches/trac364/src/bin/loadzone/tests/error/error.known
==============================================================================
--- branches/trac364/src/bin/loadzone/tests/error/error.known (original)
+++ branches/trac364/src/bin/loadzone/tests/error/error.known Wed Oct 27 13:42:53 2010
@@ -1,5 +1,5 @@
Error reading zone file: Cannot parse RR, No $ORIGIN: @ IN SOA ns hostmaster 1 3600 1800 1814400 3600
-Error reading zone file: $ORIGIN is not absolute in record:$ORIGIN com
+Error reading zone file: $ORIGIN is not absolute in record: $ORIGIN com
Error reading zone file: Cannot parse RR: $TL 300
Error reading zone file: Cannot parse RR: $OIGIN com.
Error loading database: Error while loading com.: Cannot parse RR: $INLUDE file.txt
Modified: branches/trac364/src/bin/stats/tests/isc/Makefile.am
==============================================================================
--- branches/trac364/src/bin/stats/tests/isc/Makefile.am (original)
+++ branches/trac364/src/bin/stats/tests/isc/Makefile.am Wed Oct 27 13:42:53 2010
@@ -1,3 +1,3 @@
-SUBDIRS = cc config utils
+SUBDIRS = cc config util
EXTRA_DIST = __init__.py
CLEANFILES = __init__.pyc
Modified: branches/trac364/src/bin/stats/tests/isc/util/process.py
==============================================================================
--- branches/trac364/src/bin/stats/tests/isc/util/process.py (original)
+++ branches/trac364/src/bin/stats/tests/isc/util/process.py Wed Oct 27 13:42:53 2010
@@ -15,6 +15,6 @@
# $Id$
-# A dummy function of isc.utils.process.rename()
+# A dummy function of isc.util.process.rename()
def rename(name=None):
pass
Modified: branches/trac364/src/bin/xfrin/Makefile.am
==============================================================================
--- branches/trac364/src/bin/xfrin/Makefile.am (original)
+++ branches/trac364/src/bin/xfrin/Makefile.am Wed Oct 27 13:42:53 2010
@@ -7,10 +7,11 @@
b10_xfrindir = $(DESTDIR)$(pkgdatadir)
b10_xfrin_DATA = xfrin.spec
-CLEANFILES = b10-xfrin xfrin.pyc xfrin.spec
+CLEANFILES = b10-xfrin xfrin.pyc
man_MANS = b10-xfrin.8
EXTRA_DIST = $(man_MANS) b10-xfrin.xml
+EXTRA_DIST += xfrin.spec
if ENABLE_MAN
@@ -19,9 +20,6 @@
endif
-xfrin.spec: xfrin.spec.pre
- $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" xfrin.spec.pre >$@
-
# TODO: does this need $$(DESTDIR) also?
# this is done here since configure.ac AC_OUTPUT doesn't expand exec_prefix
b10-xfrin: xfrin.py
Modified: branches/trac364/src/bin/xfrin/tests/xfrin_test.py
==============================================================================
--- branches/trac364/src/bin/xfrin/tests/xfrin_test.py (original)
+++ branches/trac364/src/bin/xfrin/tests/xfrin_test.py Wed Oct 27 13:42:53 2010
@@ -421,21 +421,21 @@
name, rrclass = self._do_parse_zone_name_class()
master_addrinfo = self._do_parse_master_port()
db_file = self.args.get('db_file')
- self.assertEqual(master_addrinfo[4][1], int(TEST_MASTER_PORT))
+ self.assertEqual(master_addrinfo[2][1], int(TEST_MASTER_PORT))
self.assertEqual(name, TEST_ZONE_NAME)
self.assertEqual(rrclass, TEST_RRCLASS)
- self.assertEqual(master_addrinfo[4][0], TEST_MASTER_IPV4_ADDRESS)
+ self.assertEqual(master_addrinfo[2][0], TEST_MASTER_IPV4_ADDRESS)
self.assertEqual(db_file, TEST_DB_FILE)
def test_parse_cmd_params_default_port(self):
del self.args['port']
master_addrinfo = self._do_parse_master_port()
- self.assertEqual(master_addrinfo[4][1], 53)
+ self.assertEqual(master_addrinfo[2][1], 53)
def test_parse_cmd_params_ip6master(self):
self.args['master'] = TEST_MASTER_IPV6_ADDRESS
master_addrinfo = self._do_parse_master_port()
- self.assertEqual(master_addrinfo[4][0], TEST_MASTER_IPV6_ADDRESS)
+ self.assertEqual(master_addrinfo[2][0], TEST_MASTER_IPV6_ADDRESS)
def test_parse_cmd_params_chclass(self):
self.args['zone_class'] = 'CH'
@@ -454,7 +454,7 @@
# master address is mandatory.
del self.args['master']
master_addrinfo = self._do_parse_master_port()
- self.assertEqual(master_addrinfo[4][0], DEFAULT_MASTER)
+ self.assertEqual(master_addrinfo[2][0], DEFAULT_MASTER)
def test_parse_cmd_params_bad_ip4(self):
self.args['master'] = '3.3.3.3.3'
Modified: branches/trac364/src/bin/xfrin/xfrin.py.in
==============================================================================
--- branches/trac364/src/bin/xfrin/xfrin.py.in (original)
+++ branches/trac364/src/bin/xfrin/xfrin.py.in Wed Oct 27 13:42:53 2010
@@ -1,6 +1,7 @@
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
+# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -30,6 +31,7 @@
from isc.config.ccsession import *
from isc.notify import notify_out
import isc.util.process
+import isc.net.parse
try:
from pydnspp import *
except ImportError as e:
@@ -93,7 +95,7 @@
self.setblocking(1)
self._shutdown_event = shutdown_event
self._verbose = verbose
- self._master_address = master_addrinfo[4]
+ self._master_address = master_addrinfo[2]
def connect_to_master(self):
'''Connect to master in TCP.'''
@@ -329,10 +331,14 @@
sock_map = {}
conn = XfrinConnection(sock_map, zone_name, rrclass, db_file,
shutdown_event, master_addrinfo, verbose)
+ ret = XFRIN_FAIL
if conn.connect_to_master():
ret = conn.do_xfrin(check_soa)
- server.publish_xfrin_news(zone_name, rrclass, ret)
-
+
+ # Publish the zone transfer result news, so zonemgr can reset the
+ # zone timer, and xfrout can notify the zone's slaves if the result
+ # is success.
+ server.publish_xfrin_news(zone_name, rrclass, ret)
xfrin_recorder.decrement(zone_name)
@@ -396,20 +402,20 @@
'''This is a straightforward wrapper for cc.check_command,
but provided as a separate method for the convenience
of unit tests.'''
- self._module_cc.check_command()
+ self._module_cc.check_command(False)
def config_handler(self, new_config):
self._max_transfers_in = new_config.get("transfers_in") or self._max_transfers_in
if ('master_addr' in new_config) or ('master_port' in new_config):
- # Check if the new master is valid, there should be library for check it.
- # and user should change the port and address together.
+ # User should change the port and address together.
try:
addr = new_config.get('master_addr') or self._master_addr
port = new_config.get('master_port') or self._master_port
- check_addr_port(addr, port)
+ isc.net.parse.addr_parse(addr)
+ isc.net.parse.port_parse(port)
self._master_addr = addr
self._master_port = port
- except:
+ except ValueError:
errmsg = "bad format for zone's master: " + str(new_config)
log_error(errmsg)
return create_answer(1, errmsg)
@@ -438,7 +444,7 @@
# specify the notifyfrom address and port, according the RFC1996, zone
# transfer should starts first from the notifyfrom, but now, let 'TODO' it.
(zone_name, rrclass) = self._parse_zone_name_and_class(args)
- (master_addr) = check_addr_port(self._master_addr, self._master_port)
+ (master_addr) = build_addr_info(self._master_addr, self._master_port)
ret = self.xfrin_start(zone_name,
rrclass,
self._get_db_file(),
@@ -486,7 +492,7 @@
def _parse_master_and_port(self, args):
port = args.get('port') or self._master_port
master = args.get('master') or self._master_addr
- return check_addr_port(master, port)
+ return build_addr_info(master, port)
def _get_db_file(self):
#TODO, the db file path should be got in auth server's configuration
@@ -513,11 +519,21 @@
param = {'zone_name': zone_name, 'zone_class': zone_class.to_text()}
if xfr_result == XFRIN_OK:
msg = create_command(notify_out.ZONE_NEW_DATA_READY_CMD, param)
- self._send_cc_session.group_sendmsg(msg, XFROUT_MODULE_NAME)
- self._send_cc_session.group_sendmsg(msg, ZONE_MANAGER_MODULE_NAME)
+ # catch the exception, in case msgq has been killed.
+ try:
+ self._send_cc_session.group_sendmsg(msg, XFROUT_MODULE_NAME)
+ self._send_cc_session.group_sendmsg(msg, ZONE_MANAGER_MODULE_NAME)
+ except socket.error as err:
+ log_error("Fail to send message to %s and %s, msgq may has been killed"
+ % (XFROUT_MODULE_NAME, ZONE_MANAGER_MODULE_NAME))
else:
msg = create_command(ZONE_XFRIN_FAILED, param)
- self._send_cc_session.group_sendmsg(msg, ZONE_MANAGER_MODULE_NAME)
+ # catch the exception, in case msgq has been killed.
+ try:
+ self._send_cc_session.group_sendmsg(msg, ZONE_MANAGER_MODULE_NAME)
+ except socket.error as err:
+ log_error("Fail to send message to %s, msgq may has been killed"
+ % ZONE_MANAGER_MODULE_NAME)
def startup(self):
while not self._shutdown_event.is_set():
@@ -559,30 +575,19 @@
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
-def check_addr_port(addrstr, portstr):
- # XXX: Linux (glibc)'s getaddrinfo incorrectly accepts numeric port
- # string larger than 65535. So we need to explicit validate it separately.
+def build_addr_info(addrstr, portstr):
+ """
+ Return tuple (family, socktype, sockaddr) for given address and port.
+ IPv4 and IPv6 are the only supported addresses now, so sockaddr will be
+ (address, port). The socktype is socket.SOCK_STREAM for now.
+ """
try:
- portnum = int(portstr)
- if portnum < 0 or portnum > 65535:
- raise ValueError("invalid port number (out of range): " + portstr)
+ port = isc.net.parse.port_parse(portstr)
+ addr = isc.net.parse.addr_parse(addrstr)
+ return (addr.family, socket.SOCK_STREAM, (addrstr, port))
except ValueError as err:
raise XfrinException("failed to resolve master address/port=%s/%s: %s" %
(addrstr, portstr, str(err)))
-
- try:
- addrinfo = socket.getaddrinfo(addrstr, portstr, socket.AF_UNSPEC,
- socket.SOCK_STREAM, socket.IPPROTO_TCP,
- socket.AI_NUMERICHOST|
- socket.AI_NUMERICSERV)
- except socket.gaierror as err:
- raise XfrinException("failed to resolve master address/port=%s/%s: %s" %
- (addrstr, portstr, str(err)))
- if len(addrinfo) != 1:
- # with the parameters above the result must be uniquely determined.
- errmsg = "unexpected result for address/port resolution for %s:%s"
- raise XfrinException(errmsg % (addrstr, portstr))
- return addrinfo[0]
def set_cmd_options(parser):
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
Modified: branches/trac364/src/bin/xfrout/xfrout.py.in
==============================================================================
--- branches/trac364/src/bin/xfrout/xfrout.py.in (original)
+++ branches/trac364/src/bin/xfrout/xfrout.py.in Wed Oct 27 13:42:53 2010
@@ -1,6 +1,7 @@
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
+# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -34,6 +35,8 @@
import select
import errno
from optparse import OptionParser, OptionValueError
+from isc.util import socketserver_mixin
+
try:
from libxfr_python import *
from pydnspp import *
@@ -265,7 +268,8 @@
for rr_data in sqlite3_ds.get_zone_datas(zone_name, self.server.get_db_file()):
if self.server._shutdown_event.is_set(): # Check if xfrout is shutdown
- self._log.log_message("error", "shutdown!")
+ self._log.log_message("info", "xfrout process is being shutdown")
+ return
# TODO: RRType.SOA() ?
if RRType(rr_data[5]) == RRType("SOA"): #ignore soa record
@@ -289,12 +293,13 @@
self._send_message_with_last_soa(msg, sock, rrset_soa, message_upper_len)
-class UnixSockServer(ThreadingUnixStreamServer):
+class UnixSockServer(socketserver_mixin.NoPollMixIn, ThreadingUnixStreamServer):
'''The unix domain socket server which accept xfr query sent from auth server.'''
def __init__(self, sock_file, handle_class, shutdown_event, config_data, cc, log):
self._remove_unused_sock_file(sock_file)
self._sock_file = sock_file
+ socketserver_mixin.NoPollMixIn.__init__(self)
ThreadingUnixStreamServer.__init__(self, sock_file, handle_class)
self._lock = threading.Lock()
self._transfers_counter = 0
@@ -339,7 +344,7 @@
return True
def shutdown(self):
- ThreadingUnixStreamServer.shutdown(self)
+ super().shutdown() # call the shutdown() of class socketserver_mixin.NoPollMixIn
try:
os.unlink(self._sock_file)
except Exception as e:
@@ -380,25 +385,6 @@
self._lock.acquire()
self._transfers_counter -= 1
self._lock.release()
-
-def listen_on_xfr_query(unix_socket_server):
- '''Listen xfr query in one single thread. Polls for shutdown
- every 0.1 seconds, is there a better time?
- '''
-
- while True:
- try:
- unix_socket_server.serve_forever(poll_interval = 0.1)
- except select.error as err:
- # serve_forever() calls select.select(), which can be
- # interrupted.
- # If it is interrupted, it raises select.error with the
- # errno set to EINTR. We ignore this case, and let the
- # normal program flow continue by trying serve_forever()
- # again.
- if err.args[0] != errno.EINTR: raise
-
-
class XfroutServer:
def __init__(self):
@@ -421,15 +407,13 @@
self._unix_socket_server = UnixSockServer(self._listen_sock_file, XfroutSession,
self._shutdown_event, self._config_data,
self._cc, self._log);
- listener = threading.Thread(target = listen_on_xfr_query, args = (self._unix_socket_server,))
+ listener = threading.Thread(target=self._unix_socket_server.serve_forever)
listener.start()
def _start_notifier(self):
datasrc = self._unix_socket_server.get_db_file()
self._notifier = notify_out.NotifyOut(datasrc, self._log)
- td = threading.Thread(target = notify_out.dispatcher, args = (self._notifier,))
- td.daemon = True
- td.start()
+ self._notifier.dispatcher()
def send_notify(self, zone_name, zone_class):
self._notifier.send_notify(zone_name, zone_class)
@@ -442,7 +426,7 @@
answer = create_answer(1, "Unknown config data: " + str(key))
continue
self._config_data[key] = new_config[key]
-
+
if self._log:
self._log.update_config(new_config)
@@ -460,9 +444,11 @@
global xfrout_server
xfrout_server = None #Avoid shutdown is called twice
self._shutdown_event.set()
+ self._notifier.shutdown()
if self._unix_socket_server:
self._unix_socket_server.shutdown()
+ # Wait for all threads to terminate
main_thread = threading.currentThread()
for th in threading.enumerate():
if th is main_thread:
@@ -474,7 +460,7 @@
self._log.log_message("info", "Received shutdown command.")
self.shutdown()
answer = create_answer(0)
-
+
elif cmd == notify_out.ZONE_NEW_DATA_READY_CMD:
zone_name = args.get('zone_name')
zone_class = args.get('zone_class')
@@ -489,12 +475,12 @@
else:
answer = create_answer(1, "Unknown command:" + str(cmd))
- return answer
+ return answer
def run(self):
'''Get and process all commands sent from cfgmgr or other modules. '''
while not self._shutdown_event.is_set():
- self._cc.check_command()
+ self._cc.check_command(False)
xfrout_server = None
Modified: branches/trac364/src/bin/zonemgr/tests/Makefile.am
==============================================================================
--- branches/trac364/src/bin/zonemgr/tests/Makefile.am (original)
+++ branches/trac364/src/bin/zonemgr/tests/Makefile.am Wed Oct 27 13:42:53 2010
@@ -1,5 +1,7 @@
PYTESTS = zonemgr_test.py
EXTRA_DIST = $(PYTESTS)
+
+CLEANFILES = initdb.file
# later will have configure option to choose this, like: coverage run --branch
PYCOVERAGE = $(PYTHON)
Modified: branches/trac364/src/bin/zonemgr/tests/zonemgr_test.py
==============================================================================
--- branches/trac364/src/bin/zonemgr/tests/zonemgr_test.py (original)
+++ branches/trac364/src/bin/zonemgr/tests/zonemgr_test.py Wed Oct 27 13:42:53 2010
@@ -27,6 +27,11 @@
ZONE_NAME_CLASS1_CH = ("sd.cn.", "CH")
ZONE_NAME_CLASS2_IN = ("tw.cn", "IN")
+MAX_TRANSFER_TIMEOUT = 14400
+LOWERBOUND_REFRESH = 10
+LOWERBOUND_RETRY = 5
+JITTER_SCOPE = 0.10
+
class ZonemgrTestException(Exception):
pass
@@ -40,8 +45,21 @@
class MyZonemgrRefresh(ZonemgrRefresh):
def __init__(self):
- self._cc = MySession()
- self._db_file = "initdb.file"
+ class FakeConfig:
+ def get(self, name):
+ if name == 'lowerbound_refresh':
+ return LOWERBOUND_REFRESH
+ elif name == 'lowerbound_retry':
+ return LOWERBOUND_RETRY
+ elif name == 'max_transfer_timeout':
+ return MAX_TRANSFER_TIMEOUT
+ elif name == 'jitter_scope':
+ return JITTER_SCOPE
+ else:
+ raise ValueError('Uknown config option')
+ self._master_socket, self._slave_socket = socket.socketpair()
+ ZonemgrRefresh.__init__(self, MySession(), "initdb.file",
+ self._slave_socket, FakeConfig())
current_time = time.time()
self._zonemgr_refresh_info = {
('sd.cn.', 'IN'): {
@@ -58,8 +76,8 @@
class TestZonemgrRefresh(unittest.TestCase):
def setUp(self):
- self.stdout_backup = sys.stdout
- sys.stdout = open(os.devnull, 'w')
+ self.stderr_backup = sys.stderr
+ sys.stderr = open(os.devnull, 'w')
self.zone_refresh = MyZonemgrRefresh()
def test_random_jitter(self):
@@ -92,7 +110,7 @@
time2 = time.time()
self.assertTrue((time1 + 7200 * 3 / 4) <= zone_timeout)
self.assertTrue(zone_timeout <= time2 + 7200)
-
+
def test_set_zone_retry_timer(self):
time1 = time.time()
self.zone_refresh._set_zone_retry_timer(ZONE_NAME_CLASS1_IN)
@@ -138,6 +156,8 @@
def test_zonemgr_reload_zone(self):
soa_rdata = 'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600'
+ # We need to restore this not to harm other tests
+ old_get_zone_soa = sqlite3_ds.get_zone_soa
def get_zone_soa(zone_name, db_file):
return (1, 2, 'sd.cn.', 'cn.sd.', 21600, 'SOA', None,
'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600')
@@ -145,6 +165,7 @@
self.zone_refresh.zonemgr_reload_zone(ZONE_NAME_CLASS1_IN)
self.assertEqual(soa_rdata, self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_soa_rdata"])
+ sqlite3_ds.get_zone_soa = old_get_zone_soa
def test_get_zone_notifier_master(self):
notify_master = "192.168.1.1"
@@ -222,6 +243,9 @@
def test_zonemgr_add_zone(self):
soa_rdata = 'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600'
+ # This needs to be restored. The following test actually failed if we left
+ # this unclean
+ old_get_zone_soa = sqlite3_ds.get_zone_soa
def get_zone_soa(zone_name, db_file):
return (1, 2, 'sd.cn.', 'cn.sd.', 21600, 'SOA', None,
@@ -242,7 +266,8 @@
return None
sqlite3_ds.get_zone_soa = get_zone_soa2
self.assertRaises(ZonemgrException, self.zone_refresh.zonemgr_add_zone, \
- ZONE_NAME_CLASS1_IN)
+ ZONE_NAME_CLASS1_IN)
+ sqlite3_ds.get_zone_soa = old_get_zone_soa
def test_build_zonemgr_refresh_info(self):
soa_rdata = 'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600'
@@ -373,7 +398,7 @@
"""This case will run timer in daemon thread.
The zone's next_refresh_time is less than now, so zonemgr will do zone refresh
immediately. The zone's state will become "refreshing".
- Then closing the socket ,the timer will stop, and throw a ZonemgrException."""
+ """
time1 = time.time()
self.zone_refresh._zonemgr_refresh_info = {
("sd.cn.", "IN"):{
@@ -382,24 +407,38 @@
'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073105 7200 3600 2419200 21600',
'zone_state': ZONE_OK}
}
- master_socket, slave_socket = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
- self.zone_refresh._socket = master_socket
- master_socket.close()
- self.assertRaises(ZonemgrException, self.zone_refresh.run_timer)
-
- self.zone_refresh._socket = slave_socket
- listener = threading.Thread(target = self.zone_refresh.run_timer, args = ())
- listener.setDaemon(True)
- listener.start()
- time.sleep(1)
-
+ self.zone_refresh._check_sock = self.zone_refresh._master_socket
+ listener = self.zone_refresh.run_timer(daemon=True)
+ # Shut down the timer thread
+ self.zone_refresh.shutdown()
+ # After running timer, the zone's state should become "refreshing".
zone_state = self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"]
self.assertTrue("refresh_timeout" in self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN].keys())
self.assertTrue(zone_state == ZONE_REFRESHING)
+ def test_update_config_data(self):
+ config_data = {
+ "lowerbound_refresh" : 60,
+ "lowerbound_retry" : 30,
+ "max_transfer_timeout" : 19800,
+ "jitter_scope" : 0.25
+ }
+ self.zone_refresh.update_config_data(config_data)
+ self.assertEqual(60, self.zone_refresh._lowerbound_refresh)
+ self.assertEqual(30, self.zone_refresh._lowerbound_retry)
+ self.assertEqual(19800, self.zone_refresh._max_transfer_timeout)
+ self.assertEqual(0.25, self.zone_refresh._jitter_scope)
+
+ def test_shutdown(self):
+ self.zone_refresh._check_sock = self.zone_refresh._master_socket
+ listener = self.zone_refresh.run_timer()
+ self.assertTrue(listener.is_alive())
+ # Shut down the timer thread
+ self.zone_refresh.shutdown()
+ self.assertFalse(listener.is_alive())
def tearDown(self):
- sys.stdout = self.stdout_backup
+ sys.stderr= self.stderr_backup
class MyCCSession():
@@ -417,10 +456,16 @@
def __init__(self):
self._db_file = "initdb.file"
+ self._zone_refresh = None
self._shutdown_event = threading.Event()
self._cc = MySession()
self._module_cc = MyCCSession()
- self._config_data = {"zone_name" : "org.cn", "zone_class" : "CH", "master" : "127.0.0.1"}
+ self._config_data = {
+ "lowerbound_refresh" : 10,
+ "lowerbound_retry" : 5,
+ "max_transfer_timeout" : 14400,
+ "jitter_scope" : 0.1
+ }
def _start_zone_refresh_timer(self):
pass
@@ -431,12 +476,21 @@
self.zonemgr = MyZonemgr()
def test_config_handler(self):
- config_data1 = {"zone_name" : "sd.cn.", "zone_class" : "CH", "master" : "192.168.1.1"}
+ config_data1 = {
+ "lowerbound_refresh" : 60,
+ "lowerbound_retry" : 30,
+ "max_transfer_timeout" : 14400,
+ "jitter_scope" : 0.1
+ }
self.zonemgr.config_handler(config_data1)
self.assertEqual(config_data1, self.zonemgr._config_data)
config_data2 = {"zone_name" : "sd.cn.", "port" : "53", "master" : "192.168.1.1"}
self.zonemgr.config_handler(config_data2)
self.assertEqual(config_data1, self.zonemgr._config_data)
+ # jitter should not be bigger than half of the original value
+ config_data3 = {"jitter_scope" : 0.7}
+ self.zonemgr.config_handler(config_data3)
+ self.assertEqual(0.5, self.zonemgr._config_data.get("jitter_scope"))
def test_get_db_file(self):
self.assertEqual("initdb.file", self.zonemgr.get_db_file())
@@ -452,6 +506,15 @@
params1 = {"zone_class" : "CH"}
self.assertRaises(ZonemgrException, self.zonemgr._parse_cmd_params, params2, ZONE_NOTIFY_COMMAND)
+ def test_config_data_check(self):
+ # jitter should not be bigger than half of the original value
+ config_data2 = {"jitter_scope" : 0.2}
+ config_data3 = {"jitter_scope" : 0.6}
+ self.zonemgr._config_data_check(config_data2)
+ self.assertEqual(0.2, config_data2.get("jitter_scope"))
+ self.zonemgr._config_data_check(config_data3)
+ self.assertEqual(0.5, config_data3.get("jitter_scope"))
+
def tearDown(self):
pass
Modified: branches/trac364/src/bin/zonemgr/zonemgr.py.in
==============================================================================
--- branches/trac364/src/bin/zonemgr/zonemgr.py.in (original)
+++ branches/trac364/src/bin/zonemgr/zonemgr.py.in Wed Oct 27 13:42:53 2010
@@ -1,6 +1,7 @@
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
+# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -15,7 +16,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-"""\
+"""
This file implements the Secondary Manager program.
The secondary manager is one of the co-operating processes
@@ -72,13 +73,6 @@
ZONE_REFRESHING = 1
ZONE_EXPIRED = 2
-# smallest refresh timeout
-LOWERBOUND_REFRESH = 10
-# smallest retry timeout
-LOWERBOUND_RETRY = 5
-# max zone transfer timeout
-MAX_TRANSFER_TIMEOUT = 14400
-
# offsets of fields in the SOA RDATA
REFRESH_OFFSET = 3
RETRY_OFFSET = 4
@@ -97,15 +91,20 @@
class ZonemgrRefresh:
"""This class will maintain and manage zone refresh info.
It also provides methods to keep track of zone timers and
- do zone refresh.
+ do zone refresh.
+ Zone timers can be started by calling run_timer(), and it
+ can be stopped by calling shutdown() in another thread.
+
"""
- def __init__(self, cc, db_file, slave_socket):
+ def __init__(self, cc, db_file, slave_socket, config_data):
self._cc = cc
- self._socket = slave_socket
+ self._check_sock = slave_socket
self._db_file = db_file
+ self.update_config_data(config_data)
self._zonemgr_refresh_info = {}
self._build_zonemgr_refresh_info()
+ self._running = False
def _random_jitter(self, max, jitter):
"""Imposes some random jitters for refresh and
@@ -121,25 +120,26 @@
return time.time()
def _set_zone_timer(self, zone_name_class, max, jitter):
- """Set zone next refresh time."""
+ """Set zone next refresh time.
+ jitter should not be bigger than half the original value."""
self._set_zone_next_refresh_time(zone_name_class, self._get_current_time() + \
self._random_jitter(max, jitter))
def _set_zone_refresh_timer(self, zone_name_class):
"""Set zone next refresh time after zone refresh success.
- now + refresh*3/4 <= next_refresh_time <= now + refresh
+ now + refresh - jitter <= next_refresh_time <= now + refresh
"""
zone_refresh_time = float(self._get_zone_soa_rdata(zone_name_class).split(" ")[REFRESH_OFFSET])
- zone_refresh_time = max(LOWERBOUND_REFRESH, zone_refresh_time)
- self._set_zone_timer(zone_name_class, zone_refresh_time, (1 * zone_refresh_time) / 4)
+ zone_refresh_time = max(self._lowerbound_refresh, zone_refresh_time)
+ self._set_zone_timer(zone_name_class, zone_refresh_time, self._jitter_scope * zone_refresh_time)
def _set_zone_retry_timer(self, zone_name_class):
"""Set zone next refresh time after zone refresh fail.
- now + retry*3/4 <= next_refresh_time <= now + retry
+ now + retry - jitter <= next_refresh_time <= now + retry
"""
zone_retry_time = float(self._get_zone_soa_rdata(zone_name_class).split(" ")[RETRY_OFFSET])
- zone_retry_time = max(LOWERBOUND_RETRY, zone_retry_time)
- self._set_zone_timer(zone_name_class, zone_retry_time, (1 * zone_retry_time) / 4)
+ zone_retry_time = max(self._lowerbound_retry, zone_retry_time)
+ self._set_zone_timer(zone_name_class, zone_retry_time, self._jitter_scope * zone_retry_time)
def _set_zone_notify_timer(self, zone_name_class):
"""Set zone next refresh time after receiving notify
@@ -299,7 +299,7 @@
"""Do zone refresh."""
log_msg("Do refresh for zone (%s, %s)." % zone_name_class)
self._set_zone_state(zone_name_class, ZONE_REFRESHING)
- self._set_zone_refresh_timeout(zone_name_class, self._get_current_time() + MAX_TRANSFER_TIMEOUT)
+ self._set_zone_refresh_timeout(zone_name_class, self._get_current_time() + self._max_transfer_timeout)
notify_master = self._get_zone_notifier_master(zone_name_class)
# If the zone has notify master, send notify command to xfrin module
if notify_master:
@@ -323,59 +323,107 @@
return False
- def run_timer(self):
- """Keep track of zone timers."""
- while True:
- # Zonemgr has no zone.
+ def _run_timer(self, start_event):
+ start_event.set()
+ while self._running:
+ # If zonemgr has no zone, set timer timeout to self._lowerbound_retry.
if self._zone_mgr_is_empty():
- time.sleep(LOWERBOUND_RETRY) # A better time?
- continue
-
- zone_need_refresh = self._find_need_do_refresh_zone()
- # If don't get zone with minimum next refresh time, set timer timeout = LOWERBOUND_REFRESH
- if not zone_need_refresh:
- timeout = LOWERBOUND_RETRY
+ timeout = self._lowerbound_retry
else:
- timeout = self._get_zone_next_refresh_time(zone_need_refresh) - self._get_current_time()
- if (timeout < 0):
- self._do_refresh(zone_need_refresh)
- continue
+ zone_need_refresh = self._find_need_do_refresh_zone()
+ # If don't get zone with minimum next refresh time, set timer timeout to self._lowerbound_retry
+ if not zone_need_refresh:
+ timeout = self._lowerbound_retry
+ else:
+ timeout = self._get_zone_next_refresh_time(zone_need_refresh) - self._get_current_time()
+ if (timeout < 0):
+ self._do_refresh(zone_need_refresh)
+ continue
""" Wait for the socket notification for a maximum time of timeout
in seconds (as float)."""
try:
- (rlist, wlist, xlist) = select.select([self._socket], [], [], timeout)
- if rlist:
- self._socket.recv(32)
- except ValueError as e:
- raise ZonemgrException("[b10-zonemgr] Socket has been closed\n")
- break
+ rlist, wlist, xlist = select.select([self._check_sock, self._read_sock], [], [], timeout)
except select.error as e:
if e.args[0] == errno.EINTR:
(rlist, wlist, xlist) = ([], [], [])
else:
- raise ZonemgrException("[b10-zonemgr] Error with select(): %s\n" % e)
+ sys.stderr.write("[b10-zonemgr] Error with select(); %s\n" % e)
break
+ for fd in rlist:
+ if fd == self._read_sock: # awaken by shutdown socket
+ # self._running will be False by now, if it is not a false
+ # alarm
+ continue
+ if fd == self._check_sock: # awaken by check socket
+ self._check_sock.recv(32)
+
+ def run_timer(self, daemon=False):
+ """
+ Keep track of zone timers. Spawns and starts a thread. The thread object is returned.
+
+ You can stop it by calling shutdown().
+ """
+ # Small sanity check
+ if self._running:
+ raise RuntimeError("Trying to run the timers twice at the same time")
+
+ # Prepare the launch
+ self._running = True
+ (self._read_sock, self._write_sock) = socket.socketpair()
+ start_event = threading.Event()
+
+ # Start the thread
+ self._thread = threading.Thread(target = self._run_timer,
+ args = (start_event,))
+ if daemon:
+ self._thread.setDaemon(True)
+ self._thread.start()
+ start_event.wait()
+
+ # Return the thread to anyone interested
+ return self._thread
+
+ def shutdown(self):
+ """
+ Stop the run_timer() thread. Block until it finished. This must be
+ called from a different thread.
+ """
+ if not self._running:
+ raise RuntimeError("Trying to shutdown, but not running")
+
+ # Ask the thread to stop
+ self._running = False
+ self._write_sock.send(b'shutdown') # make self._read_sock readble
+ # Wait for it to actually finnish
+ self._thread.join()
+ # Wipe out what we do not need
+ self._thread = None
+ self._read_sock = None
+ self._write_sock = None
+
+ def update_config_data(self, new_config):
+ """ update ZonemgrRefresh config """
+ self._lowerbound_refresh = new_config.get('lowerbound_refresh')
+ self._lowerbound_retry = new_config.get('lowerbound_retry')
+ self._max_transfer_timeout = new_config.get('max_transfer_timeout')
+ self._jitter_scope = new_config.get('jitter_scope')
class Zonemgr:
"""Zone manager class."""
def __init__(self):
+ self._zone_refresh = None
self._setup_session()
self._db_file = self.get_db_file()
# Create socket pair for communicating between main thread and zonemgr timer thread
self._master_socket, self._slave_socket = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
- self._zone_refresh= ZonemgrRefresh(self._cc, self._db_file, self._slave_socket)
- self._start_zone_refresh_timer()
+ self._zone_refresh = ZonemgrRefresh(self._cc, self._db_file, self._slave_socket, self._config_data)
+ self._zone_refresh.run_timer()
self._lock = threading.Lock()
self._shutdown_event = threading.Event()
-
- def _start_zone_refresh_timer(self):
- """Start a new thread to keep track of zone timers"""
- listener = threading.Thread(target = self._zone_refresh.run_timer, args = ())
- listener.setDaemon(True)
- listener.start()
+ self.running = False
def _setup_session(self):
"""Setup two sessions for zonemgr, one(self._module_cc) is used for receiving
@@ -387,6 +435,7 @@
self.command_handler)
self._module_cc.add_remote_config(AUTH_SPECFILE_LOCATION)
self._config_data = self._module_cc.get_full_config()
+ self._config_data_check(self._config_data)
self._module_cc.start()
def get_db_file(self):
@@ -402,25 +451,36 @@
"""Shutdown the zonemgr process. the thread which is keeping track of zone
timers should be terminated.
"""
+ self._zone_refresh.shutdown()
+
self._slave_socket.close()
self._master_socket.close()
-
self._shutdown_event.set()
- main_thread = threading.currentThread()
- for th in threading.enumerate():
- if th is main_thread:
- continue
- th.join()
+ self.running = False
def config_handler(self, new_config):
- """Update config data."""
+ """ Update config data. """
answer = create_answer(0)
for key in new_config:
if key not in self._config_data:
answer = create_answer(1, "Unknown config data: " + str(key))
continue
self._config_data[key] = new_config[key]
+
+ self._config_data_check(self._config_data)
+ if (self._zone_refresh):
+ self._zone_refresh.update_config_data(self._config_data)
+
return answer
+
+ def _config_data_check(self, config_data):
+ """Check whether the new config data is valid or
+ not. """
+ # jitter should not be bigger than half of the original value
+ if config_data.get('jitter_scope') > 0.5:
+ config_data['jitter_scope'] = 0.5
+ log_msg("[b10-zonemgr] jitter_scope is too big, its value will "
+ "be set to 0.5")
def _parse_cmd_params(self, args, command):
zone_name = args.get("zone_name")
@@ -455,21 +515,21 @@
with self._lock:
self._zone_refresh.zone_handle_notify(zone_name_class, master)
# Send notification to zonemgr timer thread
- self._master_socket.send(b" ")
+ self._master_socket.send(b" ")# make self._slave_socket readble
elif command == ZONE_XFRIN_SUCCESS_COMMAND:
""" Handle xfrin success command"""
zone_name_class = self._parse_cmd_params(args, command)
with self._lock:
self._zone_refresh.zone_refresh_success(zone_name_class)
- self._master_socket.send(b" ")
+ self._master_socket.send(b" ")# make self._slave_socket readble
elif command == ZONE_XFRIN_FAILED_COMMAND:
""" Handle xfrin fail command"""
zone_name_class = self._parse_cmd_params(args, command)
with self._lock:
self._zone_refresh.zone_refresh_fail(zone_name_class)
- self._master_socket.send(b" ")
+ self._master_socket.send(b" ")# make self._slave_socket readble
elif command == "shutdown":
self.shutdown()
@@ -480,8 +540,9 @@
return answer
def run(self):
+ self.running = True
while not self._shutdown_event.is_set():
- self._module_cc.check_command()
+ self._module_cc.check_command(False)
zonemgrd = None
@@ -519,6 +580,6 @@
except isc.config.ModuleCCSessionError as e:
sys.stderr.write("[b10-zonemgr] exit zonemgr process: %s\n" % str(e))
- if zonemgrd:
+ if zonemgrd and zonemgrd.running:
zonemgrd.shutdown()
Modified: branches/trac364/src/bin/zonemgr/zonemgr.spec.pre.in
==============================================================================
--- branches/trac364/src/bin/zonemgr/zonemgr.spec.pre.in (original)
+++ branches/trac364/src/bin/zonemgr/zonemgr.spec.pre.in Wed Oct 27 13:42:53 2010
@@ -2,6 +2,30 @@
"module_spec": {
"module_name": "Zonemgr",
"config_data":[
+ {
+ "item_name": "lowerbound_refresh",
+ "item_type": "integer",
+ "item_optional": false,
+ "item_default": 10
+ },
+ {
+ "item_name": "lowerbound_retry",
+ "item_type": "integer",
+ "item_optional": false,
+ "item_default": 5
+ },
+ {
+ "item_name": "max_transfer_timeout",
+ "item_type": "integer",
+ "item_optional": false,
+ "item_default": 14400
+ },
+ {
+ "item_name": "jitter_scope",
+ "item_type": "real",
+ "item_optional": false,
+ "item_default": 0.25
+ }
],
"commands": [
{
Modified: branches/trac364/src/lib/cc/data.cc
==============================================================================
--- branches/trac364/src/lib/cc/data.cc (original)
+++ branches/trac364/src/lib/cc/data.cc Wed Oct 27 13:42:53 2010
@@ -184,7 +184,8 @@
namespace {
inline void
-throwJSONError(const std::string& error, const std::string& file, int line, int pos)
+throwJSONError(const std::string& error, const std::string& file, int line,
+ int pos)
{
std::stringstream ss;
ss << error << " in " + file + ":" << line << ":" << pos;
@@ -427,13 +428,15 @@
}
ElementPtr
-from_stringstream_string(std::istream& in, const std::string& file, int& line, int& pos)
+from_stringstream_string(std::istream& in, const std::string& file, int& line,
+ int& pos)
{
return (Element::create(str_from_stringstream(in, file, line, pos)));
}
ElementPtr
-from_stringstream_list(std::istream &in, const std::string& file, int& line, int& pos)
+from_stringstream_list(std::istream &in, const std::string& file, int& line,
+ int& pos)
{
char c = 0;
ElementPtr list = Element::createList();
@@ -484,8 +487,7 @@
}
std::string
-Element::typeToName(Element::types type)
-{
+Element::typeToName(Element::types type) {
switch (type) {
case Element::integer:
return (std::string("integer"));
@@ -538,14 +540,16 @@
}
ElementPtr
-Element::fromJSON(std::istream& in, const std::string& file_name) throw(JSONError)
+Element::fromJSON(std::istream& in, const std::string& file_name)
+ throw(JSONError)
{
int line = 1, pos = 1;
return (fromJSON(in, file_name, line, pos));
}
ElementPtr
-Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos) throw(JSONError)
+Element::fromJSON(std::istream &in, const std::string& file, int& line,
+ int& pos) throw(JSONError)
{
char c = 0;
ElementPtr element;
@@ -892,7 +896,7 @@
isc_throw(TypeError, "merge arguments not MapElements");
}
- std::map<std::string, ConstElementPtr> m = other->mapValue();
+ const std::map<std::string, ConstElementPtr>& m = other->mapValue();
for (std::map<std::string, ConstElementPtr>::const_iterator it = m.begin();
it != m.end() ; ++it) {
if ((*it).second && (*it).second->getType() != Element::null) {
Modified: branches/trac364/src/lib/cc/tests/run_unittests.cc
==============================================================================
--- branches/trac364/src/lib/cc/tests/run_unittests.cc (original)
+++ branches/trac364/src/lib/cc/tests/run_unittests.cc Wed Oct 27 13:42:53 2010
@@ -17,8 +17,7 @@
#include <gtest/gtest.h>
int
-main(int argc, char* argv[])
-{
+main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return (RUN_ALL_TESTS());
}
Modified: branches/trac364/src/lib/config/ccsession.cc
==============================================================================
--- branches/trac364/src/lib/config/ccsession.cc (original)
+++ branches/trac364/src/lib/config/ccsession.cc Wed Oct 27 13:42:53 2010
@@ -45,6 +45,7 @@
using namespace std;
using isc::data::Element;
+using isc::data::ConstElementPtr;
using isc::data::ElementPtr;
using isc::data::JSONError;
@@ -333,8 +334,7 @@
}
std::string
-ModuleCCSession::addRemoteConfig(const std::string& spec_file_name)
-{
+ModuleCCSession::addRemoteConfig(const std::string& spec_file_name) {
ModuleSpec rmod_spec = readModuleSpecification(spec_file_name);
std::string module_name = rmod_spec.getFullSpec()->get("module_name")->stringValue();
ConfigData rmod_config = ConfigData(rmod_spec);
@@ -362,8 +362,7 @@
}
void
-ModuleCCSession::removeRemoteConfig(const std::string& module_name)
-{
+ModuleCCSession::removeRemoteConfig(const std::string& module_name) {
std::map<std::string, ConfigData>::iterator it;
it = remote_module_configs_.find(module_name);
Modified: branches/trac364/src/lib/config/ccsession.h
==============================================================================
--- branches/trac364/src/lib/config/ccsession.h (original)
+++ branches/trac364/src/lib/config/ccsession.h Wed Oct 27 13:42:53 2010
@@ -31,7 +31,7 @@
/// \brief Creates a standard config/command level success answer message
/// (i.e. of the form { "result": [ 0 ] }
/// \return Standard command/config success answer message
-ConstElementPtr createAnswer();
+isc::data::ConstElementPtr createAnswer();
///
/// \brief Creates a standard config/command level answer message
@@ -43,7 +43,8 @@
/// Element type. For rcode == 1, this argument is mandatory,
/// and must be a StringElement containing an error description
/// \return Standard command/config answer message
-ConstElementPtr createAnswer(const int rcode, ConstElementPtr arg);
+isc::data::ConstElementPtr createAnswer(const int rcode,
+ isc::data::ConstElementPtr arg);
///
/// \brief Creates a standard config/command level answer message
@@ -52,7 +53,8 @@
/// \param rcode The return code (0 for success)
/// \param arg A string to put into the StringElement argument
/// \return Standard command/config answer message
-ConstElementPtr createAnswer(const int rcode, const std::string& arg);
+isc::data::ConstElementPtr createAnswer(const int rcode,
+ const std::string& arg);
///
/// Parses a standard config/command level answer message
@@ -63,7 +65,8 @@
/// \return The optional argument in the message, or an empty ElementPtr
/// if there was no argument. If rcode != 0, this contains a
/// StringElement with the error description.
-ConstElementPtr parseAnswer(int &rcode, ConstElementPtr msg);
+isc::data::ConstElementPtr parseAnswer(int &rcode,
+ isc::data::ConstElementPtr msg);
///
/// \brief Creates a standard config/command command message with no
@@ -71,7 +74,7 @@
///
/// \param command The command string
/// \return The created message
-ConstElementPtr createCommand(const std::string& command);
+isc::data::ConstElementPtr createCommand(const std::string& command);
///
/// \brief Creates a standard config/command command message with the
@@ -81,7 +84,8 @@
/// \param arg The optional argument for the command. This can be of
/// any Element type, but it should conform to the .spec file.
/// \return The created message
-ConstElementPtr createCommand(const std::string& command, ConstElementPtr arg);
+isc::data::ConstElementPtr createCommand(const std::string& command,
+ isc::data::ConstElementPtr arg);
///
/// \brief Parses the given command into a string containing the actual
@@ -92,7 +96,8 @@
/// \param command The command message containing the command (as made
/// by createCommand()
/// \return The command string
-std::string parseCommand(ConstElementPtr& arg, ConstElementPtr command);
+std::string parseCommand(isc::data::ConstElementPtr& arg,
+ isc::data::ConstElementPtr command);
///
@@ -225,8 +230,9 @@
* \param identifier The identifier of the config value
* \return The configuration setting at the given identifier
*/
- ConstElementPtr getRemoteConfigValue(const std::string& module_name,
- const std::string& identifier) const;
+ isc::data::ConstElementPtr getRemoteConfigValue(
+ const std::string& module_name,
+ const std::string& identifier) const;
private:
ModuleSpec readModuleSpecification(const std::string& filename);
@@ -235,7 +241,8 @@
std::string module_name_;
isc::cc::AbstractSession& session_;
ModuleSpec module_specification_;
- ConstElementPtr handleConfigUpdate(ConstElementPtr new_config);
+ isc::data::ConstElementPtr handleConfigUpdate(
+ isc::data::ConstElementPtr new_config);
isc::data::ConstElementPtr(*config_handler_)(
isc::data::ConstElementPtr new_config);
@@ -245,7 +252,7 @@
std::map<std::string, ConfigData> remote_module_configs_;
void updateRemoteConfig(const std::string& module_name,
- ConstElementPtr new_config);
+ isc::data::ConstElementPtr new_config);
};
}
Modified: branches/trac364/src/lib/config/config_data.h
==============================================================================
--- branches/trac364/src/lib/config/config_data.h (original)
+++ branches/trac364/src/lib/config/config_data.h Wed Oct 27 13:42:53 2010
@@ -39,12 +39,14 @@
public:
/// Constructs a ConfigData option with no specification and an
/// empty configuration.
- ConfigData() { _config = Element::createMap(); };
+ ConfigData() { _config = isc::data::Element::createMap(); };
/// Constructs a ConfigData option with the given specification
/// and an empty configuration.
/// \param module_spec A ModuleSpec for the relevant module
- ConfigData(const ModuleSpec& module_spec) : _module_spec(module_spec) { _config = Element::createMap(); }
+ ConfigData(const ModuleSpec& module_spec) : _module_spec(module_spec) {
+ _config = isc::data::Element::createMap();
+ }
virtual ~ConfigData() {};
@@ -55,7 +57,7 @@
/// Raises a DataNotFoundError if the identifier is bad.
/// \param identifier The identifier pointing to the configuration
/// value that is to be returned
- ConstElementPtr getValue(const std::string& identifier) const;
+ isc::data::ConstElementPtr getValue(const std::string& identifier) const;
/// Returns the value currently set for the given identifier
/// If no value is set, the default value (as specified by the
@@ -67,8 +69,8 @@
/// false otherwise
/// \param identifier The identifier pointing to the configuration
/// value that is to be returned
- ConstElementPtr getValue(bool& is_default,
- const std::string& identifier) const;
+ isc::data::ConstElementPtr getValue(bool& is_default,
+ const std::string& identifier) const;
/// Returns the ModuleSpec associated with this ConfigData object
const ModuleSpec& getModuleSpec() const { return (_module_spec); }
@@ -80,12 +82,12 @@
/// \param config An ElementPtr pointing to a MapElement containing
/// *all* non-default configuration values. Existing values
/// will be removed.
- void setLocalConfig(ElementPtr config) { _config = config; }
+ void setLocalConfig(isc::data::ElementPtr config) { _config = config; }
/// Returns the local (i.e. non-default) configuration.
/// \returns An ElementPtr pointing to a MapElement containing all
/// non-default configuration options.
- ElementPtr getLocalConfig() { return (_config); }
+ isc::data::ElementPtr getLocalConfig() { return (_config); }
/// Returns a list of all possible configuration options as specified
/// by the ModuleSpec.
@@ -97,18 +99,18 @@
/// StringElements that specify the identifiers at the given
/// location (or all possible identifiers if identifier==""
/// and recurse==false)
- ConstElementPtr getItemList(const std::string& identifier = "",
- bool recurse = false) const;
+ isc::data::ConstElementPtr getItemList(const std::string& identifier = "",
+ bool recurse = false) const;
/// Returns all current configuration settings (both non-default and default).
/// \return An ElementPtr pointing to a MapElement containing
/// string->value elements, where the string is the
/// full identifier of the configuration option and the
/// value is an ElementPtr with the value.
- ConstElementPtr getFullConfig() const;
+ isc::data::ConstElementPtr getFullConfig() const;
private:
- ElementPtr _config;
+ isc::data::ElementPtr _config;
ModuleSpec _module_spec;
};
Modified: branches/trac364/src/lib/config/module_spec.cc
==============================================================================
--- branches/trac364/src/lib/config/module_spec.cc (original)
+++ branches/trac364/src/lib/config/module_spec.cc Wed Oct 27 13:42:53 2010
@@ -24,6 +24,7 @@
// todo: add more context to thrown ModuleSpecErrors?
+using namespace isc::data;
using namespace isc::config;
namespace {
Modified: branches/trac364/src/lib/config/module_spec.h
==============================================================================
--- branches/trac364/src/lib/config/module_spec.h (original)
+++ branches/trac364/src/lib/config/module_spec.h Wed Oct 27 13:42:53 2010
@@ -19,8 +19,6 @@
#include <cc/data.h>
#include <sstream>
-
-using namespace isc::data;
namespace isc { namespace config {
@@ -55,24 +53,27 @@
/// Create a \c ModuleSpec instance with the given data as
/// the specification
/// \param e The Element containing the data specification
- explicit ModuleSpec(ConstElementPtr e, const bool check = true)
+ explicit ModuleSpec(isc::data::ConstElementPtr e,
+ const bool check = true)
throw(ModuleSpecError);
/// Returns the commands part of the specification as an
/// ElementPtr, returns an empty ElementPtr if there is none
/// \return ElementPtr Shared pointer to the commands
/// part of the specification
- ConstElementPtr getCommandsSpec() const;
+ isc::data::ConstElementPtr getCommandsSpec() const;
/// Returns the configuration part of the specification as an
/// ElementPtr
/// \return ElementPtr Shared pointer to the configuration
/// part of the specification
- ConstElementPtr getConfigSpec() const;
+ isc::data::ConstElementPtr getConfigSpec() const;
/// Returns the full module specification as an ElementPtr
/// \return ElementPtr Shared pointer to the specification
- ConstElementPtr getFullSpec() const { return module_specification; }
+ isc::data::ConstElementPtr getFullSpec() const {
+ return module_specification;
+ }
/// Returns the module name as specified by the specification
const std::string getModuleName() const;
@@ -87,22 +88,28 @@
/// \param data The base \c Element of the data to check
/// \return true if the data conforms to the specification,
/// false otherwise.
- bool validate_config(ConstElementPtr data,
+ bool validate_config(isc::data::ConstElementPtr data,
const bool full = false) const;
/// errors must be of type ListElement
- bool validate_config(ConstElementPtr data, const bool full,
- ElementPtr errors) const;
+ bool validate_config(isc::data::ConstElementPtr data, const bool full,
+ isc::data::ElementPtr errors) const;
private:
- bool validate_item(ConstElementPtr spec, ConstElementPtr data,
- const bool full, ElementPtr errors) const;
- bool validate_spec(ConstElementPtr spec, ConstElementPtr data,
- const bool full, ElementPtr errors) const;
- bool validate_spec_list(ConstElementPtr spec, ConstElementPtr data,
- const bool full, ElementPtr errors) const;
+ bool validate_item(isc::data::ConstElementPtr spec,
+ isc::data::ConstElementPtr data,
+ const bool full,
+ isc::data::ElementPtr errors) const;
+ bool validate_spec(isc::data::ConstElementPtr spec,
+ isc::data::ConstElementPtr data,
+ const bool full,
+ isc::data::ElementPtr errors) const;
+ bool validate_spec_list(isc::data::ConstElementPtr spec,
+ isc::data::ConstElementPtr data,
+ const bool full,
+ isc::data::ElementPtr errors) const;
- ConstElementPtr module_specification;
+ isc::data::ConstElementPtr module_specification;
};
/// Creates a \c ModuleSpec instance from the contents
@@ -115,7 +122,7 @@
/// is checked to be of the correct form
ModuleSpec
moduleSpecFromFile(const std::string& file_name, const bool check = true)
- throw(JSONError, ModuleSpecError);
+ throw(isc::data::JSONError, ModuleSpecError);
/// Creates a \c ModuleSpec instance from the given input
/// stream that contains the contents of a .spec file.
@@ -127,7 +134,7 @@
/// to be of the correct form
ModuleSpec
moduleSpecFromFile(std::ifstream& in, const bool check = true)
- throw(JSONError, ModuleSpecError);
+ throw(isc::data::JSONError, ModuleSpecError);
} }
#endif // _DATA_DEF_H
Modified: branches/trac364/src/lib/config/tests/ccsession_unittests.cc
==============================================================================
--- branches/trac364/src/lib/config/tests/ccsession_unittests.cc (original)
+++ branches/trac364/src/lib/config/tests/ccsession_unittests.cc Wed Oct 27 13:42:53 2010
@@ -164,8 +164,7 @@
EXPECT_EQ(0, session.getMsgQueue()->size());
}
-TEST_F(CCSessionTest, session2)
-{
+TEST_F(CCSessionTest, session2) {
EXPECT_EQ(false, session.haveSubscription("Spec2", "*"));
ModuleCCSession mccs(ccspecfile("spec2.spec"), session, NULL, NULL);
EXPECT_EQ(true, session.haveSubscription("Spec2", "*"));
Modified: branches/trac364/src/lib/config/tests/module_spec_unittests.cc
==============================================================================
--- branches/trac364/src/lib/config/tests/module_spec_unittests.cc (original)
+++ branches/trac364/src/lib/config/tests/module_spec_unittests.cc Wed Oct 27 13:42:53 2010
@@ -105,8 +105,7 @@
"badname is not a valid type name");
}
-TEST(ModuleSpec, SpecfileConfigData)
-{
+TEST(ModuleSpec, SpecfileConfigData) {
module_spec_error("spec7.spec",
"module_name missing in { }");
module_spec_error("spec8.spec",
@@ -117,8 +116,7 @@
"commands is not a list of elements");
}
-TEST(ModuleSpec, SpecfileCommands)
-{
+TEST(ModuleSpec, SpecfileCommands) {
module_spec_error("spec17.spec",
"command_name missing in { \"command_args\": [ { \"item_default\": \"\", \"item_name\": \"message\", \"item_optional\": false, \"item_type\": \"string\" } ], \"command_description\": \"Print the given message to stdout\" }");
module_spec_error("spec18.spec",
Modified: branches/trac364/src/lib/config/tests/run_unittests.cc
==============================================================================
--- branches/trac364/src/lib/config/tests/run_unittests.cc (original)
+++ branches/trac364/src/lib/config/tests/run_unittests.cc Wed Oct 27 13:42:53 2010
@@ -17,8 +17,7 @@
#include <gtest/gtest.h>
int
-main(int argc, char* argv[])
-{
+main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return (RUN_ALL_TESTS());
}
Modified: branches/trac364/src/lib/datasrc/static_datasrc.cc
==============================================================================
--- branches/trac364/src/lib/datasrc/static_datasrc.cc (original)
+++ branches/trac364/src/lib/datasrc/static_datasrc.cc Wed Oct 27 13:42:53 2010
@@ -110,14 +110,12 @@
"0 28800 7200 604800 86400"));
}
-StaticDataSrc::StaticDataSrc()
-{
+StaticDataSrc::StaticDataSrc() {
setClass(RRClass::CH());
impl_ = new StaticDataSrcImpl;
}
-StaticDataSrc::~StaticDataSrc()
-{
+StaticDataSrc::~StaticDataSrc() {
delete impl_;
}
Modified: branches/trac364/src/lib/datasrc/tests/run_unittests.cc
==============================================================================
--- branches/trac364/src/lib/datasrc/tests/run_unittests.cc (original)
+++ branches/trac364/src/lib/datasrc/tests/run_unittests.cc Wed Oct 27 13:42:53 2010
@@ -19,8 +19,7 @@
#include <dns/tests/unittest_util.h>
int
-main(int argc, char* argv[])
-{
+main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
isc::UnitTestUtil::addDataPath(TEST_DATA_DIR);
Modified: branches/trac364/src/lib/dns/gen-rdatacode.py.in
==============================================================================
--- branches/trac364/src/lib/dns/gen-rdatacode.py.in (original)
+++ branches/trac364/src/lib/dns/gen-rdatacode.py.in Wed Oct 27 13:42:53 2010
@@ -113,7 +113,7 @@
if re.match('\s+// BEGIN_COMMON_MEMBERS$', line):
content += '''
explicit ''' + type_utxt + '''(const std::string& type_str);
- explicit ''' + type_utxt + '''(InputBuffer& buffer, size_t rdata_len);
+ ''' + type_utxt + '''(InputBuffer& buffer, size_t rdata_len);
''' + type_utxt + '''(const ''' + type_utxt + '''& other);
virtual std::string toText() const;
virtual void toWire(OutputBuffer& buffer) const;
@@ -129,12 +129,13 @@
global rdatadef_mtime
global rdatahdr_mtime
+ if classdir_mtime < getmtime('@srcdir@/rdata'):
+ classdir_mtime = getmtime('@srcdir@/rdata')
+
for dir in list(os.listdir('@srcdir@/rdata')):
classdir = '@srcdir@/rdata' + os.sep + dir
m = re_typecode.match(dir)
if os.path.isdir(classdir) and (m != None or dir == 'generic'):
- if classdir_mtime < getmtime(classdir):
- classdir_mtime = getmtime(classdir)
if dir == 'generic':
class_txt = 'generic'
class_code = generic_code
@@ -219,8 +220,7 @@
codetxt = code2txt[code].upper()
declarationtxt += ' ' * 4 + 'static const RR' + cap_key + '& ' + codetxt + '();\n'
deftxt += '''inline const RR''' + cap_key + '''&
-RR''' + cap_key + '''::''' + codetxt + '''()
-{
+RR''' + cap_key + '''::''' + codetxt + '''() {
static RR''' + cap_key + ''' ''' + lower_key + '''(''' + code + ''');
return (''' + lower_key + ''');
}\n
@@ -284,9 +284,7 @@
generate_rdatadef('@builddir@/rdataclass.cc', rdatadef_mtime)
generate_rdatahdr('@builddir@/rdataclass.h', rdata_declarations,
rdatahdr_mtime)
- generate_typeclasscode('rrtype',
- max(rdatadef_mtime, rdatahdr_mtime),
- typecode2txt, 'Type')
+ generate_typeclasscode('rrtype', rdatahdr_mtime, typecode2txt, 'Type')
generate_typeclasscode('rrclass', classdir_mtime,
classcode2txt, 'Class')
generate_rrparam('rrparamregistry', rdatahdr_mtime)
Modified: branches/trac364/src/lib/dns/message.cc
==============================================================================
--- branches/trac364/src/lib/dns/message.cc (original)
+++ branches/trac364/src/lib/dns/message.cc Wed Oct 27 13:42:53 2010
@@ -715,8 +715,7 @@
}
void
-Message::makeResponse()
-{
+Message::makeResponse() {
if (impl_->mode_ != Message::PARSE) {
isc_throw(InvalidMessageOperation,
"makeResponse() is performed in non-parse mode");
Modified: branches/trac364/src/lib/dns/message.h
==============================================================================
--- branches/trac364/src/lib/dns/message.h (original)
+++ branches/trac364/src/lib/dns/message.h Wed Oct 27 13:42:53 2010
@@ -114,50 +114,43 @@
};
inline const MessageFlag&
-MessageFlag::QR()
-{
+MessageFlag::QR() {
static MessageFlag f(0x8000);
return (f);
}
inline const MessageFlag&
-MessageFlag::AA()
-{
+MessageFlag::AA() {
static MessageFlag f(0x0400);
return (f);
}
inline const MessageFlag&
-MessageFlag::TC()
-{
+MessageFlag::TC() {
static MessageFlag f(0x0200);
return (f);
}
inline const MessageFlag&
-MessageFlag::RD()
-{
+MessageFlag::RD() {
static MessageFlag f(0x0100);
return (f);
}
inline const MessageFlag&
-MessageFlag::RA()
-{
+MessageFlag::RA() {
static MessageFlag f(0x0080);
return (f);
}
inline const MessageFlag&
-MessageFlag::AD()
-{
+MessageFlag::AD() {
static MessageFlag f(0x0020);
return (f);
}
inline const MessageFlag&
-MessageFlag::CD()
-{
+MessageFlag::CD() {
static MessageFlag f(0x0010);
return (f);
}
@@ -199,29 +192,25 @@
};
inline const Section&
-Section::QUESTION()
-{
+Section::QUESTION() {
static Section s(SECTION_QUESTION);
return (s);
}
inline const Section&
-Section::ANSWER()
-{
+Section::ANSWER() {
static Section s(SECTION_ANSWER);
return (s);
}
inline const Section&
-Section::AUTHORITY()
-{
+Section::AUTHORITY() {
static Section s(SECTION_AUTHORITY);
return (s);
}
inline const Section&
-Section::ADDITIONAL()
-{
+Section::ADDITIONAL() {
static Section s(SECTION_ADDITIONAL);
return (s);
}
Modified: branches/trac364/src/lib/dns/name.h
==============================================================================
--- branches/trac364/src/lib/dns/name.h (original)
+++ branches/trac364/src/lib/dns/name.h Wed Oct 27 13:42:53 2010
@@ -143,8 +143,8 @@
///
/// This constructor simply initializes the object in the straightforward
/// way.
- explicit NameComparisonResult(int order, unsigned int nlabels,
- NameRelation relation) :
+ NameComparisonResult(int order, unsigned int nlabels,
+ NameRelation relation) :
order_(order), nlabels_(nlabels), relation_(relation) {}
//@}
Modified: branches/trac364/src/lib/dns/question.cc
==============================================================================
--- branches/trac364/src/lib/dns/question.cc (original)
+++ branches/trac364/src/lib/dns/question.cc Wed Oct 27 13:42:53 2010
@@ -42,15 +42,13 @@
}
string
-Question::toText() const
-{
+Question::toText() const {
return (name_.toText() + " " + rrclass_.toText() + " " +
rrtype_.toText() + "\n");
}
unsigned int
-Question::toWire(OutputBuffer& buffer) const
-{
+Question::toWire(OutputBuffer& buffer) const {
name_.toWire(buffer);
rrtype_.toWire(buffer);
rrclass_.toWire(buffer); // number of "entries", which is always 1
@@ -59,8 +57,7 @@
}
unsigned int
-Question::toWire(MessageRenderer& renderer) const
-{
+Question::toWire(MessageRenderer& renderer) const {
renderer.writeName(name_);
rrtype_.toWire(renderer);
rrclass_.toWire(renderer);
@@ -69,8 +66,7 @@
}
ostream&
-operator<<(std::ostream& os, const Question& question)
-{
+operator<<(std::ostream& os, const Question& question) {
os << question.toText();
return (os);
}
Modified: branches/trac364/src/lib/dns/rdata.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata.cc (original)
+++ branches/trac364/src/lib/dns/rdata.cc Wed Oct 27 13:42:53 2010
@@ -82,8 +82,7 @@
}
int
-compareNames(const Name& n1, const Name& n2)
-{
+compareNames(const Name& n1, const Name& n2) {
size_t len1 = n1.getLength();
size_t len2 = n2.getLength();
size_t cmplen = min(len1, len2);
@@ -107,8 +106,7 @@
vector<uint8_t> data_;
};
-Generic::Generic(InputBuffer& buffer, size_t rdata_len)
-{
+Generic::Generic(InputBuffer& buffer, size_t rdata_len) {
if (rdata_len > MAX_RDLENGTH) {
isc_throw(InvalidRdataLength, "RDLENGTH too large");
}
@@ -119,8 +117,7 @@
impl_ = new GenericImpl(data);
}
-Generic::Generic(const string& rdata_string)
-{
+Generic::Generic(const string& rdata_string) {
istringstream iss(rdata_string);
string unknown_mark;
iss >> unknown_mark;
@@ -181,8 +178,7 @@
impl_ = new GenericImpl(data);
}
-Generic::~Generic()
-{
+Generic::~Generic() {
delete impl_;
}
@@ -191,8 +187,7 @@
{}
Generic&
-Generic::operator=(const Generic& source)
-{
+Generic::operator=(const Generic& source) {
if (impl_ == source.impl_) {
return (*this);
}
@@ -218,8 +213,7 @@
}
string
-Generic::toText() const
-{
+Generic::toText() const {
ostringstream oss;
oss << "\\# " << impl_->data_.size() << " ";
@@ -231,21 +225,18 @@
}
void
-Generic::toWire(OutputBuffer& buffer) const
-{
+Generic::toWire(OutputBuffer& buffer) const {
buffer.writeData(&impl_->data_[0], impl_->data_.size());
}
void
-Generic::toWire(MessageRenderer& renderer) const
-{
+Generic::toWire(MessageRenderer& renderer) const {
renderer.writeData(&impl_->data_[0], impl_->data_.size());
}
namespace {
inline int
-compare_internal(const GenericImpl& lhs, const GenericImpl& rhs)
-{
+compare_internal(const GenericImpl& lhs, const GenericImpl& rhs) {
size_t this_len = lhs.data_.size();
size_t other_len = rhs.data_.size();
size_t len = (this_len < other_len) ? this_len : other_len;
@@ -262,16 +253,14 @@
}
int
-Generic::compare(const Rdata& other) const
-{
+Generic::compare(const Rdata& other) const {
const Generic& other_rdata = dynamic_cast<const Generic&>(other);
return (compare_internal(*impl_, *other_rdata.impl_));
}
std::ostream&
-operator<<(std::ostream& os, const Generic& rdata)
-{
+operator<<(std::ostream& os, const Generic& rdata) {
return (os << rdata.toText());
}
} // end of namespace generic
Modified: branches/trac364/src/lib/dns/rdata/ch_3/a_1.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/ch_3/a_1.cc (original)
+++ branches/trac364/src/lib/dns/rdata/ch_3/a_1.cc Wed Oct 27 13:42:53 2010
@@ -30,13 +30,11 @@
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
-A::A(const string& addrstr UNUSED_PARAM)
-{
+A::A(const string& addrstr UNUSED_PARAM) {
// TBD
}
-A::A(InputBuffer& buffer UNUSED_PARAM, size_t rdata_len UNUSED_PARAM)
-{
+A::A(InputBuffer& buffer UNUSED_PARAM, size_t rdata_len UNUSED_PARAM) {
// TBD
}
@@ -45,27 +43,23 @@
}
void
-A::toWire(OutputBuffer& buffer UNUSED_PARAM) const
-{
+A::toWire(OutputBuffer& buffer UNUSED_PARAM) const {
// TBD
}
void
-A::toWire(MessageRenderer& renderer UNUSED_PARAM) const
-{
+A::toWire(MessageRenderer& renderer UNUSED_PARAM) const {
// TBD
}
string
-A::toText() const
-{
+A::toText() const {
// TBD
isc_throw(InvalidRdataText, "Not implemented yet");
}
int
-A::compare(const Rdata& other UNUSED_PARAM) const
-{
+A::compare(const Rdata& other UNUSED_PARAM) const {
return (0); // dummy. TBD
}
Modified: branches/trac364/src/lib/dns/rdata/generic/cname_5.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/cname_5.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/cname_5.cc Wed Oct 27 13:42:53 2010
@@ -49,34 +49,29 @@
{}
void
-CNAME::toWire(OutputBuffer& buffer) const
-{
+CNAME::toWire(OutputBuffer& buffer) const {
cname_.toWire(buffer);
}
void
-CNAME::toWire(MessageRenderer& renderer) const
-{
+CNAME::toWire(MessageRenderer& renderer) const {
renderer.writeName(cname_);
}
string
-CNAME::toText() const
-{
+CNAME::toText() const {
return (cname_.toText());
}
int
-CNAME::compare(const Rdata& other) const
-{
+CNAME::compare(const Rdata& other) const {
const CNAME& other_cname = dynamic_cast<const CNAME&>(other);
return (compareNames(cname_, other_cname.cname_));
}
const Name&
-CNAME::getCname() const
-{
+CNAME::getCname() const {
return (cname_);
}
Modified: branches/trac364/src/lib/dns/rdata/generic/dname_39.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/dname_39.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/dname_39.cc Wed Oct 27 13:42:53 2010
@@ -49,34 +49,29 @@
{}
void
-DNAME::toWire(OutputBuffer& buffer) const
-{
+DNAME::toWire(OutputBuffer& buffer) const {
dname_.toWire(buffer);
}
void
-DNAME::toWire(MessageRenderer& renderer) const
-{
+DNAME::toWire(MessageRenderer& renderer) const {
renderer.writeName(dname_);
}
string
-DNAME::toText() const
-{
+DNAME::toText() const {
return (dname_.toText());
}
int
-DNAME::compare(const Rdata& other) const
-{
+DNAME::compare(const Rdata& other) const {
const DNAME& other_dname = dynamic_cast<const DNAME&>(other);
return (compareNames(dname_, other_dname.dname_));
}
const Name&
-DNAME::getDname() const
-{
+DNAME::getDname() const {
return (dname_);
}
Modified: branches/trac364/src/lib/dns/rdata/generic/dnskey_48.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/dnskey_48.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/dnskey_48.cc Wed Oct 27 13:42:53 2010
@@ -103,8 +103,7 @@
{}
DNSKEY&
-DNSKEY::operator=(const DNSKEY& source)
-{
+DNSKEY::operator=(const DNSKEY& source) {
if (impl_ == source.impl_) {
return (*this);
}
@@ -116,14 +115,12 @@
return (*this);
}
-DNSKEY::~DNSKEY()
-{
+DNSKEY::~DNSKEY() {
delete impl_;
}
string
-DNSKEY::toText() const
-{
+DNSKEY::toText() const {
return (boost::lexical_cast<string>(static_cast<int>(impl_->flags_)) +
" " + boost::lexical_cast<string>(static_cast<int>(impl_->protocol_)) +
" " + boost::lexical_cast<string>(static_cast<int>(impl_->algorithm_)) +
@@ -131,8 +128,7 @@
}
void
-DNSKEY::toWire(OutputBuffer& buffer) const
-{
+DNSKEY::toWire(OutputBuffer& buffer) const {
buffer.writeUint16(impl_->flags_);
buffer.writeUint8(impl_->protocol_);
buffer.writeUint8(impl_->algorithm_);
@@ -140,8 +136,7 @@
}
void
-DNSKEY::toWire(MessageRenderer& renderer) const
-{
+DNSKEY::toWire(MessageRenderer& renderer) const {
renderer.writeUint16(impl_->flags_);
renderer.writeUint8(impl_->protocol_);
renderer.writeUint8(impl_->algorithm_);
@@ -149,8 +144,7 @@
}
int
-DNSKEY::compare(const Rdata& other) const
-{
+DNSKEY::compare(const Rdata& other) const {
const DNSKEY& other_dnskey = dynamic_cast<const DNSKEY&>(other);
if (impl_->flags_ != other_dnskey.impl_->flags_) {
@@ -176,8 +170,7 @@
}
uint16_t
-DNSKEY::getTag() const
-{
+DNSKEY::getTag() const {
if (impl_->algorithm_ == 1) {
int len = impl_->keydata_.size();
return ((impl_->keydata_[len - 3] << 8) + impl_->keydata_[len - 2]);
Modified: branches/trac364/src/lib/dns/rdata/generic/ds_43.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/ds_43.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/ds_43.cc Wed Oct 27 13:42:53 2010
@@ -77,8 +77,7 @@
impl_ = new DSImpl(tag, algorithm, digest_type, digest);
}
-DS::DS(InputBuffer& buffer, size_t rdata_len)
-{
+DS::DS(InputBuffer& buffer, size_t rdata_len) {
if (rdata_len < 4) {
isc_throw(InvalidRdataLength, "DS too short");
}
@@ -99,8 +98,7 @@
{}
DS&
-DS::operator=(const DS& source)
-{
+DS::operator=(const DS& source) {
if (impl_ == source.impl_) {
return (*this);
}
@@ -112,14 +110,12 @@
return (*this);
}
-DS::~DS()
-{
+DS::~DS() {
delete impl_;
}
string
-DS::toText() const
-{
+DS::toText() const {
using namespace boost;
return (lexical_cast<string>(static_cast<int>(impl_->tag_)) +
" " + lexical_cast<string>(static_cast<int>(impl_->algorithm_)) +
@@ -128,8 +124,7 @@
}
void
-DS::toWire(OutputBuffer& buffer) const
-{
+DS::toWire(OutputBuffer& buffer) const {
buffer.writeUint16(impl_->tag_);
buffer.writeUint8(impl_->algorithm_);
buffer.writeUint8(impl_->digest_type_);
@@ -137,8 +132,7 @@
}
void
-DS::toWire(MessageRenderer& renderer) const
-{
+DS::toWire(MessageRenderer& renderer) const {
renderer.writeUint16(impl_->tag_);
renderer.writeUint8(impl_->algorithm_);
renderer.writeUint8(impl_->digest_type_);
@@ -146,8 +140,7 @@
}
int
-DS::compare(const Rdata& other) const
-{
+DS::compare(const Rdata& other) const {
const DS& other_ds = dynamic_cast<const DS&>(other);
if (impl_->tag_ != other_ds.impl_->tag_) {
Modified: branches/trac364/src/lib/dns/rdata/generic/mx_15.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/mx_15.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/mx_15.cc Wed Oct 27 13:42:53 2010
@@ -67,28 +67,24 @@
{}
void
-MX::toWire(OutputBuffer& buffer) const
-{
+MX::toWire(OutputBuffer& buffer) const {
buffer.writeUint16(preference_);
mxname_.toWire(buffer);
}
void
-MX::toWire(MessageRenderer& renderer) const
-{
+MX::toWire(MessageRenderer& renderer) const {
renderer.writeUint16(preference_);
renderer.writeName(mxname_);
}
string
-MX::toText() const
-{
+MX::toText() const {
return (lexical_cast<string>(preference_) + " " + mxname_.toText());
}
int
-MX::compare(const Rdata& other) const
-{
+MX::compare(const Rdata& other) const {
const MX& other_mx = dynamic_cast<const MX&>(other);
if (preference_ < other_mx.preference_) {
@@ -101,14 +97,12 @@
}
const Name&
-MX::getMXName() const
-{
+MX::getMXName() const {
return (mxname_);
}
uint16_t
-MX::getMXPref() const
-{
+MX::getMXPref() const {
return (preference_);
}
Modified: branches/trac364/src/lib/dns/rdata/generic/mx_15.h
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/mx_15.h (original)
+++ branches/trac364/src/lib/dns/rdata/generic/mx_15.h Wed Oct 27 13:42:53 2010
@@ -35,7 +35,7 @@
// BEGIN_COMMON_MEMBERS
// END_COMMON_MEMBERS
- explicit MX(uint16_t preference, const Name& mxname);
+ MX(uint16_t preference, const Name& mxname);
///
/// Specialized methods
Modified: branches/trac364/src/lib/dns/rdata/generic/ns_2.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/ns_2.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/ns_2.cc Wed Oct 27 13:42:53 2010
@@ -45,34 +45,29 @@
{}
void
-NS::toWire(OutputBuffer& buffer) const
-{
+NS::toWire(OutputBuffer& buffer) const {
nsname_.toWire(buffer);
}
void
-NS::toWire(MessageRenderer& renderer) const
-{
+NS::toWire(MessageRenderer& renderer) const {
renderer.writeName(nsname_);
}
string
-NS::toText() const
-{
+NS::toText() const {
return (nsname_.toText());
}
int
-NS::compare(const Rdata& other) const
-{
+NS::compare(const Rdata& other) const {
const NS& other_ns = dynamic_cast<const NS&>(other);
return (compareNames(nsname_, other_ns.nsname_));
}
const Name&
-NS::getNSName() const
-{
+NS::getNSName() const {
return (nsname_);
}
Modified: branches/trac364/src/lib/dns/rdata/generic/nsec3_50.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/nsec3_50.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/nsec3_50.cc Wed Oct 27 13:42:53 2010
@@ -127,8 +127,7 @@
impl_ = new NSEC3Impl(hashalg, flags, iterations, salt, next, typebits);
}
-NSEC3::NSEC3(InputBuffer& buffer, size_t rdata_len)
-{
+NSEC3::NSEC3(InputBuffer& buffer, size_t rdata_len) {
if (rdata_len < 5) {
isc_throw(InvalidRdataLength, "NSEC3 too short");
}
@@ -189,8 +188,7 @@
{}
NSEC3&
-NSEC3::operator=(const NSEC3& source)
-{
+NSEC3::operator=(const NSEC3& source) {
if (impl_ == source.impl_) {
return (*this);
}
@@ -202,14 +200,12 @@
return (*this);
}
-NSEC3::~NSEC3()
-{
+NSEC3::~NSEC3() {
delete impl_;
}
string
-NSEC3::toText() const
-{
+NSEC3::toText() const {
ostringstream s;
int len = 0;
for (int i = 0; i < impl_->typebits_.size(); i += len) {
@@ -241,8 +237,7 @@
}
void
-NSEC3::toWire(OutputBuffer& buffer) const
-{
+NSEC3::toWire(OutputBuffer& buffer) const {
buffer.writeUint8(impl_->hashalg_);
buffer.writeUint8(impl_->flags_);
buffer.writeUint16(impl_->iterations_);
@@ -254,8 +249,7 @@
}
void
-NSEC3::toWire(MessageRenderer& renderer) const
-{
+NSEC3::toWire(MessageRenderer& renderer) const {
renderer.writeUint8(impl_->hashalg_);
renderer.writeUint8(impl_->flags_);
renderer.writeUint16(impl_->iterations_);
@@ -267,8 +261,7 @@
}
int
-NSEC3::compare(const Rdata& other) const
-{
+NSEC3::compare(const Rdata& other) const {
const NSEC3& other_nsec3 = dynamic_cast<const NSEC3&>(other);
if (impl_->hashalg_ != other_nsec3.impl_->hashalg_) {
Modified: branches/trac364/src/lib/dns/rdata/generic/nsec3param_51.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/nsec3param_51.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/nsec3param_51.cc Wed Oct 27 13:42:53 2010
@@ -73,8 +73,7 @@
impl_ = new NSEC3PARAMImpl(hashalg, flags, iterations, salt);
}
-NSEC3PARAM::NSEC3PARAM(InputBuffer& buffer, size_t rdata_len)
-{
+NSEC3PARAM::NSEC3PARAM(InputBuffer& buffer, size_t rdata_len) {
if (rdata_len < 4) {
isc_throw(InvalidRdataLength, "NSEC3PARAM too short");
}
@@ -102,8 +101,7 @@
{}
NSEC3PARAM&
-NSEC3PARAM::operator=(const NSEC3PARAM& source)
-{
+NSEC3PARAM::operator=(const NSEC3PARAM& source) {
if (impl_ == source.impl_) {
return (*this);
}
@@ -115,14 +113,12 @@
return (*this);
}
-NSEC3PARAM::~NSEC3PARAM()
-{
+NSEC3PARAM::~NSEC3PARAM() {
delete impl_;
}
string
-NSEC3PARAM::toText() const
-{
+NSEC3PARAM::toText() const {
using namespace boost;
return (lexical_cast<string>(static_cast<int>(impl_->hashalg_)) +
" " + lexical_cast<string>(static_cast<int>(impl_->flags_)) +
@@ -131,8 +127,7 @@
}
void
-NSEC3PARAM::toWire(OutputBuffer& buffer) const
-{
+NSEC3PARAM::toWire(OutputBuffer& buffer) const {
buffer.writeUint8(impl_->hashalg_);
buffer.writeUint8(impl_->flags_);
buffer.writeUint16(impl_->iterations_);
@@ -141,8 +136,7 @@
}
void
-NSEC3PARAM::toWire(MessageRenderer& renderer) const
-{
+NSEC3PARAM::toWire(MessageRenderer& renderer) const {
renderer.writeUint8(impl_->hashalg_);
renderer.writeUint8(impl_->flags_);
renderer.writeUint16(impl_->iterations_);
@@ -151,8 +145,7 @@
}
int
-NSEC3PARAM::compare(const Rdata& other) const
-{
+NSEC3PARAM::compare(const Rdata& other) const {
const NSEC3PARAM& other_param = dynamic_cast<const NSEC3PARAM&>(other);
if (impl_->hashalg_ != other_param.impl_->hashalg_) {
Modified: branches/trac364/src/lib/dns/rdata/generic/opt_41.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/opt_41.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/opt_41.cc Wed Oct 27 13:42:53 2010
@@ -28,13 +28,11 @@
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
-OPT::OPT(const string& type_str UNUSED_PARAM)
-{
+OPT::OPT(const string& type_str UNUSED_PARAM) {
isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text");
}
-OPT::OPT(InputBuffer& buffer, size_t rdata_len)
-{
+OPT::OPT(InputBuffer& buffer, size_t rdata_len) {
// setPosition() will throw against a short buffer anyway, but it's safer
// to check it explicitly here.
if (buffer.getLength() - buffer.getPosition() < rdata_len) {
@@ -45,32 +43,27 @@
buffer.setPosition(buffer.getPosition() + rdata_len);
}
-OPT::OPT(const OPT& source UNUSED_PARAM) : Rdata()
-{
+OPT::OPT(const OPT& source UNUSED_PARAM) : Rdata() {
// there's nothing to copy in this simple implementation.
}
std::string
-OPT::toText() const
-{
+OPT::toText() const {
return ("");
}
void
-OPT::toWire(OutputBuffer& buffer UNUSED_PARAM) const
-{
+OPT::toWire(OutputBuffer& buffer UNUSED_PARAM) const {
// nothing to do, as this simple version doesn't support any options.
}
void
-OPT::toWire(MessageRenderer& renderer UNUSED_PARAM) const
-{
+OPT::toWire(MessageRenderer& renderer UNUSED_PARAM) const {
// nothing to do, as this simple version doesn't support any options.
}
int
-OPT::compare(const Rdata& other) const
-{
+OPT::compare(const Rdata& other) const {
//const OPT& other_opt = dynamic_cast<const OPT&>(other);
dynamic_cast<const OPT&>(other); // right now we don't need other_opt
Modified: branches/trac364/src/lib/dns/rdata/generic/ptr_12.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/ptr_12.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/ptr_12.cc Wed Oct 27 13:42:53 2010
@@ -45,26 +45,22 @@
{}
std::string
-PTR::toText() const
-{
+PTR::toText() const {
return (ptr_name_.toText());
}
void
-PTR::toWire(OutputBuffer& buffer) const
-{
+PTR::toWire(OutputBuffer& buffer) const {
ptr_name_.toWire(buffer);
}
void
-PTR::toWire(MessageRenderer& renderer) const
-{
+PTR::toWire(MessageRenderer& renderer) const {
renderer.writeName(ptr_name_);
}
int
-PTR::compare(const Rdata& other) const
-{
+PTR::compare(const Rdata& other) const {
// The compare method normally begins with this dynamic cast.
const PTR& other_ptr = dynamic_cast<const PTR&>(other);
@@ -73,8 +69,7 @@
}
const Name&
-PTR::getPTRName() const
-{
+PTR::getPTRName() const {
return (ptr_name_);
}
Modified: branches/trac364/src/lib/dns/rdata/generic/rrsig_46.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/rrsig_46.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/rrsig_46.cc Wed Oct 27 13:42:53 2010
@@ -106,8 +106,7 @@
Name(signer_txt), signature);
}
-RRSIG::RRSIG(InputBuffer& buffer, size_t rdata_len)
-{
+RRSIG::RRSIG(InputBuffer& buffer, size_t rdata_len) {
size_t pos = buffer.getPosition();
if (rdata_len < RRSIG_MINIMUM_LEN) {
@@ -142,8 +141,7 @@
{}
RRSIG&
-RRSIG::operator=(const RRSIG& source)
-{
+RRSIG::operator=(const RRSIG& source) {
if (impl_ == source.impl_) {
return (*this);
}
@@ -155,14 +153,12 @@
return (*this);
}
-RRSIG::~RRSIG()
-{
+RRSIG::~RRSIG() {
delete impl_;
}
string
-RRSIG::toText() const
-{
+RRSIG::toText() const {
string expire = timeToText(impl_->timeexpire_);
string inception = timeToText(impl_->timeinception_);
@@ -178,8 +174,7 @@
}
void
-RRSIG::toWire(OutputBuffer& buffer) const
-{
+RRSIG::toWire(OutputBuffer& buffer) const {
impl_->covered_.toWire(buffer);
buffer.writeUint8(impl_->algorithm_);
buffer.writeUint8(impl_->labels_);
@@ -192,8 +187,7 @@
}
void
-RRSIG::toWire(MessageRenderer& renderer) const
-{
+RRSIG::toWire(MessageRenderer& renderer) const {
impl_->covered_.toWire(renderer);
renderer.writeUint8(impl_->algorithm_);
renderer.writeUint8(impl_->labels_);
@@ -206,8 +200,7 @@
}
int
-RRSIG::compare(const Rdata& other) const
-{
+RRSIG::compare(const Rdata& other) const {
const RRSIG& other_rrsig = dynamic_cast<const RRSIG&>(other);
if (impl_->covered_.getCode() != other_rrsig.impl_->covered_.getCode()) {
Modified: branches/trac364/src/lib/dns/rdata/generic/soa_6.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/soa_6.cc (original)
+++ branches/trac364/src/lib/dns/rdata/generic/soa_6.cc Wed Oct 27 13:42:53 2010
@@ -94,24 +94,21 @@
}
void
-SOA::toWire(OutputBuffer& buffer) const
-{
+SOA::toWire(OutputBuffer& buffer) const {
mname_.toWire(buffer);
rname_.toWire(buffer);
buffer.writeData(numdata_, sizeof(numdata_));
}
void
-SOA::toWire(MessageRenderer& renderer) const
-{
+SOA::toWire(MessageRenderer& renderer) const {
renderer.writeName(mname_);
renderer.writeName(rname_);
renderer.writeData(numdata_, sizeof(numdata_));
}
string
-SOA::toText() const
-{
+SOA::toText() const {
InputBuffer b(numdata_, sizeof(numdata_));
uint32_t serial = b.readUint32();
uint32_t refresh = b.readUint32();
@@ -128,8 +125,7 @@
}
int
-SOA::compare(const Rdata& other) const
-{
+SOA::compare(const Rdata& other) const {
const SOA& other_soa = dynamic_cast<const SOA&>(other);
int order = compareNames(mname_, other_soa.mname_);
Modified: branches/trac364/src/lib/dns/rdata/generic/soa_6.h
==============================================================================
--- branches/trac364/src/lib/dns/rdata/generic/soa_6.h (original)
+++ branches/trac364/src/lib/dns/rdata/generic/soa_6.h Wed Oct 27 13:42:53 2010
@@ -33,9 +33,9 @@
// BEGIN_COMMON_MEMBERS
// END_COMMON_MEMBERS
- explicit SOA(const Name& mname, const Name& rname, uint32_t serial,
- uint32_t refresh, uint32_t retry, uint32_t expire,
- uint32_t minimum);
+ SOA(const Name& mname, const Name& rname, uint32_t serial,
+ uint32_t refresh, uint32_t retry, uint32_t expire,
+ uint32_t minimum);
private:
/// Note: this is a prototype version; we may reconsider
/// this representation later.
Modified: branches/trac364/src/lib/dns/rdata/hs_4/a_1.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/hs_4/a_1.cc (original)
+++ branches/trac364/src/lib/dns/rdata/hs_4/a_1.cc Wed Oct 27 13:42:53 2010
@@ -30,43 +30,36 @@
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
-A::A(const string& addrstr UNUSED_PARAM)
-{
+A::A(const string& addrstr UNUSED_PARAM) {
// TBD
}
-A::A(InputBuffer& buffer UNUSED_PARAM, size_t rdata_len UNUSED_PARAM)
-{
+A::A(InputBuffer& buffer UNUSED_PARAM, size_t rdata_len UNUSED_PARAM) {
// TBD
}
-A::A(const A& source UNUSED_PARAM) : Rdata()
-{
+A::A(const A& source UNUSED_PARAM) : Rdata() {
// TBD
}
void
-A::toWire(OutputBuffer& buffer UNUSED_PARAM) const
-{
+A::toWire(OutputBuffer& buffer UNUSED_PARAM) const {
// TBD
}
void
-A::toWire(MessageRenderer& renderer UNUSED_PARAM) const
-{
+A::toWire(MessageRenderer& renderer UNUSED_PARAM) const {
// TBD
}
string
-A::toText() const
-{
+A::toText() const {
// TBD
isc_throw(InvalidRdataText, "Not implemented yet");
}
int
-A::compare(const Rdata& other UNUSED_PARAM) const
-{
+A::compare(const Rdata& other UNUSED_PARAM) const {
return (0); // dummy. TBD
}
Modified: branches/trac364/src/lib/dns/rdata/template.cc
==============================================================================
--- branches/trac364/src/lib/dns/rdata/template.cc (original)
+++ branches/trac364/src/lib/dns/rdata/template.cc Wed Oct 27 13:42:53 2010
@@ -34,36 +34,29 @@
// If you added member functions specific to this derived class, you'll need
// to implement them here, of course.
-MyType::MyType(const string& type_str)
-{
+MyType::MyType(const string& type_str) {
}
-MyType::MyType(InputBuffer& buffer, size_t rdata_len)
-{
+MyType::MyType(InputBuffer& buffer, size_t rdata_len) {
}
-MyType::MyType(const MyType& source)
-{
+MyType::MyType(const MyType& source) {
}
std::string
-MyType::toText() const
-{
+MyType::toText() const {
}
void
-MyType::toWire(OutputBuffer& buffer) const
-{
+MyType::toWire(OutputBuffer& buffer) const {
}
void
-MyType::toWire(MessageRenderer& renderer) const
-{
+MyType::toWire(MessageRenderer& renderer) const {
}
int
-MyType::compare(const Rdata& other) const
-{
+MyType::compare(const Rdata& other) const {
// The compare method normally begins with this dynamic cast.
const MyType& other_mytype = dynamic_cast<const MyType&>(other);
// ...
Modified: branches/trac364/src/lib/dns/rrclass-placeholder.h
==============================================================================
--- branches/trac364/src/lib/dns/rrclass-placeholder.h (original)
+++ branches/trac364/src/lib/dns/rrclass-placeholder.h Wed Oct 27 13:42:53 2010
@@ -260,16 +260,14 @@
// END_WELL_KNOWN_CLASS_DEFINITIONS
inline const RRClass&
-RRClass::NONE()
-{
+RRClass::NONE() {
static RRClass rrclass(RRCLASS_NONE);
return (rrclass);
}
inline const RRClass&
-RRClass::ANY()
-{
+RRClass::ANY() {
static RRClass rrclass(RRCLASS_ANY);
return (rrclass);
Modified: branches/trac364/src/lib/dns/rrclass.cc
==============================================================================
--- branches/trac364/src/lib/dns/rrclass.cc (original)
+++ branches/trac364/src/lib/dns/rrclass.cc Wed Oct 27 13:42:53 2010
@@ -31,13 +31,11 @@
namespace isc {
namespace dns {
-RRClass::RRClass(const string& classstr)
-{
+RRClass::RRClass(const string& classstr) {
classcode_ = RRParamRegistry::getRegistry().textToClassCode(classstr);
}
-RRClass::RRClass(InputBuffer& buffer)
-{
+RRClass::RRClass(InputBuffer& buffer) {
if (buffer.getLength() - buffer.getPosition() < sizeof(uint16_t)) {
isc_throw(IncompleteRRClass, "incomplete wire-format RR class");
}
@@ -45,26 +43,22 @@
}
const string
-RRClass::toText() const
-{
+RRClass::toText() const {
return (RRParamRegistry::getRegistry().codeToClassText(classcode_));
}
void
-RRClass::toWire(OutputBuffer& buffer) const
-{
+RRClass::toWire(OutputBuffer& buffer) const {
buffer.writeUint16(classcode_);
}
void
-RRClass::toWire(MessageRenderer& renderer) const
-{
+RRClass::toWire(MessageRenderer& renderer) const {
renderer.writeUint16(classcode_);
}
ostream&
-operator<<(ostream& os, const RRClass& rrclass)
-{
+operator<<(ostream& os, const RRClass& rrclass) {
os << rrclass.toText();
return (os);
}
Modified: branches/trac364/src/lib/dns/rrparamregistry-placeholder.cc
==============================================================================
--- branches/trac364/src/lib/dns/rrparamregistry-placeholder.cc (original)
+++ branches/trac364/src/lib/dns/rrparamregistry-placeholder.cc Wed Oct 27 13:42:53 2010
@@ -49,8 +49,7 @@
/// containers below.
///
bool
-CICharLess(char c1, char c2)
-{
+CICharLess(char c1, char c2) {
return (tolower(static_cast<unsigned char>(c1)) <
tolower(static_cast<unsigned char>(c2)));
}
@@ -84,29 +83,25 @@
typedef map<uint16_t, RRTypeParamPtr> CodeRRTypeMap;
inline const string&
-RRTypeParam::UNKNOWN_PREFIX()
-{
+RRTypeParam::UNKNOWN_PREFIX() {
static const string p("TYPE");
return (p);
}
inline size_t
-RRTypeParam::UNKNOWN_PREFIXLEN()
-{
+RRTypeParam::UNKNOWN_PREFIXLEN() {
static size_t plen = UNKNOWN_PREFIX().size();
return (plen);
}
inline const string&
-RRTypeParam::UNKNOWN_MAX()
-{
+RRTypeParam::UNKNOWN_MAX() {
static const string p("TYPE65535");
return (p);
}
inline size_t
-RRTypeParam::UNKNOWN_MAXLEN()
-{
+RRTypeParam::UNKNOWN_MAXLEN() {
static size_t plen = UNKNOWN_MAX().size();
return (plen);
}
@@ -130,29 +125,25 @@
typedef map<uint16_t, RRClassParamPtr> CodeRRClassMap;
inline const string&
-RRClassParam::UNKNOWN_PREFIX()
-{
+RRClassParam::UNKNOWN_PREFIX() {
static const string p("CLASS");
return (p);
}
inline size_t
-RRClassParam::UNKNOWN_PREFIXLEN()
-{
+RRClassParam::UNKNOWN_PREFIXLEN() {
static size_t plen = UNKNOWN_PREFIX().size();
return (plen);
}
inline const string&
-RRClassParam::UNKNOWN_MAX()
-{
+RRClassParam::UNKNOWN_MAX() {
static const string p("CLASS65535");
return (p);
}
inline size_t
-RRClassParam::UNKNOWN_MAXLEN()
-{
+RRClassParam::UNKNOWN_MAXLEN() {
static size_t plen = UNKNOWN_MAX().size();
return (plen);
}
@@ -209,8 +200,7 @@
GenericRdataFactoryMap genericrdata_factories;
};
-RRParamRegistry::RRParamRegistry()
-{
+RRParamRegistry::RRParamRegistry() {
impl_ = new RRParamRegistryImpl;
// set up parameters for well-known RRs
@@ -223,14 +213,12 @@
}
}
-RRParamRegistry::~RRParamRegistry()
-{
+RRParamRegistry::~RRParamRegistry() {
delete impl_;
}
RRParamRegistry&
-RRParamRegistry::getRegistry()
-{
+RRParamRegistry::getRegistry() {
static RRParamRegistry registry;
return (registry);
@@ -301,8 +289,7 @@
}
bool
-RRParamRegistry::removeRdataFactory(const RRType& rrtype)
-{
+RRParamRegistry::removeRdataFactory(const RRType& rrtype) {
GenericRdataFactoryMap::iterator found =
impl_->genericrdata_factories.find(rrtype);
if (found != impl_->genericrdata_factories.end()) {
@@ -320,15 +307,13 @@
/// included in <cstring>. To be as much as portable within the C++ standard
/// we take the "in house" approach here.
///
-bool CICharEqual(char c1, char c2)
-{
+bool CICharEqual(char c1, char c2) {
return (tolower(static_cast<unsigned char>(c1)) ==
tolower(static_cast<unsigned char>(c2)));
}
bool
-caseStringEqual(const string& s1, const string& s2, size_t n)
-{
+caseStringEqual(const string& s1, const string& s2, size_t n) {
assert(s1.size() >= n && s2.size() >= n);
return (mismatch(s1.begin(), s1.begin() + n, s2.begin(), CICharEqual).first
@@ -378,8 +363,7 @@
template <typename MC, typename MS>
inline bool
-removeParam(uint16_t code, MC& codemap, MS& stringmap)
-{
+removeParam(uint16_t code, MC& codemap, MS& stringmap) {
typename MC::iterator found = codemap.find(code);
if (found != codemap.end()) {
@@ -397,8 +381,7 @@
template <typename PT, typename MS, typename ET>
inline uint16_t
-textToCode(const string& code_str, MS& stringmap)
-{
+textToCode(const string& code_str, MS& stringmap) {
typename MS::const_iterator found;
found = stringmap.find(code_str);
@@ -424,8 +407,7 @@
template <typename PT, typename MC>
inline string
-codeToText(uint16_t code, MC& codemap)
-{
+codeToText(uint16_t code, MC& codemap) {
typename MC::const_iterator found;
found = codemap.find(code);
@@ -440,57 +422,49 @@
}
bool
-RRParamRegistry::addType(const string& type_string, uint16_t code)
-{
+RRParamRegistry::addType(const string& type_string, uint16_t code) {
return (addParam<RRTypeParam, CodeRRTypeMap, StrRRTypeMap, RRTypeExists>
(type_string, code, impl_->code2typemap, impl_->str2typemap));
}
bool
-RRParamRegistry::removeType(uint16_t code)
-{
+RRParamRegistry::removeType(uint16_t code) {
return (removeParam<CodeRRTypeMap, StrRRTypeMap>(code, impl_->code2typemap,
impl_->str2typemap));
}
uint16_t
-RRParamRegistry::textToTypeCode(const string& type_string) const
-{
+RRParamRegistry::textToTypeCode(const string& type_string) const {
return (textToCode<RRTypeParam, StrRRTypeMap,
InvalidRRType>(type_string, impl_->str2typemap));
}
string
-RRParamRegistry::codeToTypeText(uint16_t code) const
-{
+RRParamRegistry::codeToTypeText(uint16_t code) const {
return (codeToText<RRTypeParam, CodeRRTypeMap>(code, impl_->code2typemap));
}
bool
-RRParamRegistry::addClass(const string& class_string, uint16_t code)
-{
+RRParamRegistry::addClass(const string& class_string, uint16_t code) {
return (addParam<RRClassParam, CodeRRClassMap, StrRRClassMap, RRClassExists>
(class_string, code, impl_->code2classmap, impl_->str2classmap));
}
bool
-RRParamRegistry::removeClass(uint16_t code)
-{
+RRParamRegistry::removeClass(uint16_t code) {
return (removeParam<CodeRRClassMap, StrRRClassMap>(code,
impl_->code2classmap,
impl_->str2classmap));
}
uint16_t
-RRParamRegistry::textToClassCode(const string& class_string) const
-{
+RRParamRegistry::textToClassCode(const string& class_string) const {
return (textToCode<RRClassParam, StrRRClassMap,
InvalidRRClass>(class_string, impl_->str2classmap));
}
string
-RRParamRegistry::codeToClassText(uint16_t code) const
-{
+RRParamRegistry::codeToClassText(uint16_t code) const {
return (codeToText<RRClassParam, CodeRRClassMap>(code,
impl_->code2classmap));
}
Modified: branches/trac364/src/lib/dns/rrset.cc
==============================================================================
--- branches/trac364/src/lib/dns/rrset.cc (original)
+++ branches/trac364/src/lib/dns/rrset.cc Wed Oct 27 13:42:53 2010
@@ -35,14 +35,12 @@
namespace isc {
namespace dns {
void
-AbstractRRset::addRdata(const Rdata& rdata)
-{
+AbstractRRset::addRdata(const Rdata& rdata) {
addRdata(createRdata(getType(), getClass(), rdata));
}
string
-AbstractRRset::toText() const
-{
+AbstractRRset::toText() const {
string s;
RdataIteratorPtr it = getRdataIterator();
@@ -64,8 +62,7 @@
namespace {
template <typename T>
inline unsigned int
-rrsetToWire(const AbstractRRset& rrset, T& output, const size_t limit)
-{
+rrsetToWire(const AbstractRRset& rrset, T& output, const size_t limit) {
unsigned int n = 0;
RdataIteratorPtr it = rrset.getRdataIterator();
@@ -105,14 +102,12 @@
}
unsigned int
-AbstractRRset::toWire(OutputBuffer& buffer) const
-{
+AbstractRRset::toWire(OutputBuffer& buffer) const {
return (rrsetToWire<OutputBuffer>(*this, buffer, 0));
}
unsigned int
-AbstractRRset::toWire(MessageRenderer& renderer) const
-{
+AbstractRRset::toWire(MessageRenderer& renderer) const {
const unsigned int rrs_written = rrsetToWire<MessageRenderer>(
*this, renderer, renderer.getLengthLimit());
if (getRdataCount() > rrs_written) {
@@ -122,8 +117,7 @@
}
ostream&
-operator<<(ostream& os, const AbstractRRset& rrset)
-{
+operator<<(ostream& os, const AbstractRRset& rrset) {
os << rrset.toText();
return (os);
}
@@ -151,80 +145,67 @@
impl_ = new BasicRRsetImpl(name, rrclass, rrtype, ttl);
}
-BasicRRset::~BasicRRset()
-{
+BasicRRset::~BasicRRset() {
delete impl_;
}
void
-BasicRRset::addRdata(ConstRdataPtr rdata)
-{
+BasicRRset::addRdata(ConstRdataPtr rdata) {
impl_->rdatalist_.push_back(rdata);
}
void
-BasicRRset::addRdata(const Rdata& rdata)
-{
+BasicRRset::addRdata(const Rdata& rdata) {
AbstractRRset::addRdata(rdata);
}
unsigned int
-BasicRRset::getRdataCount() const
-{
+BasicRRset::getRdataCount() const {
return (impl_->rdatalist_.size());
}
const Name&
-BasicRRset::getName() const
-{
+BasicRRset::getName() const {
return (impl_->name_);
}
const RRClass&
-BasicRRset::getClass() const
-{
+BasicRRset::getClass() const {
return (impl_->rrclass_);
}
const RRType&
-BasicRRset::getType() const
-{
+BasicRRset::getType() const {
return (impl_->rrtype_);
}
const RRTTL&
-BasicRRset::getTTL() const
-{
+BasicRRset::getTTL() const {
return (impl_->ttl_);
}
void
-BasicRRset::setName(const Name& name)
-{
+BasicRRset::setName(const Name& name) {
impl_->name_ = name;
}
void
-BasicRRset::setTTL(const RRTTL& ttl)
-{
+BasicRRset::setTTL(const RRTTL& ttl) {
impl_->ttl_ = ttl;
}
string
-BasicRRset::toText() const
-{
+BasicRRset::toText() const {
return (AbstractRRset::toText());
}
unsigned int
-BasicRRset::toWire(OutputBuffer& buffer) const
-{
+BasicRRset::toWire(OutputBuffer& buffer) const {
return (AbstractRRset::toWire(buffer));
}
unsigned int
-BasicRRset::toWire(MessageRenderer& renderer) const
-{
+BasicRRset::toWire(MessageRenderer& renderer) const {
return (AbstractRRset::toWire(renderer));
}
@@ -256,8 +237,7 @@
}
RdataIteratorPtr
-BasicRRset::getRdataIterator() const
-{
+BasicRRset::getRdataIterator() const {
return (RdataIteratorPtr(new BasicRdataIterator(impl_->rdatalist_)));
}
}
Modified: branches/trac364/src/lib/dns/rrset.h
==============================================================================
--- branches/trac364/src/lib/dns/rrset.h (original)
+++ branches/trac364/src/lib/dns/rrset.h Wed Oct 27 13:42:53 2010
@@ -530,8 +530,8 @@
/// \param rrclass The RR class of the RRset.
/// \param rrtype The RR type of the RRset.
/// \param ttl The TTL of the RRset.
- explicit BasicRRset(const Name& name, const RRClass& rrclass,
- const RRType& rrtype, const RRTTL& ttl);
+ BasicRRset(const Name& name, const RRClass& rrclass,
+ const RRType& rrtype, const RRTTL& ttl);
/// \brief The destructor.
virtual ~BasicRRset();
//@}
@@ -668,7 +668,7 @@
/// QNAME/QTYPE/QCLASS as a single object.
class RRset : public BasicRRset {
public:
- explicit RRset(const Name& name, const RRClass& rrclass,
+ RRset(const Name& name, const RRClass& rrclass,
const RRType& rrtype, const RRTTL& ttl);
virtual ~RRset();
Modified: branches/trac364/src/lib/dns/rrsetlist.cc
==============================================================================
--- branches/trac364/src/lib/dns/rrsetlist.cc (original)
+++ branches/trac364/src/lib/dns/rrsetlist.cc Wed Oct 27 13:42:53 2010
@@ -41,8 +41,7 @@
}
void
-RRsetList::append(RRsetList& source)
-{
+RRsetList::append(RRsetList& source) {
BOOST_FOREACH(RRsetPtr rrset, source) {
addRRset(rrset);
}
Modified: branches/trac364/src/lib/dns/rrttl.cc
==============================================================================
--- branches/trac364/src/lib/dns/rrttl.cc (original)
+++ branches/trac364/src/lib/dns/rrttl.cc Wed Oct 27 13:42:53 2010
@@ -29,8 +29,7 @@
namespace isc {
namespace dns {
-RRTTL::RRTTL(const string& ttlstr)
-{
+RRTTL::RRTTL(const string& ttlstr) {
// Some systems (at least gcc-4.4) flow negative values over into
// unsigned integer, where older systems failed to parse. We want
// that failure here, so we extract into int64 and check the value
@@ -45,8 +44,7 @@
}
}
-RRTTL::RRTTL(InputBuffer& buffer)
-{
+RRTTL::RRTTL(InputBuffer& buffer) {
if (buffer.getLength() - buffer.getPosition() < sizeof(uint32_t)) {
isc_throw(IncompleteRRTTL, "incomplete wire-format TTL value");
}
@@ -54,28 +52,24 @@
}
const string
-RRTTL::toText() const
-{
+RRTTL::toText() const {
ostringstream oss;
oss << ttlval_;
return (oss.str());
}
void
-RRTTL::toWire(OutputBuffer& buffer) const
-{
+RRTTL::toWire(OutputBuffer& buffer) const {
buffer.writeUint32(ttlval_);
}
void
-RRTTL::toWire(MessageRenderer& renderer) const
-{
+RRTTL::toWire(MessageRenderer& renderer) const {
renderer.writeUint32(ttlval_);
}
ostream&
-operator<<(ostream& os, const RRTTL& rrttl)
-{
+operator<<(ostream& os, const RRTTL& rrttl) {
os << rrttl.toText();
return (os);
}
Modified: branches/trac364/src/lib/dns/rrtype-placeholder.h
==============================================================================
--- branches/trac364/src/lib/dns/rrtype-placeholder.h (original)
+++ branches/trac364/src/lib/dns/rrtype-placeholder.h Wed Oct 27 13:42:53 2010
@@ -276,22 +276,19 @@
// END_WELL_KNOWN_TYPE_DEFINITIONS
inline const RRType&
-RRType::IXFR()
-{
+RRType::IXFR() {
static RRType rrtype(RRTYPE_IXFR);
return (rrtype);
}
inline const RRType&
-RRType::AXFR()
-{
+RRType::AXFR() {
static RRType rrtype(RRTYPE_AXFR);
return (rrtype);
}
inline const RRType&
-RRType::ANY()
-{
+RRType::ANY() {
static RRType rrtype(RRTYPE_ANY);
return (rrtype);
}
Modified: branches/trac364/src/lib/dns/rrtype.cc
==============================================================================
--- branches/trac364/src/lib/dns/rrtype.cc (original)
+++ branches/trac364/src/lib/dns/rrtype.cc Wed Oct 27 13:42:53 2010
@@ -33,13 +33,11 @@
namespace isc {
namespace dns {
-RRType::RRType(const string& typestr)
-{
+RRType::RRType(const string& typestr) {
typecode_ = RRParamRegistry::getRegistry().textToTypeCode(typestr);
}
-RRType::RRType(InputBuffer& buffer)
-{
+RRType::RRType(InputBuffer& buffer) {
if (buffer.getLength() - buffer.getPosition() < sizeof(uint16_t)) {
isc_throw(IncompleteRRType, "incomplete wire-format RR type");
}
@@ -47,26 +45,22 @@
}
const string
-RRType::toText() const
-{
+RRType::toText() const {
return (RRParamRegistry::getRegistry().codeToTypeText(typecode_));
}
void
-RRType::toWire(OutputBuffer& buffer) const
-{
+RRType::toWire(OutputBuffer& buffer) const {
buffer.writeUint16(typecode_);
}
void
-RRType::toWire(MessageRenderer& renderer) const
-{
+RRType::toWire(MessageRenderer& renderer) const {
renderer.writeUint16(typecode_);
}
ostream&
-operator<<(ostream& os, const RRType& rrtype)
-{
+operator<<(ostream& os, const RRType& rrtype) {
os << rrtype.toText();
return (os);
}
Modified: branches/trac364/src/lib/dns/tests/Makefile.am
==============================================================================
--- branches/trac364/src/lib/dns/tests/Makefile.am (original)
+++ branches/trac364/src/lib/dns/tests/Makefile.am Wed Oct 27 13:42:53 2010
@@ -3,7 +3,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_SRCDIR=\"$(srcdir)/testdata\"
-AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(top_builddir)/src/lib/dns/tests/testdata\"
+AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/dns/tests/testdata\"
AM_CXXFLAGS = $(B10_CXXFLAGS)
if USE_STATIC_LINK
Modified: branches/trac364/src/lib/dns/tests/buffer_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/buffer_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/buffer_unittest.cc Wed Oct 27 13:42:53 2010
@@ -48,8 +48,7 @@
const uint8_t BufferTest::testdata[5] = {1, 2, 3, 4, 5};
-TEST_F(BufferTest, inputBufferRead)
-{
+TEST_F(BufferTest, inputBufferRead) {
EXPECT_EQ(5, ibuffer.getLength());
EXPECT_EQ(1, ibuffer.readUint8());
EXPECT_EQ(1, ibuffer.getPosition());
@@ -66,8 +65,7 @@
EXPECT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
}
-TEST_F(BufferTest, inputBufferException)
-{
+TEST_F(BufferTest, inputBufferException) {
EXPECT_THROW(ibuffer.setPosition(6), isc::dns::InvalidBufferPosition);
ibuffer.setPosition(sizeof(testdata));
@@ -84,8 +82,7 @@
isc::dns::InvalidBufferPosition);
}
-TEST_F(BufferTest, outputBufferExtend)
-{
+TEST_F(BufferTest, outputBufferExtend) {
EXPECT_EQ(0, obuffer.getCapacity());
EXPECT_EQ(0, obuffer.getLength());
obuffer.writeUint8(10);
@@ -93,8 +90,7 @@
EXPECT_EQ(1, obuffer.getLength());
}
-TEST_F(BufferTest, outputBufferWrite)
-{
+TEST_F(BufferTest, outputBufferWrite) {
const uint8_t* cp;
obuffer.writeUint8(1);
@@ -126,8 +122,7 @@
EXPECT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata)));
}
-TEST_F(BufferTest, outputBufferWriteat)
-{
+TEST_F(BufferTest, outputBufferWriteat) {
obuffer.writeUint32(data32);
expected_size += sizeof(data32);
@@ -153,8 +148,7 @@
isc::dns::InvalidBufferPosition);
}
-TEST_F(BufferTest, outputBufferSkip)
-{
+TEST_F(BufferTest, outputBufferSkip) {
obuffer.skip(4);
EXPECT_EQ(4, obuffer.getLength());
@@ -162,8 +156,7 @@
EXPECT_EQ(6, obuffer.getLength());
}
-TEST_F(BufferTest, outputBufferTrim)
-{
+TEST_F(BufferTest, outputBufferTrim) {
obuffer.writeData(testdata, sizeof(testdata));
EXPECT_EQ(5, obuffer.getLength());
@@ -176,8 +169,7 @@
EXPECT_THROW(obuffer.trim(3), OutOfRange);
}
-TEST_F(BufferTest, outputBufferReadat)
-{
+TEST_F(BufferTest, outputBufferReadat) {
obuffer.writeData(testdata, sizeof(testdata));
for (int i = 0; i < sizeof(testdata); i ++) {
EXPECT_EQ(testdata[i], obuffer[i]);
@@ -185,8 +177,7 @@
EXPECT_THROW(obuffer[sizeof(testdata)], isc::dns::InvalidBufferPosition);
}
-TEST_F(BufferTest, outputBufferClear)
-{
+TEST_F(BufferTest, outputBufferClear) {
obuffer.writeData(testdata, sizeof(testdata));
obuffer.clear();
EXPECT_EQ(0, obuffer.getLength());
Modified: branches/trac364/src/lib/dns/tests/name_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/name_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/name_unittest.cc Wed Oct 27 13:42:53 2010
@@ -84,8 +84,7 @@
}
Name
-NameTest::nameFactoryLowerCase()
-{
+NameTest::nameFactoryLowerCase() {
string lowercase_namestr;
lowercase_namestr.reserve(Name::MAX_WIRE);
@@ -124,8 +123,7 @@
buffer_expected.getData(), buffer_expected.getLength());
}
-TEST_F(NameTest, nonlocalObject)
-{
+TEST_F(NameTest, nonlocalObject) {
// A previous version of code relied on a non local static object for
// name construction, so a non local static Name object defined outside
// the name module might not be initialized correctly. This test detects
@@ -133,8 +131,7 @@
EXPECT_EQ("\\255.example.com.", downcased_global.toText());
}
-TEST_F(NameTest, fromText)
-{
+TEST_F(NameTest, fromText) {
vector<string> strnames;
strnames.push_back("www.example.com");
strnames.push_back("www.example.com."); // with a trailing dot
@@ -216,8 +213,7 @@
EXPECT_EQ(Name::MAX_LABELS, maxlabels.getLabelCount());
}
-TEST_F(NameTest, fromWire)
-{
+TEST_F(NameTest, fromWire) {
//
// test cases derived from BIND9 tests.
//
@@ -271,8 +267,7 @@
EXPECT_EQ(3, nameFactoryFromWire("name_fromWire1", 25).getLabelCount());
}
-TEST_F(NameTest, copyConstruct)
-{
+TEST_F(NameTest, copyConstruct) {
Name copy(example_name);
EXPECT_EQ(copy, example_name);
@@ -283,8 +278,7 @@
EXPECT_EQ(copy3, example_name);
}
-TEST_F(NameTest, assignment)
-{
+TEST_F(NameTest, assignment) {
Name copy(".");
copy = example_name;
EXPECT_EQ(copy, example_name);
@@ -301,8 +295,7 @@
EXPECT_EQ(copy, example_name);
}
-TEST_F(NameTest, toText)
-{
+TEST_F(NameTest, toText) {
// tests derived from BIND9
EXPECT_EQ("a.b.c.d", Name("a.b.c.d").toText(true));
EXPECT_EQ("a.\\\\[[.c.d", Name("a.\\\\[\\[.c.d").toText(true));
@@ -349,8 +342,7 @@
nameFactoryFromWire("name_fromWire14", 0).toText());
}
-TEST_F(NameTest, toWireBuffer)
-{
+TEST_F(NameTest, toWireBuffer) {
vector<unsigned char> data;
OutputBuffer buffer(0);
@@ -364,8 +356,7 @@
// We test various corner cases in Renderer tests, but add this test case
// to fill the code coverage gap.
//
-TEST_F(NameTest, toWireRenderer)
-{
+TEST_F(NameTest, toWireRenderer) {
vector<unsigned char> data;
OutputBuffer buffer(0);
MessageRenderer renderer(buffer);
Modified: branches/trac364/src/lib/dns/tests/question_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/question_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/question_unittest.cc Wed Oct 27 13:42:53 2010
@@ -56,8 +56,7 @@
};
Question
-questionFromWire(const char* datafile, size_t position = 0)
-{
+questionFromWire(const char* datafile, size_t position = 0) {
vector<unsigned char> data;
UnitTestUtil::readWireData(datafile, data);
@@ -67,8 +66,7 @@
return (Question(buffer));
}
-TEST_F(QuestionTest, fromWire)
-{
+TEST_F(QuestionTest, fromWire) {
Question q = questionFromWire("question_fromWire");
EXPECT_EQ(example_name1, q.getName());
@@ -88,14 +86,12 @@
EXPECT_THROW(questionFromWire("question_fromWire", 36), IncompleteRRClass);
}
-TEST_F(QuestionTest, toText)
-{
+TEST_F(QuestionTest, toText) {
EXPECT_EQ("foo.example.com. IN NS\n", test_question1.toText());
EXPECT_EQ("bar.example.com. CH A\n", test_question2.toText());
}
-TEST_F(QuestionTest, toWireBuffer)
-{
+TEST_F(QuestionTest, toWireBuffer) {
test_question1.toWire(obuffer);
test_question2.toWire(obuffer);
UnitTestUtil::readWireData("question_toWire1", wiredata);
@@ -103,8 +99,7 @@
obuffer.getLength(), &wiredata[0], wiredata.size());
}
-TEST_F(QuestionTest, toWireRenderer)
-{
+TEST_F(QuestionTest, toWireRenderer) {
test_question1.toWire(renderer);
test_question2.toWire(renderer);
UnitTestUtil::readWireData("question_toWire2", wiredata);
@@ -113,15 +108,13 @@
}
// test operator<<. We simply confirm it appends the result of toText().
-TEST_F(QuestionTest, LeftShiftOperator)
-{
+TEST_F(QuestionTest, LeftShiftOperator) {
ostringstream oss;
oss << test_question1;
EXPECT_EQ(test_question1.toText(), oss.str());
}
-TEST_F(QuestionTest, comparison)
-{
+TEST_F(QuestionTest, comparison) {
const Name a("a"), b("b");
const RRClass in(RRClass::IN()), ch(RRClass::CH());
const RRType ns(RRType::NS()), aaaa(RRType::AAAA());
Modified: branches/trac364/src/lib/dns/tests/rdata_cname_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rdata_cname_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rdata_cname_unittest.cc Wed Oct 27 13:42:53 2010
@@ -50,8 +50,7 @@
// compressed.
0x03, 0x63, 0x6e, 0x32, 0xc0, 0x03 };
-TEST_F(Rdata_CNAME_Test, createFromText)
-{
+TEST_F(Rdata_CNAME_Test, createFromText) {
EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com.")));
@@ -64,8 +63,7 @@
"cn.example.com")));
}
-TEST_F(Rdata_CNAME_Test, createFromWire)
-{
+TEST_F(Rdata_CNAME_Test, createFromWire) {
EXPECT_EQ(0, rdata_cname.compare(
*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"rdata_cname_fromWire")));
@@ -90,16 +88,14 @@
InvalidRdataLength);
}
-TEST_F(Rdata_CNAME_Test, toWireBuffer)
-{
+TEST_F(Rdata_CNAME_Test, toWireBuffer) {
rdata_cname.toWire(obuffer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
wiredata_cname, sizeof(wiredata_cname));
}
-TEST_F(Rdata_CNAME_Test, toWireRenderer)
-{
+TEST_F(Rdata_CNAME_Test, toWireRenderer) {
rdata_cname.toWire(renderer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
@@ -110,13 +106,11 @@
wiredata_cname2, sizeof(wiredata_cname2));
}
-TEST_F(Rdata_CNAME_Test, toText)
-{
+TEST_F(Rdata_CNAME_Test, toText) {
EXPECT_EQ("cn.example.com.", rdata_cname.toText());
}
-TEST_F(Rdata_CNAME_Test, getCname)
-{
+TEST_F(Rdata_CNAME_Test, getCname) {
EXPECT_EQ(Name("cn.example.com."), rdata_cname.getCname());
}
}
Modified: branches/trac364/src/lib/dns/tests/rdata_dname_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rdata_dname_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rdata_dname_unittest.cc Wed Oct 27 13:42:53 2010
@@ -50,8 +50,7 @@
// compressed.
0x03, 0x64, 0x6e, 0x32, 0xc0, 0x03 };
-TEST_F(Rdata_DNAME_Test, createFromText)
-{
+TEST_F(Rdata_DNAME_Test, createFromText) {
EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("dn.example.com")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("dn.example.com.")));
@@ -64,8 +63,7 @@
"dn.example.com")));
}
-TEST_F(Rdata_DNAME_Test, createFromWire)
-{
+TEST_F(Rdata_DNAME_Test, createFromWire) {
EXPECT_EQ(0, rdata_dname.compare(
*rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"rdata_dname_fromWire")));
@@ -90,16 +88,14 @@
InvalidRdataLength);
}
-TEST_F(Rdata_DNAME_Test, toWireBuffer)
-{
+TEST_F(Rdata_DNAME_Test, toWireBuffer) {
rdata_dname.toWire(obuffer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
wiredata_dname, sizeof(wiredata_dname));
}
-TEST_F(Rdata_DNAME_Test, toWireRenderer)
-{
+TEST_F(Rdata_DNAME_Test, toWireRenderer) {
rdata_dname.toWire(renderer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
@@ -110,13 +106,11 @@
wiredata_dname2, sizeof(wiredata_dname2));
}
-TEST_F(Rdata_DNAME_Test, toText)
-{
+TEST_F(Rdata_DNAME_Test, toText) {
EXPECT_EQ("dn.example.com.", rdata_dname.toText());
}
-TEST_F(Rdata_DNAME_Test, getDname)
-{
+TEST_F(Rdata_DNAME_Test, getDname) {
EXPECT_EQ(Name("dn.example.com."), rdata_dname.getDname());
}
}
Modified: branches/trac364/src/lib/dns/tests/rdata_ns_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rdata_ns_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rdata_ns_unittest.cc Wed Oct 27 13:42:53 2010
@@ -50,8 +50,7 @@
// compressed.
0x03, 0x6e, 0x73, 0x32, 0xc0, 0x03 };
-TEST_F(Rdata_NS_Test, createFromText)
-{
+TEST_F(Rdata_NS_Test, createFromText) {
EXPECT_EQ(0, rdata_ns.compare(generic::NS("ns.example.com")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_ns.compare(generic::NS("ns.example.com.")));
@@ -63,8 +62,7 @@
"ns.example.com")));
}
-TEST_F(Rdata_NS_Test, createFromWire)
-{
+TEST_F(Rdata_NS_Test, createFromWire) {
EXPECT_EQ(0, rdata_ns.compare(
*rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"rdata_ns_fromWire")));
@@ -89,16 +87,14 @@
InvalidRdataLength);
}
-TEST_F(Rdata_NS_Test, toWireBuffer)
-{
+TEST_F(Rdata_NS_Test, toWireBuffer) {
rdata_ns.toWire(obuffer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
wiredata_ns, sizeof(wiredata_ns));
}
-TEST_F(Rdata_NS_Test, toWireRenderer)
-{
+TEST_F(Rdata_NS_Test, toWireRenderer) {
rdata_ns.toWire(renderer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
@@ -109,21 +105,18 @@
wiredata_ns2, sizeof(wiredata_ns2));
}
-TEST_F(Rdata_NS_Test, toText)
-{
+TEST_F(Rdata_NS_Test, toText) {
EXPECT_EQ("ns.example.com.", rdata_ns.toText());
}
-TEST_F(Rdata_NS_Test, compare)
-{
+TEST_F(Rdata_NS_Test, compare) {
generic::NS small("a.example");
generic::NS large("example");
EXPECT_EQ(true, Name("a.example") > Name("example"));
EXPECT_GT(0, small.compare(large));
}
-TEST_F(Rdata_NS_Test, getNSName)
-{
+TEST_F(Rdata_NS_Test, getNSName) {
EXPECT_EQ(Name("ns.example.com"), rdata_ns.getNSName());
}
}
Modified: branches/trac364/src/lib/dns/tests/rdata_opt_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rdata_opt_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rdata_opt_unittest.cc Wed Oct 27 13:42:53 2010
@@ -38,14 +38,12 @@
const generic::OPT rdata_opt;
-TEST_F(Rdata_OPT_Test, createFromText)
-{
+TEST_F(Rdata_OPT_Test, createFromText) {
// OPT RR cannot be created from text.
EXPECT_THROW(generic::OPT("this does not matter"), InvalidRdataText);
}
-TEST_F(Rdata_OPT_Test, createFromWire)
-{
+TEST_F(Rdata_OPT_Test, createFromWire) {
// Valid cases: in the simple implementation with no supported options,
// we can only check these don't throw.
EXPECT_NO_THROW(rdataFactoryFromFile(RRType::OPT(), RRClass("CLASS4096"),
@@ -59,25 +57,21 @@
InvalidRdataLength);
}
-TEST_F(Rdata_OPT_Test, toWireBuffer)
-{
+TEST_F(Rdata_OPT_Test, toWireBuffer) {
rdata_opt.toWire(obuffer);
EXPECT_EQ(0, obuffer.getLength());
}
-TEST_F(Rdata_OPT_Test, toWireRenderer)
-{
+TEST_F(Rdata_OPT_Test, toWireRenderer) {
rdata_opt.toWire(renderer);
EXPECT_EQ(0, obuffer.getLength());
}
-TEST_F(Rdata_OPT_Test, toText)
-{
+TEST_F(Rdata_OPT_Test, toText) {
EXPECT_EQ("", rdata_opt.toText());
}
-TEST_F(Rdata_OPT_Test, compare)
-{
+TEST_F(Rdata_OPT_Test, compare) {
// This simple implementation always returns "true"
EXPECT_EQ(0, rdata_opt.compare(
*rdataFactoryFromFile(RRType::OPT(), RRClass::CH(),
Modified: branches/trac364/src/lib/dns/tests/rdata_ptr_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rdata_ptr_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rdata_ptr_unittest.cc Wed Oct 27 13:42:53 2010
@@ -54,8 +54,7 @@
// compressed.
0x03, 0x6e, 0x73, 0x32, 0xc0, 0x03 };
-TEST_F(Rdata_PTR_Test, createFromText)
-{
+TEST_F(Rdata_PTR_Test, createFromText) {
EXPECT_EQ(0, rdata_ptr.compare(generic::PTR("ns.example.com")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_ptr.compare(generic::PTR("ns.example.com.")));
@@ -67,8 +66,7 @@
"ns.example.com")));
}
-TEST_F(Rdata_PTR_Test, createFromWire)
-{
+TEST_F(Rdata_PTR_Test, createFromWire) {
EXPECT_EQ(0, rdata_ptr.compare(
*rdataFactoryFromFile(RRType("PTR"), RRClass("IN"),
"rdata_ns_fromWire")));
@@ -93,16 +91,14 @@
InvalidRdataLength);
}
-TEST_F(Rdata_PTR_Test, toWireBuffer)
-{
+TEST_F(Rdata_PTR_Test, toWireBuffer) {
rdata_ptr.toWire(obuffer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
wiredata_ptr, sizeof(wiredata_ptr));
}
-TEST_F(Rdata_PTR_Test, toWireRenderer)
-{
+TEST_F(Rdata_PTR_Test, toWireRenderer) {
rdata_ptr.toWire(renderer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
@@ -113,21 +109,18 @@
wiredata_ptr2, sizeof(wiredata_ptr2));
}
-TEST_F(Rdata_PTR_Test, toText)
-{
+TEST_F(Rdata_PTR_Test, toText) {
EXPECT_EQ("ns.example.com.", rdata_ptr.toText());
}
-TEST_F(Rdata_PTR_Test, compare)
-{
+TEST_F(Rdata_PTR_Test, compare) {
generic::PTR small("a.example");
generic::PTR large("example");
EXPECT_EQ(true, Name("a.example") > Name("example"));
EXPECT_GT(0, small.compare(large));
}
-TEST_F(Rdata_PTR_Test, getPTRName)
-{
+TEST_F(Rdata_PTR_Test, getPTRName) {
EXPECT_EQ(Name("ns.example.com"), rdata_ptr.getPTRName());
}
}
Modified: branches/trac364/src/lib/dns/tests/rdata_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rdata_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rdata_unittest.cc Wed Oct 27 13:42:53 2010
@@ -68,8 +68,7 @@
};
string
-Rdata_Unknown_Test::getLongestRdataTxt()
-{
+Rdata_Unknown_Test::getLongestRdataTxt() {
ostringstream oss;
oss << "\\# " << MAX_RDLENGTH << " ";
@@ -83,8 +82,7 @@
}
void
-Rdata_Unknown_Test::getLongestRdataWire(vector<uint8_t>& v)
-{
+Rdata_Unknown_Test::getLongestRdataWire(vector<uint8_t>& v) {
unsigned char ch = 0;
for (int i = 0; i < MAX_RDLENGTH; ++i, ++ch) {
v.push_back(ch);
@@ -102,8 +100,7 @@
// renumber it.
const RRType unknown_rrtype = RRType(65000);
-TEST_F(Rdata_Unknown_Test, createFromText)
-{
+TEST_F(Rdata_Unknown_Test, createFromText) {
// valid construction. This also tests a normal case of "FromWire".
EXPECT_EQ(0, generic::Generic("\\# 4 a1b2c30d").compare(
*rdataFactoryFromFile(unknown_rrtype, RRClass::IN(),
@@ -148,8 +145,7 @@
EXPECT_THROW(generic::Generic("\\# 1ff"), InvalidRdataText);
}
-TEST_F(Rdata_Unknown_Test, createFromWire)
-{
+TEST_F(Rdata_Unknown_Test, createFromWire) {
// normal case (including 0-length data) is covered in createFromText.
// buffer too short. the error should be detected in buffer read
@@ -167,8 +163,7 @@
// The following 3 sets of tests check the behavior of createRdata() variants
// with the "unknown" RRtype. The result should be RRclass independent.
-TEST_F(Rdata_Unknown_Test, createRdataFromString)
-{
+TEST_F(Rdata_Unknown_Test, createRdataFromString) {
EXPECT_EQ(0, rdata_unknown.compare(
*createRdata(unknown_rrtype, RRClass::IN(),
rdata_unknowntxt)));
@@ -180,8 +175,7 @@
rdata_unknowntxt)));
}
-TEST_F(Rdata_Unknown_Test, createRdataFromWire)
-{
+TEST_F(Rdata_Unknown_Test, createRdataFromWire) {
InputBuffer ibuffer(wiredata_unknown, sizeof(wiredata_unknown));
EXPECT_EQ(0, rdata_unknown.compare(
*createRdata(unknown_rrtype, RRClass::IN(),
@@ -198,8 +192,7 @@
ibuffer3, sizeof(wiredata_unknown))));
}
-TEST_F(Rdata_Unknown_Test, createRdataByCopy)
-{
+TEST_F(Rdata_Unknown_Test, createRdataByCopy) {
EXPECT_EQ(0, rdata_unknown.compare(
*createRdata(unknown_rrtype, RRClass::IN(), rdata_unknown)));
EXPECT_EQ(0, rdata_unknown.compare(
@@ -209,8 +202,7 @@
rdata_unknown)));
}
-TEST_F(Rdata_Unknown_Test, copyConstruct)
-{
+TEST_F(Rdata_Unknown_Test, copyConstruct) {
generic::Generic copy(rdata_unknown);
EXPECT_EQ(0, copy.compare(rdata_unknown));
@@ -221,8 +213,7 @@
EXPECT_EQ(0, copy3.compare(rdata_unknown));
}
-TEST_F(Rdata_Unknown_Test, assignment)
-{
+TEST_F(Rdata_Unknown_Test, assignment) {
generic::Generic copy("\\# 1 10");
copy = rdata_unknown;
EXPECT_EQ(0, copy.compare(rdata_unknown));
@@ -239,31 +230,27 @@
EXPECT_EQ(0, copy.compare(rdata_unknown));
}
-TEST_F(Rdata_Unknown_Test, toText)
-{
+TEST_F(Rdata_Unknown_Test, toText) {
EXPECT_EQ(rdata_unknowntxt, rdata_unknown.toText());
EXPECT_EQ(getLongestRdataTxt(),
generic::Generic(getLongestRdataTxt()).toText());
}
-TEST_F(Rdata_Unknown_Test, toWireBuffer)
-{
+TEST_F(Rdata_Unknown_Test, toWireBuffer) {
rdata_unknown.toWire(obuffer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
wiredata_unknown, sizeof(wiredata_unknown));
}
-TEST_F(Rdata_Unknown_Test, toWireRenderer)
-{
+TEST_F(Rdata_Unknown_Test, toWireRenderer) {
rdata_unknown.toWire(renderer);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
obuffer.getData(), obuffer.getLength(),
wiredata_unknown, sizeof(wiredata_unknown));
}
-TEST_F(Rdata_Unknown_Test, compare)
-{
+TEST_F(Rdata_Unknown_Test, compare) {
// comparison as left-justified unsigned octet sequences:
EXPECT_EQ(0, rdata_unknown.compare(rdata_unknown));
@@ -281,8 +268,7 @@
EXPECT_LT(0, rdata_unknown.compare(rdata_unknown_short));
}
-TEST_F(Rdata_Unknown_Test, LeftShiftOperator)
-{
+TEST_F(Rdata_Unknown_Test, LeftShiftOperator) {
ostringstream oss;
oss << rdata_unknown;
EXPECT_EQ(rdata_unknown.toText(), oss.str());
@@ -291,8 +277,7 @@
//
// Tests for global utility functions
//
-TEST_F(RdataTest, compareNames)
-{
+TEST_F(RdataTest, compareNames) {
Name small("a.example");
Name large("example");
Modified: branches/trac364/src/lib/dns/tests/rrclass_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rrclass_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rrclass_unittest.cc Wed Oct 27 13:42:53 2010
@@ -51,8 +51,7 @@
0x00, 0x80, 0x00, 0xff, 0xff };
RRClass
-RRClassTest::rrclassFactoryFromWire(const char* datafile)
-{
+RRClassTest::rrclassFactoryFromWire(const char* datafile) {
std::vector<unsigned char> data;
UnitTestUtil::readWireData(datafile, data);
@@ -61,8 +60,7 @@
return (RRClass(buffer));
}
-TEST_F(RRClassTest, fromText)
-{
+TEST_F(RRClassTest, fromText) {
EXPECT_EQ("IN", RRClass("IN").toText());
EXPECT_EQ("CH", RRClass("CH").toText());
@@ -81,29 +79,25 @@
EXPECT_THROW(RRClass("CLASS65000 "), InvalidRRClass);
}
-TEST_F(RRClassTest, fromWire)
-{
+TEST_F(RRClassTest, fromWire) {
EXPECT_EQ(0x1234,
rrclassFactoryFromWire("rrcode16_fromWire1").getCode());
EXPECT_THROW(rrclassFactoryFromWire("rrcode16_fromWire2"),
IncompleteRRClass);
}
-TEST_F(RRClassTest, caseConstruct)
-{
+TEST_F(RRClassTest, caseConstruct) {
EXPECT_EQ("IN", RRClass("in").toText());
EXPECT_EQ("CH", RRClass("ch").toText());
EXPECT_EQ("CLASS65535", RRClass("class65535").toText());
}
-TEST_F(RRClassTest, toText)
-{
+TEST_F(RRClassTest, toText) {
EXPECT_EQ("IN", RRClass(1).toText());
EXPECT_EQ("CLASS65000", RRClass(65000).toText());
}
-TEST_F(RRClassTest, toWireBuffer)
-{
+TEST_F(RRClassTest, toWireBuffer) {
rrclass_1.toWire(obuffer);
rrclass_0x80.toWire(obuffer);
rrclass_0x800.toWire(obuffer);
@@ -115,8 +109,7 @@
wiredata, sizeof(wiredata));
}
-TEST_F(RRClassTest, toWireRenderer)
-{
+TEST_F(RRClassTest, toWireRenderer) {
rrclass_1.toWire(renderer);
rrclass_0x80.toWire(renderer);
rrclass_0x800.toWire(renderer);
@@ -128,14 +121,12 @@
wiredata, sizeof(wiredata));
}
-TEST_F(RRClassTest, wellKnownClasss)
-{
+TEST_F(RRClassTest, wellKnownClasss) {
EXPECT_EQ(1, RRClass::IN().getCode());
EXPECT_EQ("IN", RRClass::IN().toText());
}
-TEST_F(RRClassTest, compare)
-{
+TEST_F(RRClassTest, compare) {
EXPECT_TRUE(RRClass(1) == RRClass("IN"));
EXPECT_TRUE(RRClass(1).equals(RRClass("IN")));
EXPECT_TRUE(RRClass(0).nequals(RRClass("IN")));
@@ -145,8 +136,7 @@
}
// test operator<<. We simply confirm it appends the result of toText().
-TEST_F(RRClassTest, LeftShiftOperator)
-{
+TEST_F(RRClassTest, LeftShiftOperator) {
ostringstream oss;
oss << RRClass::IN();
EXPECT_EQ(RRClass::IN().toText(), oss.str());
Modified: branches/trac364/src/lib/dns/tests/rrparamregistry_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rrparamregistry_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rrparamregistry_unittest.cc Wed Oct 27 13:42:53 2010
@@ -70,8 +70,7 @@
const string RRParamRegistryTest::test_class_str("TESTCLASS");
const string RRParamRegistryTest::test_type_str("TESTTYPE");
-TEST_F(RRParamRegistryTest, addRemove)
-{
+TEST_F(RRParamRegistryTest, addRemove) {
RRParamRegistry::getRegistry().addType(test_type_str, test_type_code);
RRParamRegistry::getRegistry().addClass(test_class_str, test_class_code);
EXPECT_EQ(65533, RRClass("TESTCLASS").getCode());
@@ -90,8 +89,7 @@
EXPECT_FALSE(RRParamRegistry::getRegistry().removeClass(test_class_code));
}
-TEST_F(RRParamRegistryTest, addError)
-{
+TEST_F(RRParamRegistryTest, addError) {
// An attempt to override a pre-registered class should fail with an
// exception, and the pre-registered one should remain in the registry.
EXPECT_THROW(RRParamRegistry::getRegistry().addClass(test_class_str, 1),
@@ -114,8 +112,7 @@
{ return (RdataPtr(new in::A(dynamic_cast<const in::A&>(source)))); }
};
-TEST_F(RRParamRegistryTest, addRemoveFactory)
-{
+TEST_F(RRParamRegistryTest, addRemoveFactory) {
// By default, the test type/code pair should be considered "unknown",
// so the following should trigger an exception.
EXPECT_THROW(createRdata(RRType(test_type_code), RRClass(test_class_code),
Modified: branches/trac364/src/lib/dns/tests/rrset_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rrset_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rrset_unittest.cc Wed Oct 27 13:42:53 2010
@@ -72,57 +72,49 @@
static const int MAX_RDATA_COUNT = 100;
};
-TEST_F(RRsetTest, getRdataCount)
-{
+TEST_F(RRsetTest, getRdataCount) {
for (int i = 0; i < MAX_RDATA_COUNT; ++i) {
EXPECT_EQ(i, rrset_a_empty.getRdataCount());
rrset_a_empty.addRdata(in::A("192.0.2.1"));
}
}
-TEST_F(RRsetTest, getName)
-{
+TEST_F(RRsetTest, getName) {
EXPECT_EQ(test_name, rrset_a.getName());
EXPECT_EQ(test_domain, rrset_ns.getName());
}
-TEST_F(RRsetTest, getClass)
-{
+TEST_F(RRsetTest, getClass) {
EXPECT_EQ(RRClass("IN"), rrset_a.getClass());
EXPECT_EQ(RRClass("CH"), rrset_ch_txt.getClass());
}
-TEST_F(RRsetTest, getType)
-{
+TEST_F(RRsetTest, getType) {
EXPECT_EQ(RRType("A"), rrset_a.getType());
EXPECT_EQ(RRType("NS"), rrset_ns.getType());
EXPECT_EQ(RRType("TXT"), rrset_ch_txt.getType());
}
-TEST_F(RRsetTest, getTTL)
-{
+TEST_F(RRsetTest, getTTL) {
EXPECT_EQ(RRTTL(3600), rrset_a.getTTL());
EXPECT_EQ(RRTTL(86400), rrset_ns.getTTL());
EXPECT_EQ(RRTTL(0), rrset_ch_txt.getTTL());
}
-TEST_F(RRsetTest, setTTL)
-{
+TEST_F(RRsetTest, setTTL) {
rrset_a.setTTL(RRTTL(86400));
EXPECT_EQ(RRTTL(86400), rrset_a.getTTL());
rrset_a.setTTL(RRTTL(0));
EXPECT_EQ(RRTTL(0), rrset_a.getTTL());
}
-TEST_F(RRsetTest, setName)
-{
+TEST_F(RRsetTest, setName) {
rrset_a.setName(test_nsname);
EXPECT_EQ(test_nsname, rrset_a.getName());
}
void
-addRdataTestCommon(const RRset& rrset)
-{
+addRdataTestCommon(const RRset& rrset) {
EXPECT_EQ(2, rrset.getRdataCount());
RdataIteratorPtr it = rrset.getRdataIterator();
@@ -136,8 +128,7 @@
EXPECT_TRUE(it->isLast());
}
-TEST_F(RRsetTest, addRdata)
-{
+TEST_F(RRsetTest, addRdata) {
addRdataTestCommon(rrset_a);
// Reference version of addRdata() doesn't allow to add a different
@@ -145,8 +136,7 @@
EXPECT_THROW(rrset_a.addRdata(generic::NS(test_nsname)), std::bad_cast);
}
-TEST_F(RRsetTest, addRdataPtr)
-{
+TEST_F(RRsetTest, addRdataPtr) {
rrset_a_empty.addRdata(createRdata(rrset_a_empty.getType(),
rrset_a_empty.getClass(),
"192.0.2.1"));
@@ -163,8 +153,7 @@
EXPECT_EQ(3, rrset_a_empty.getRdataCount());
}
-TEST_F(RRsetTest, iterator)
-{
+TEST_F(RRsetTest, iterator) {
// Iterator for an empty RRset.
RdataIteratorPtr it = rrset_a_empty.getRdataIterator();
it->first();
@@ -187,8 +176,7 @@
}
}
-TEST_F(RRsetTest, toText)
-{
+TEST_F(RRsetTest, toText) {
EXPECT_EQ("test.example.com. 3600 IN A 192.0.2.1\n"
"test.example.com. 3600 IN A 192.0.2.2\n",
rrset_a.toText());
@@ -197,8 +185,7 @@
EXPECT_THROW(rrset_a_empty.toText(), EmptyRRset);
}
-TEST_F(RRsetTest, toWireBuffer)
-{
+TEST_F(RRsetTest, toWireBuffer) {
rrset_a.toWire(buffer);
UnitTestUtil::readWireData("rrset_toWire1", wiredata);
@@ -210,8 +197,7 @@
EXPECT_THROW(rrset_a_empty.toWire(buffer), EmptyRRset);
}
-TEST_F(RRsetTest, toWireRenderer)
-{
+TEST_F(RRsetTest, toWireRenderer) {
rrset_ns.addRdata(generic::NS(test_nsname));
rrset_a.toWire(renderer);
@@ -227,8 +213,7 @@
}
// test operator<<. We simply confirm it appends the result of toText().
-TEST_F(RRsetTest, LeftShiftOperator)
-{
+TEST_F(RRsetTest, LeftShiftOperator) {
ostringstream oss;
oss << rrset_a;
EXPECT_EQ(rrset_a.toText(), oss.str());
Modified: branches/trac364/src/lib/dns/tests/rrttl_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rrttl_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rrttl_unittest.cc Wed Oct 27 13:42:53 2010
@@ -57,8 +57,7 @@
0xff, 0xff, 0xff, 0xff };
RRTTL
-RRTTLTest::rrttlFactoryFromWire(const char* datafile)
-{
+RRTTLTest::rrttlFactoryFromWire(const char* datafile) {
std::vector<unsigned char> data;
UnitTestUtil::readWireData(datafile, data);
@@ -67,8 +66,7 @@
return (RRTTL(buffer));
}
-TEST_F(RRTTLTest, fromText)
-{
+TEST_F(RRTTLTest, fromText) {
EXPECT_EQ(0, ttl_0.getValue());
EXPECT_EQ(3600, ttl_1h.getValue());
EXPECT_EQ(86400, ttl_1d.getValue());
@@ -82,16 +80,14 @@
EXPECT_THROW(RRTTL("4294967296"), InvalidRRTTL); // must be 32-bit
}
-TEST_F(RRTTLTest, fromWire)
-{
+TEST_F(RRTTLTest, fromWire) {
EXPECT_EQ(0x12345678,
rrttlFactoryFromWire("rrcode32_fromWire1").getValue());
EXPECT_THROW(rrttlFactoryFromWire("rrcode32_fromWire2"),
IncompleteRRTTL);
}
-TEST_F(RRTTLTest, toText)
-{
+TEST_F(RRTTLTest, toText) {
EXPECT_EQ("0", ttl_0.toText());
EXPECT_EQ("3600", ttl_1h.toText());
EXPECT_EQ("86400", ttl_1d.toText());
@@ -99,8 +95,7 @@
EXPECT_EQ("4294967295", ttl_max.toText());
}
-TEST_F(RRTTLTest, toWireBuffer)
-{
+TEST_F(RRTTLTest, toWireBuffer) {
ttl_0.toWire(obuffer);
ttl_1h.toWire(obuffer);
ttl_1d.toWire(obuffer);
@@ -112,8 +107,7 @@
wiredata, sizeof(wiredata));
}
-TEST_F(RRTTLTest, toWireRenderer)
-{
+TEST_F(RRTTLTest, toWireRenderer) {
ttl_0.toWire(renderer);
ttl_1h.toWire(renderer);
ttl_1d.toWire(renderer);
@@ -125,8 +119,7 @@
wiredata, sizeof(wiredata));
}
-TEST_F(RRTTLTest, equal)
-{
+TEST_F(RRTTLTest, equal) {
EXPECT_TRUE(RRTTL("3600") == ttl_1h);
EXPECT_TRUE(RRTTL("86400").equals(ttl_1d));
@@ -139,8 +132,7 @@
// The test logic is simple, and all tests are just straightforward variations
// of the first one.
//
-TEST_F(RRTTLTest, leq)
-{
+TEST_F(RRTTLTest, leq) {
// small <= large is true
EXPECT_TRUE(ttl_small.leq(ttl_large));
EXPECT_TRUE(ttl_small <= ttl_large);
@@ -154,8 +146,7 @@
EXPECT_FALSE(ttl_large <= ttl_small);
}
-TEST_F(RRTTLTest, geq)
-{
+TEST_F(RRTTLTest, geq) {
EXPECT_TRUE(ttl_large.geq(ttl_small));
EXPECT_TRUE(ttl_large >= ttl_small);
@@ -166,8 +157,7 @@
EXPECT_FALSE(ttl_small >= ttl_large);
}
-TEST_F(RRTTLTest, lthan)
-{
+TEST_F(RRTTLTest, lthan) {
EXPECT_TRUE(ttl_small.lthan(ttl_large));
EXPECT_TRUE(ttl_small < ttl_large);
@@ -178,8 +168,7 @@
EXPECT_FALSE(ttl_large < ttl_small);
}
-TEST_F(RRTTLTest, gthan)
-{
+TEST_F(RRTTLTest, gthan) {
EXPECT_TRUE(ttl_large.gthan(ttl_small));
EXPECT_TRUE(ttl_large > ttl_small);
@@ -191,8 +180,7 @@
}
// test operator<<. We simply confirm it appends the result of toText().
-TEST_F(RRTTLTest, LeftShiftOperator)
-{
+TEST_F(RRTTLTest, LeftShiftOperator) {
ostringstream oss;
oss << ttl_1h;
EXPECT_EQ(ttl_1h.toText(), oss.str());
Modified: branches/trac364/src/lib/dns/tests/rrtype_unittest.cc
==============================================================================
--- branches/trac364/src/lib/dns/tests/rrtype_unittest.cc (original)
+++ branches/trac364/src/lib/dns/tests/rrtype_unittest.cc Wed Oct 27 13:42:53 2010
@@ -51,8 +51,7 @@
0x00, 0x80, 0x00, 0xff, 0xff };
RRType
-RRTypeTest::rrtypeFactoryFromWire(const char* datafile)
-{
+RRTypeTest::rrtypeFactoryFromWire(const char* datafile) {
std::vector<unsigned char> data;
UnitTestUtil::readWireData(datafile, data);
@@ -61,8 +60,7 @@
return (RRType(buffer));
}
-TEST_F(RRTypeTest, fromText)
-{
+TEST_F(RRTypeTest, fromText) {
EXPECT_EQ("A", RRType("A").toText());
EXPECT_EQ("NS", RRType("NS").toText());
@@ -85,29 +83,25 @@
EXPECT_THROW(RRType("TYPE65000 "), InvalidRRType);
}
-TEST_F(RRTypeTest, fromWire)
-{
+TEST_F(RRTypeTest, fromWire) {
EXPECT_EQ(0x1234,
rrtypeFactoryFromWire("rrcode16_fromWire1").getCode());
EXPECT_THROW(rrtypeFactoryFromWire("rrcode16_fromWire2"), IncompleteRRType);
}
// from string, lower case
-TEST_F(RRTypeTest, caseConstruct)
-{
+TEST_F(RRTypeTest, caseConstruct) {
EXPECT_EQ("A", RRType("a").toText());
EXPECT_EQ("NS", RRType("ns").toText());
EXPECT_EQ("TYPE65535", RRType("type65535").toText());
}
-TEST_F(RRTypeTest, toText)
-{
+TEST_F(RRTypeTest, toText) {
EXPECT_EQ("A", RRType(1).toText());
EXPECT_EQ("TYPE65000", RRType(65000).toText());
}
-TEST_F(RRTypeTest, toWireBuffer)
-{
+TEST_F(RRTypeTest, toWireBuffer) {
rrtype_1.toWire(obuffer);
rrtype_0x80.toWire(obuffer);
rrtype_0x800.toWire(obuffer);
@@ -119,8 +113,7 @@
wiredata, sizeof(wiredata));
}
-TEST_F(RRTypeTest, toWireRenderer)
-{
+TEST_F(RRTypeTest, toWireRenderer) {
rrtype_1.toWire(renderer);
rrtype_0x80.toWire(renderer);
rrtype_0x800.toWire(renderer);
@@ -132,14 +125,12 @@
wiredata, sizeof(wiredata));
}
-TEST_F(RRTypeTest, wellKnownTypes)
-{
+TEST_F(RRTypeTest, wellKnownTypes) {
EXPECT_EQ(1, RRType::A().getCode());
EXPECT_EQ("A", RRType::A().toText());
}
-TEST_F(RRTypeTest, compare)
-{
+TEST_F(RRTypeTest, compare) {
EXPECT_TRUE(RRType(1) == RRType("A"));
EXPECT_TRUE(RRType(1).equals(RRType("A")));
EXPECT_TRUE(RRType(0) != RRType("A"));
@@ -150,8 +141,7 @@
}
// test operator<<. We simply confirm it appends the result of toText().
-TEST_F(RRTypeTest, LeftShiftOperator)
-{
+TEST_F(RRTypeTest, LeftShiftOperator) {
ostringstream oss;
oss << RRType::A();
EXPECT_EQ(RRType::A().toText(), oss.str());
Modified: branches/trac364/src/lib/dns/util/sha1.cc
==============================================================================
--- branches/trac364/src/lib/dns/util/sha1.cc (original)
+++ branches/trac364/src/lib/dns/util/sha1.cc Wed Oct 27 13:42:53 2010
@@ -312,8 +312,7 @@
* sha Error Code.
*
*/
-static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte)
-{
+static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte) {
int i;
SHA1PadMessage(context, Pad_Byte);
/* message may be sensitive, clear it out */
@@ -350,8 +349,7 @@
* Nothing.
*
*/
-static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte)
-{
+static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte) {
/*
* Check to see if the current message block is too small to hold
* the initial padding bits and length. If so, we will pad the
Modified: branches/trac364/src/lib/exceptions/exceptions.cc
==============================================================================
--- branches/trac364/src/lib/exceptions/exceptions.cc (original)
+++ branches/trac364/src/lib/exceptions/exceptions.cc Wed Oct 27 13:42:53 2010
@@ -23,8 +23,7 @@
namespace isc {
const char*
-Exception::what() const throw()
-{
+Exception::what() const throw() {
const char* whatstr = "isc::Exception";
// XXX: even though it's very unlikely that c_str() throws an exception,
Modified: branches/trac364/src/lib/exceptions/tests/run_unittests.cc
==============================================================================
--- branches/trac364/src/lib/exceptions/tests/run_unittests.cc (original)
+++ branches/trac364/src/lib/exceptions/tests/run_unittests.cc Wed Oct 27 13:42:53 2010
@@ -17,8 +17,7 @@
#include <gtest/gtest.h>
int
-main(int argc, char* argv[])
-{
+main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return (RUN_ALL_TESTS());
}
Modified: branches/trac364/src/lib/python/isc/Makefile.am
==============================================================================
--- branches/trac364/src/lib/python/isc/Makefile.am (original)
+++ branches/trac364/src/lib/python/isc/Makefile.am Wed Oct 27 13:42:53 2010
@@ -1,4 +1,4 @@
-SUBDIRS = datasrc cc config log notify util
+SUBDIRS = datasrc cc config log net notify util
python_PYTHON = __init__.py
Modified: branches/trac364/src/lib/python/isc/config/ccsession.py
==============================================================================
--- branches/trac364/src/lib/python/isc/config/ccsession.py (original)
+++ branches/trac364/src/lib/python/isc/config/ccsession.py Wed Oct 27 13:42:53 2010
@@ -1,4 +1,5 @@
# Copyright (C) 2009 Internet Systems Consortium.
+# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -169,20 +170,35 @@
time-critical, it is strongly recommended to only use
check_command(), and not look at the socket at all."""
return self._session._socket
-
+
def close(self):
"""Close the session to the command channel"""
self._session.close()
- def check_command(self):
- """Check whether there is a command or configuration update
- on the channel. Call the corresponding callback function if
- there is. This function does a non-blocking read on the
- cc session, and returns nothing. It will respond to any
- command by either an error or the answer message returned
- by the callback, unless the latter is None."""
- msg, env = self._session.group_recvmsg(True)
-
+ def check_command(self, nonblock=True):
+ """Check whether there is a command or configuration update on
+ the channel. This function does a read on the cc session, and
+ returns nothing.
+ It calls check_command_without_recvmsg()
+ to parse the received message.
+
+ If nonblock is True, it just checks if there's a command
+ and does nothing if there isn't. If nonblock is False, it
+ waits until it arrives. It temporarily sets timeout to infinity,
+ because commands may not come in arbitrary long time."""
+ timeout_orig = self._session.get_timeout()
+ self._session.set_timeout(0)
+ try:
+ msg, env = self._session.group_recvmsg(nonblock)
+ finally:
+ self._session.set_timeout(timeout_orig)
+ self.check_command_without_recvmsg(msg, env)
+
+ def check_command_without_recvmsg(self, msg, env):
+ """Parse the given message to see if there is a command or a
+ configuration update. Calls the corresponding handler
+ functions if present. Responds on the channel if the
+ handler returns a message."""
# should we default to an answer? success-by-default? unhandled error?
if msg is not None and not 'result' in msg:
answer = None
@@ -200,7 +216,8 @@
newc = self._remote_module_configs[module_name].get_local_config()
isc.cc.data.merge(newc, new_config)
self._remote_module_configs[module_name].set_local_config(newc)
- return
+ # For other modules, we're not supposed to answer
+ return
# ok, so apparently this update is for us.
errors = []
Modified: branches/trac364/src/lib/python/isc/config/module_spec.py
==============================================================================
--- branches/trac364/src/lib/python/isc/config/module_spec.py (original)
+++ branches/trac364/src/lib/python/isc/config/module_spec.py Wed Oct 27 13:42:53 2010
@@ -316,7 +316,9 @@
item_name = spec['item_name']
item_optional = spec['item_optional']
- if item_name in data:
+ if not data and item_optional:
+ return True
+ elif item_name in data:
return _validate_item(spec, full, data[item_name], errors)
elif full and not item_optional:
if errors != None:
Modified: branches/trac364/src/lib/python/isc/config/tests/ccsession_test.py
==============================================================================
--- branches/trac364/src/lib/python/isc/config/tests/ccsession_test.py (original)
+++ branches/trac364/src/lib/python/isc/config/tests/ccsession_test.py Wed Oct 27 13:42:53 2010
@@ -23,7 +23,7 @@
import os
from isc.config.ccsession import *
from isc.config.config_data import BIND10_CONFIG_DATA_VERSION
-from unittest_fakesession import FakeModuleCCSession
+from unittest_fakesession import FakeModuleCCSession, WouldBlockForever
class TestHelperFunctions(unittest.TestCase):
def test_parse_answer(self):
@@ -125,6 +125,8 @@
self.assertTrue("Spec1" in fake_session.subscriptions)
self.assertEqual(len(fake_session.message_queue), 0)
+ fake_session.group_sendmsg(None, 'Spec1')
+ fake_session.group_sendmsg(None, 'Spec1')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', {'module_name': 'Spec1'}]},
@@ -150,6 +152,8 @@
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec2.spec", None, None, fake_session)
self.assertEqual(len(fake_session.message_queue), 0)
+ fake_session.group_sendmsg(None, 'Spec2')
+ fake_session.group_sendmsg(None, 'Spec2')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', mccs.specification._module_spec]},
@@ -173,6 +177,8 @@
mccs = self.create_session("spec2.spec", None, None, fake_session)
mccs.set_config_handler(self.my_config_handler_ok)
self.assertEqual(len(fake_session.message_queue), 0)
+ fake_session.group_sendmsg(None, 'Spec2')
+ fake_session.group_sendmsg(None, 'Spec2')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', mccs.specification._module_spec]},
@@ -196,6 +202,8 @@
mccs = self.create_session("spec2.spec", None, None, fake_session)
mccs.set_config_handler(self.my_config_handler_ok)
self.assertEqual(len(fake_session.message_queue), 0)
+ fake_session.group_sendmsg(None, 'Spec2')
+ fake_session.group_sendmsg(None, 'Spec2')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', mccs.specification._module_spec]},
@@ -327,30 +335,173 @@
self.assertEqual(len(fake_session.message_queue), 1)
self.assertEqual({'result': [2, 'Spec2 has no command handler']},
fake_session.get_message('Spec2', None))
-
- def test_check_command7(self):
- fake_session = FakeModuleCCSession()
- mccs = self.create_session("spec2.spec", None, None, fake_session)
- mccs.set_command_handler(self.my_command_handler_ok)
+
+ """Many check_command tests look too similar, this is common body."""
+ def common_check_command_check(self, cmd_handler,
+ cmd_check=lambda mccs, _: mccs.check_command()):
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(cmd_handler)
self.assertEqual(len(fake_session.message_queue), 0)
cmd = isc.config.ccsession.create_command("print_message", "just a message")
fake_session.group_sendmsg(cmd, 'Spec2')
self.assertEqual(len(fake_session.message_queue), 1)
- mccs.check_command()
+ cmd_check(mccs, fake_session)
+ return fake_session
+
+ def test_check_command7(self):
+ fake_session = self.common_check_command_check(
+ self.my_command_handler_ok)
self.assertEqual(len(fake_session.message_queue), 1)
self.assertEqual({'result': [0]},
fake_session.get_message('Spec2', None))
-
+
def test_check_command8(self):
- fake_session = FakeModuleCCSession()
- mccs = self.create_session("spec2.spec", None, None, fake_session)
- mccs.set_command_handler(self.my_command_handler_no_answer)
+ fake_session = self.common_check_command_check(
+ self.my_command_handler_no_answer)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ def test_check_command_block(self):
+ """See if the message gets there even in blocking mode."""
+ fake_session = self.common_check_command_check(
+ self.my_command_handler_ok,
+ lambda mccs, _: mccs.check_command(False))
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+
+ def test_check_command_block_timeout(self):
+ """Check it works if session has timeout and it sets it back."""
+ def cmd_check(mccs, session):
+ session.set_timeout(1)
+ mccs.check_command(False)
+ fake_session = self.common_check_command_check(
+ self.my_command_handler_ok, cmd_check)
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+ self.assertEqual(fake_session.get_timeout(), 1)
+
+ def test_check_command_blocks_forever(self):
+ """Check it would wait forever checking a command."""
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
+ self.assertRaises(WouldBlockForever, lambda: mccs.check_command(False))
+
+ def test_check_command_blocks_forever_timeout(self):
+ """Like above, but it should wait forever even with timeout here."""
+ fake_session = FakeModuleCCSession()
+ fake_session.set_timeout(1)
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
+ self.assertRaises(WouldBlockForever, lambda: mccs.check_command(False))
+
+ def test_check_command_without_recvmsg1(self):
+ "copied from test_check_command2"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec1.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec1': 'abcd' })
+ env = { 'group': 'Spec1', 'from':None };
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [1, 'No config_data specification']},
+ fake_session.get_message('Spec1', None))
+
+ def test_check_command_without_recvmsg2(self):
+ "copied from test_check_command3"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec2': { 'item1': 2 }})
+ self.assertEqual(len(fake_session.message_queue), 0)
+ env = { 'group':'Spec2', 'from':None }
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+
+ def test_check_command_without_recvmsg3(self):
+ "copied from test_check_command7"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
self.assertEqual(len(fake_session.message_queue), 0)
cmd = isc.config.ccsession.create_command("print_message", "just a message")
- fake_session.group_sendmsg(cmd, 'Spec2')
- self.assertEqual(len(fake_session.message_queue), 1)
- mccs.check_command()
- self.assertEqual(len(fake_session.message_queue), 0)
+ env = { 'group':'Spec2', 'from':None }
+ self.assertEqual(len(fake_session.message_queue), 0)
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+
+ def test_check_command_without_recvmsg_remote_module(self):
+ "copied from test_check_command3"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec1.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ fake_session.group_sendmsg(None, 'Spec2')
+ rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
+ print(fake_session.message_queue)
+ self.assertEqual({'command': ['get_config', {'module_name': 'Spec2'}]},
+ fake_session.get_message('ConfigManager', None))
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec2': { 'item1': 2 }})
+ env = { 'group':'Spec2', 'from':None }
+ self.assertEqual(len(fake_session.message_queue), 0)
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ def test_check_command_without_recvmsg_remote_module2(self):
+ "copied from test_check_command3"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec1.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ fake_session.group_sendmsg(None, 'Spec2')
+ rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
+ self.assertEqual({'command': ['get_config', {'module_name': 'Spec2'}]},
+ fake_session.get_message('ConfigManager', None))
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec3': { 'item1': 2 }})
+ env = { 'group':'Spec3', 'from':None }
+ self.assertEqual(len(fake_session.message_queue), 0)
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ def test_check_command_block_timeout(self):
+ """Check it works if session has timeout and it sets it back."""
+ def cmd_check(mccs, session):
+ session.set_timeout(1)
+ mccs.check_command(False)
+ fake_session = self.common_check_command_check(
+ self.my_command_handler_ok, cmd_check)
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+ self.assertEqual(fake_session.get_timeout(), 1)
+
+ def test_check_command_blocks_forever(self):
+ """Check it would wait forever checking a command."""
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
+ self.assertRaises(WouldBlockForever, lambda: mccs.check_command(False))
+
+ def test_check_command_blocks_forever_timeout(self):
+ """Like above, but it should wait forever even with timeout here."""
+ fake_session = FakeModuleCCSession()
+ fake_session.set_timeout(1)
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
+ self.assertRaises(WouldBlockForever, lambda: mccs.check_command(False))
def test_remote_module(self):
fake_session = FakeModuleCCSession()
@@ -360,6 +511,7 @@
self.assertRaises(ModuleCCSessionError, mccs.get_remote_config_value, "Spec2", "item1")
self.assertFalse("Spec2" in fake_session.subscriptions)
+ fake_session.group_sendmsg(None, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
self.assertTrue("Spec2" in fake_session.subscriptions)
self.assertEqual("Spec2", rmodname)
@@ -373,6 +525,7 @@
self.assertRaises(ModuleCCSessionError, mccs.get_remote_config_value, "Spec2", "item1")
# test if unsubscription is alse sent when object is deleted
+ fake_session.group_sendmsg({'result' : [0]}, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
self.assertTrue("Spec2" in fake_session.subscriptions)
mccs = None
@@ -383,6 +536,7 @@
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec1.spec", None, None, fake_session)
mccs.set_command_handler(self.my_command_handler_ok)
+ fake_session.group_sendmsg(None, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
# remove the 'get config' from the queue
Modified: branches/trac364/src/lib/python/isc/config/tests/cfgmgr_test.py
==============================================================================
--- branches/trac364/src/lib/python/isc/config/tests/cfgmgr_test.py (original)
+++ branches/trac364/src/lib/python/isc/config/tests/cfgmgr_test.py Wed Oct 27 13:42:53 2010
@@ -255,6 +255,7 @@
self.fake_session.get_message(self.name, None))
self.assertEqual(len(self.fake_session.message_queue), 0)
+ self.fake_session.group_sendmsg(None, 'ConfigManager')
self._handle_msg_helper({ "command": [ "set_config", [ ] ] },
{'result': [1, 'Wrong number of arguments']} )
self._handle_msg_helper({ "command": [ "set_config", [ self.name, { "test": 125 }] ] },
Modified: branches/trac364/src/lib/python/isc/config/tests/unittest_fakesession.py
==============================================================================
--- branches/trac364/src/lib/python/isc/config/tests/unittest_fakesession.py (original)
+++ branches/trac364/src/lib/python/isc/config/tests/unittest_fakesession.py Wed Oct 27 13:42:53 2010
@@ -16,6 +16,13 @@
# $Id$
import isc
+
+class WouldBlockForever(Exception):
+ """
+ This is thrown by the FakeModuleCCSession if it would need
+ to block forever for incoming message.
+ """
+ pass
#
# We can probably use a more general version of this
@@ -64,13 +71,18 @@
if 'group' in env:
self.message_queue.append([ env['group'], None, msg])
- def group_recvmsg(self, blocking, seq = None):
+ def group_recvmsg(self, nonblock=True, seq = None):
for qm in self.message_queue:
- if qm[0] in self.subscriptions and (qm[1] == None or qm[1] in self.subscriptions[qm[0]]):
+ if qm[0] in self.subscriptions and (qm[1] == None or qm[1] in
+ self.subscriptions[qm[0]]):
self.message_queue.remove(qm)
return qm[2], {'group': qm[0], 'from': qm[1]}
if self._timeout == 0:
- return None, None
+ if nonblock:
+ return None, None
+ else:
+ raise WouldBlockForever(
+ "Blocking read without timeout and no message ready")
else:
raise isc.cc.SessionTimeout("Timeout set but no data to "
"return to group_recvmsg()")
@@ -88,3 +100,6 @@
def set_timeout(self, timeout):
self._timeout = timeout
+
+ def get_timeout(self):
+ return self._timeout
Modified: branches/trac364/src/lib/python/isc/datasrc/master.py
==============================================================================
--- branches/trac364/src/lib/python/isc/datasrc/master.py (original)
+++ branches/trac364/src/lib/python/isc/datasrc/master.py Wed Oct 27 13:42:53 2010
@@ -269,7 +269,7 @@
if second[-1] == '.':
self.__origin = second
elif not self.__origin:
- raise MasterFileError("$ORIGIN is not absolute in record:%s" % s)
+ raise MasterFileError("$ORIGIN is not absolute in record: %s" % s)
elif self.__origin != '.':
self.__origin = second + '.' + self.__origin
else:
Modified: branches/trac364/src/lib/python/isc/notify/notify_out.py
==============================================================================
--- branches/trac364/src/lib/python/isc/notify/notify_out.py (original)
+++ branches/trac364/src/lib/python/isc/notify/notify_out.py Wed Oct 27 13:42:53 2010
@@ -19,6 +19,7 @@
import socket
import threading
import time
+import errno
from isc.datasrc import sqlite3_ds
import isc
try:
@@ -44,29 +45,11 @@
_BAD_QR = 4
_BAD_REPLY_PACKET = 5
+SOCK_DATA = b's'
def addr_to_str(addr):
return '%s#%s' % (addr[0], addr[1])
-def dispatcher(notifier):
- '''The loop function for handling notify related events.
- If one zone get the notify reply before timeout, call the
- handle to process the reply. If one zone can't get the notify
- before timeout, call the handler to resend notify or notify
- next slave.
- notifier: one object of class NotifyOut. '''
- while True:
- replied_zones, not_replied_zones = notifier._wait_for_notify_reply()
- if len(replied_zones) == 0 and len(not_replied_zones) == 0:
- time.sleep(_IDLE_SLEEP_TIME) #TODO set a better time for idle sleep
- continue
-
- for name_ in replied_zones:
- notifier._zone_notify_handler(replied_zones[name_], _EVENT_READ)
-
- for name_ in not_replied_zones:
- if not_replied_zones[name_].notify_timeout <= time.time():
- notifier._zone_notify_handler(not_replied_zones[name_], _EVENT_TIMEOUT)
-
+
class ZoneNotifyInfo:
'''This class keeps track of notify-out information for one zone.'''
@@ -115,14 +98,17 @@
class NotifyOut:
'''This class is used to handle notify logic for all zones(sending
- notify message to its slaves).The only interface provided to
- the user is send_notify(). the object of this class should be
- used together with function dispatcher(). '''
+ notify message to its slaves). notify service can be started by
+ calling dispatcher(), and it can be stoped by calling shutdown()
+ in another thread. '''
def __init__(self, datasrc_file, log=None, verbose=True):
self._notify_infos = {} # key is (zone_name, zone_class)
self._waiting_zones = []
self._notifying_zones = []
self._log = log
+ self._serving = False
+ self._read_sock, self._write_sock = socket.socketpair()
+ self._read_sock.setblocking(False)
self.notify_num = 0 # the count of in progress notifies
self._verbose = verbose
self._lock = threading.Lock()
@@ -164,6 +150,70 @@
self._notify_infos[zone_id].prepare_notify_out()
self.notify_num += 1
self._notifying_zones.append(zone_id)
+
+ def _dispatcher(self, started_event):
+ started_event.set() # Let the master know we are alive already
+ while self._serving:
+ replied_zones, not_replied_zones = self._wait_for_notify_reply()
+
+ for name_ in replied_zones:
+ self._zone_notify_handler(replied_zones[name_], _EVENT_READ)
+
+ for name_ in not_replied_zones:
+ if not_replied_zones[name_].notify_timeout <= time.time():
+ self._zone_notify_handler(not_replied_zones[name_], _EVENT_TIMEOUT)
+
+ def dispatcher(self, daemon=False):
+ """Spawns a thread that will handle notify related events.
+
+ If one zone get the notify reply before timeout, call the
+ handle to process the reply. If one zone can't get the notify
+ before timeout, call the handler to resend notify or notify
+ next slave.
+
+ The thread can be stopped by calling shutdown().
+
+ Returns the thread object to anyone interested.
+ """
+
+ if self._serving:
+ raise RuntimeError(
+ 'Dispatcher already running, tried to start twice')
+
+ # Prepare for launch
+ self._serving = True
+ started_event = threading.Event()
+
+ # Start
+ self._thread = threading.Thread(target=self._dispatcher,
+ args=[started_event])
+ if daemon:
+ self._thread.daemon = daemon
+ self._thread.start()
+
+ # Wait for it to get started
+ started_event.wait()
+
+ # Return it to anyone listening
+ return self._thread
+
+ def shutdown(self):
+ """Stop the dispatcher() thread. Blocks until the thread stopped."""
+
+ if not self._serving:
+ raise RuntimeError('Tried to stop while not running')
+
+ # Ask it to stop
+ self._serving = False
+ self._write_sock.send(SOCK_DATA) # make self._read_sock be readable.
+
+ # Wait for it
+ self._thread.join()
+
+ # Clean up
+ self._write_sock = None
+ self._read_sock = None
+ self._thread = None
def _get_rdata_data(self, rr):
return rr[7].strip()
@@ -200,49 +250,68 @@
return addr_list
def _prepare_select_info(self):
- '''Prepare the information for select(), returned
- value is one tuple
+ '''
+ Prepare the information for select(), returned
+ value is one tuple
(block_timeout, valid_socks, notifying_zones)
block_timeout: the timeout for select()
valid_socks: sockets list for waiting ready reading.
- notifying_zones: the zones which have been triggered
- for notify. '''
+ notifying_zones: the zones which have been triggered
+ for notify.
+ '''
valid_socks = []
notifying_zones = {}
- min_timeout = None
+ min_timeout = None
for info in self._notify_infos:
sock = self._notify_infos[info].get_socket()
if sock:
valid_socks.append(sock)
notifying_zones[info] = self._notify_infos[info]
tmp_timeout = self._notify_infos[info].notify_timeout
- if min_timeout:
+ if min_timeout is not None:
if tmp_timeout < min_timeout:
min_timeout = tmp_timeout
else:
min_timeout = tmp_timeout
-
- block_timeout = 0
- if min_timeout:
+
+ block_timeout = _IDLE_SLEEP_TIME
+ if min_timeout is not None:
block_timeout = min_timeout - time.time()
if block_timeout < 0:
block_timeout = 0
-
+
return (block_timeout, valid_socks, notifying_zones)
def _wait_for_notify_reply(self):
- '''receive notify replies in specified time. returned value
- is one tuple:(replied_zones, not_replied_zones)
+ '''
+ Receive notify replies in specified time. returned value
+ is one tuple:(replied_zones, not_replied_zones). ({}, {}) is
+ returned if shutdown() was called.
+
replied_zones: the zones which receive notify reply.
not_replied_zones: the zones which haven't got notify reply.
+
'''
- (block_timeout, valid_socks, notifying_zones) = self._prepare_select_info()
+ (block_timeout, valid_socks, notifying_zones) = \
+ self._prepare_select_info()
+ # This is None only during some tests
+ if self._read_sock is not None:
+ valid_socks.append(self._read_sock)
try:
r_fds, w, e = select.select(valid_socks, [], [], block_timeout)
except select.error as err:
if err.args[0] != EINTR:
- return [], []
-
+ return {}, {}
+
+ if self._read_sock in r_fds: # user has called shutdown()
+ try:
+ # Noone should write anything else than shutdown
+ assert self._read_sock.recv(len(SOCK_DATA)) == SOCK_DATA
+ return {}, {}
+ except socket.error as e: # Workaround around rare linux bug
+ if e.errno != errno.EAGAIN and e.errno != errno.EWOULDBLOCK:
+ raise
+
not_replied_zones = {}
replied_zones = {}
for info in notifying_zones:
Modified: branches/trac364/src/lib/python/isc/notify/tests/notify_out_test.py
==============================================================================
--- branches/trac364/src/lib/python/isc/notify/tests/notify_out_test.py (original)
+++ branches/trac364/src/lib/python/isc/notify/tests/notify_out_test.py Wed Oct 27 13:42:53 2010
@@ -20,7 +20,7 @@
import time
import socket
from isc.datasrc import sqlite3_ds
-from isc.notify import notify_out
+from isc.notify import notify_out, SOCK_DATA
class TestZoneNotifyInfo(unittest.TestCase):
def setUp(self):
@@ -53,8 +53,6 @@
class TestNotifyOut(unittest.TestCase):
def setUp(self):
- self.old_stdout = sys.stdout
- sys.stdout = open(os.devnull, 'w')
self._db_file = tempfile.NamedTemporaryFile(delete=False)
sqlite3_ds.load(self._db_file.name, 'cn.', self._cn_data_reader)
sqlite3_ds.load(self._db_file.name, 'com.', self._com_data_reader)
@@ -70,7 +68,6 @@
info.notify_slaves.append(('1.1.1.1', 5353))
def tearDown(self):
- sys.stdout = self.old_stdout
self._db_file.close()
os.unlink(self._db_file.name)
@@ -123,6 +120,20 @@
self.assertTrue(('com.', 'IN') in timeout_zones.keys())
self.assertLess(time.time(), self._notify._notify_infos[('com.', 'IN')].notify_timeout)
+ def test_wait_for_notify_reply_2(self):
+ # Test the returned value when the read_side socket is readable.
+ self._notify.send_notify('cn.')
+ self._notify.send_notify('com.')
+
+ # Now make one socket be readable
+ self._notify._notify_infos[('cn.', 'IN')].notify_timeout = time.time() + 10
+ self._notify._notify_infos[('com.', 'IN')].notify_timeout = time.time() + 10
+ self._notify._read_sock, self._notify._write_sock = socket.socketpair()
+ self._notify._write_sock.send(SOCK_DATA)
+ replied_zones, timeout_zones = self._notify._wait_for_notify_reply()
+ self.assertEqual(0, len(replied_zones))
+ self.assertEqual(0, len(timeout_zones))
+
def test_notify_next_target(self):
self._notify.send_notify('cn.')
self._notify.send_notify('com.')
@@ -258,7 +269,7 @@
def test_prepare_select_info(self):
timeout, valid_fds, notifying_zones = self._notify._prepare_select_info()
- self.assertEqual(0, timeout)
+ self.assertEqual(notify_out._IDLE_SLEEP_TIME, timeout)
self.assertListEqual([], valid_fds)
self._notify._notify_infos[('cn.', 'IN')]._sock = 1
@@ -279,6 +290,12 @@
self.assertEqual(timeout, 0)
self.assertListEqual([2, 1], valid_fds)
+ def test_shutdown(self):
+ thread = self._notify.dispatcher()
+ self.assertTrue(thread.is_alive())
+ self._notify.shutdown()
+ self.assertFalse(thread.is_alive())
+
if __name__== "__main__":
unittest.main()
Modified: branches/trac364/src/lib/python/isc/util/Makefile.am
==============================================================================
--- branches/trac364/src/lib/python/isc/util/Makefile.am (original)
+++ branches/trac364/src/lib/python/isc/util/Makefile.am Wed Oct 27 13:42:53 2010
@@ -1,5 +1,5 @@
-SUBDIRS = tests
+SUBDIRS = . tests
-python_PYTHON = __init__.py process.py
+python_PYTHON = __init__.py process.py socketserver_mixin.py
pythondir = $(pyexecdir)/isc/util
Modified: branches/trac364/src/lib/python/isc/util/__init__.py
==============================================================================
--- branches/trac364/src/lib/python/isc/util/__init__.py (original)
+++ branches/trac364/src/lib/python/isc/util/__init__.py Wed Oct 27 13:42:53 2010
@@ -1,0 +1,1 @@
+from isc.util.socketserver_mixin import *
Modified: branches/trac364/src/lib/python/isc/util/tests/Makefile.am
==============================================================================
--- branches/trac364/src/lib/python/isc/util/tests/Makefile.am (original)
+++ branches/trac364/src/lib/python/isc/util/tests/Makefile.am Wed Oct 27 13:42:53 2010
@@ -1,4 +1,4 @@
-PYTESTS = process_test.py
+PYTESTS = process_test.py socketserver_mixin_test.py
EXTRA_DIST = $(PYTESTS)
# later will have configure option to choose this, like: coverage run --branch
Modified: branches/trac364/src/lib/xfr/python_xfr.cc
==============================================================================
--- branches/trac364/src/lib/xfr/python_xfr.cc (original)
+++ branches/trac364/src/lib/xfr/python_xfr.cc Wed Oct 27 13:42:53 2010
@@ -28,8 +28,7 @@
using namespace isc::xfr;
using namespace boost::python;
-BOOST_PYTHON_MODULE(bind10_xfr)
-{
+BOOST_PYTHON_MODULE(bind10_xfr) {
def("recv_fd", &recv_fd);
def("send_fd", &send_fd);
}
Modified: branches/trac364/src/lib/xfr/xfrout_client.cc
==============================================================================
--- branches/trac364/src/lib/xfr/xfrout_client.cc (original)
+++ branches/trac364/src/lib/xfr/xfrout_client.cc Wed Oct 27 13:42:53 2010
@@ -47,8 +47,7 @@
impl_(new XfroutClientImpl(file))
{}
-XfroutClient::~XfroutClient()
-{
+XfroutClient::~XfroutClient() {
delete impl_;
}
More information about the bind10-changes
mailing list