BIND 10 trac1429, updated. d9b851b96c9fb3f56c4fe3a626f5c2b05bbb7a5f [1429] Creation of the cache
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Nov 29 12:39:13 UTC 2011
The branch, trac1429 has been updated
via d9b851b96c9fb3f56c4fe3a626f5c2b05bbb7a5f (commit)
from 51f3cb54492ef02e4951afb15a9c40ba0cdff4ce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d9b851b96c9fb3f56c4fe3a626f5c2b05bbb7a5f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Nov 29 13:38:54 2011 +0100
[1429] Creation of the cache
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10_src.py.in | 14 ++++++++++++++
src/bin/bind10/tests/bind10_test.py.in | 16 ++++++++++++++++
src/lib/python/isc/bind10/socket_cache.py | 4 +++-
src/lib/python/isc/bind10/special_component.py | 1 +
4 files changed, 34 insertions(+), 1 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index 063e31c..35e852a 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -72,6 +72,7 @@ import isc.log
from isc.log_messages.bind10_messages import *
import isc.bind10.component
import isc.bind10.special_component
+import isc.bind10.socket_cache
isc.log.init("b10-boss")
logger = isc.log.Logger("boss")
@@ -241,6 +242,7 @@ class BoB:
# If -v was set, enable full debug logging.
if self.verbose:
logger.set_severity("DEBUG", 99)
+ self._socket_cache = None
def __propagate_component_config(self, config):
comps = dict(config)
@@ -828,6 +830,18 @@ class BoB:
"""
pass
+ def insert_creator(self, creator):
+ """
+ Registeres a socket creator into the boss. The socket creator is not
+ used directly, but through a cache. The cache is created in this
+ method.
+
+ If called more than once, it raises a ValueError.
+ """
+ if self._socket_cache is not None:
+ raise ValueError("A creator was inserted previously")
+ self._socket_cache = isc.bind10.socket_cache.Cache(creator)
+
# global variables, needed for signal handlers
options = None
boss_of_bind = None
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index db68b35..ba72a6a 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -28,6 +28,7 @@ from isc.net.addr import IPAddr
import time
import isc
import isc.log
+import isc.bind10.socket_cache
from isc.testutils.parse_args import TestOptParser, OptsError
@@ -109,6 +110,21 @@ class TestBoB(unittest.TestCase):
self.assertEqual(bob.uid, None)
self.assertEqual(bob.username, None)
self.assertEqual(bob.nocache, False)
+ self.assertIsNone(bob._socket_cache)
+
+ def test_insert_creator(self):
+ """
+ Test the call to insert_creator. First time, the cache is created
+ with the passed creator. The next time, it throws an exception.
+ """
+ bob = BoB()
+ # The cache doesn't use it at start, so just create an empty class
+ class Creator: pass
+ creator = Creator()
+ bob.insert_creator(creator)
+ self.assertIsInstance(bob._socket_cache, isc.bind10.socket_cache.Cache)
+ self.assertEqual(creator, bob._socket_cache._creator)
+ self.assertRaises(ValueError, bob.insert_creator, creator)
def test_init_alternate_socket(self):
bob = BoB("alt_socket_file")
diff --git a/src/lib/python/isc/bind10/socket_cache.py b/src/lib/python/isc/bind10/socket_cache.py
index d499cbd..f58ea1c 100644
--- a/src/lib/python/isc/bind10/socket_cache.py
+++ b/src/lib/python/isc/bind10/socket_cache.py
@@ -54,7 +54,9 @@ class Cache:
(isc.bind10.sockcreator.Creator) which will be used to create yet
uncached sockets.
"""
- pass
+ # Full implementation and tests are in #1427. This is just because
+ # of a boss test.
+ self._creator = creator
def get_token(self, protocol, address, port, share_mode, share_name):
"""
diff --git a/src/lib/python/isc/bind10/special_component.py b/src/lib/python/isc/bind10/special_component.py
index 1c8bc64..7d35814 100644
--- a/src/lib/python/isc/bind10/special_component.py
+++ b/src/lib/python/isc/bind10/special_component.py
@@ -42,6 +42,7 @@ class SockCreator(BaseComponent):
self.__creator = isc.bind10.sockcreator.Creator(LIBEXECDIR + ':' +
os.environ['PATH'])
self._boss.register_process(self.pid(), self)
+ self._boss.insert_creator(self.__creator)
self._boss.log_started(self.pid())
def _stop_internal(self):
More information about the bind10-changes
mailing list