BIND 10 trac565, updated. a0cf49f8a45dbaa40a90d6be8959834a0c5c2eb9 [trac576] Wording and naming fixes

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Feb 23 21:33:58 UTC 2011


The branch, trac565 has been updated
       via  a0cf49f8a45dbaa40a90d6be8959834a0c5c2eb9 (commit)
       via  b479db63aeb73ba268ea46b3a4a3bac29dcbf2c7 (commit)
       via  37bdb296e6156be88b868ec27005def104d7db13 (commit)
       via  c5cf405c5dcb6dccdc46e3ec67e0a04697491e86 (commit)
      from  e5961a4ce06bb430469c457856f5392ca147d857 (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 a0cf49f8a45dbaa40a90d6be8959834a0c5c2eb9
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Feb 23 22:31:36 2011 +0100

    [trac576] Wording and naming fixes

commit b479db63aeb73ba268ea46b3a4a3bac29dcbf2c7
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Feb 23 22:22:22 2011 +0100

    [trac576] Rename sendo to recipient

commit 37bdb296e6156be88b868ec27005def104d7db13
Merge: c5cf405c5dcb6dccdc46e3ec67e0a04697491e86 e5961a4ce06bb430469c457856f5392ca147d857
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Feb 23 22:15:16 2011 +0100

    Merge branch 'trac565' of git+ssh://bind10.isc.org/var/bind10/git/bind10 into work/boss/start

commit c5cf405c5dcb6dccdc46e3ec67e0a04697491e86
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Feb 23 22:08:26 2011 +0100

    [trac576] Reorder the config_handler for readability
    
    The closures are moved to the top of the function and commented. It'll
    hopefully be more readable this way.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/bind10/bind10.py.in         |   26 ++++++++++++++++----------
 src/bin/bind10/tests/bind10_test.py |   20 ++++++++++----------
 2 files changed, 26 insertions(+), 20 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10.py.in b/src/bin/bind10/bind10.py.in
index a4596e2..7e876ff 100755
--- a/src/bin/bind10/bind10.py.in
+++ b/src/bin/bind10/bind10.py.in
@@ -232,9 +232,9 @@ class BoB:
         # If this is initial update, don't do anything now, leave it to startup
         if not self.runnable:
             return
-        if self.verbose:
-            sys.stdout.write("[bind10] Handling new configuration: " +
-                str(new_config) + "\n")
+        # Now we declare few functions used only internally here. Besides the
+        # benefit of not polluting the name space, they are closures, so we
+        # don't need to pass some variables
         def start_stop(name, started, start, stop):
             if not'start_' + name in new_config:
                 return
@@ -246,14 +246,14 @@ class BoB:
                     start()
             else:
                 stop()
+        # These four functions are passed to start_stop (smells like functional
+        # programming little bit)
         def resolver_on():
             self.start_resolver(self.c_channel_env)
             self.started_resolver_family = True
         def resolver_off():
             self.stop_resolver()
             self.started_resolver_family = False
-        start_stop('resolver', self.started_resolver_family, resolver_on,
-            resolver_off)
         def auth_on():
             self.start_auth(self.c_channel_env)
             self.start_xfrout(self.c_channel_env)
@@ -266,11 +266,17 @@ class BoB:
             self.stop_xfrout()
             self.stop_auth()
             self.started_auth_family = False
+
+        # The real code of the config handler function follows here
+        if self.verbose:
+            sys.stdout.write("[bind10] Handling new configuration: " +
+                str(new_config) + "\n")
+        start_stop('resolver', self.started_resolver_family, resolver_on,
+            resolver_off)
         start_stop('auth', self.started_auth_family, auth_on, auth_off)
 
         answer = isc.config.ccsession.create_answer(0)
         return answer
-        # TODO
 
     def command_handler(self, command, args):
         if self.verbose:
@@ -606,10 +612,10 @@ class BoB:
         self.cc_session.group_sendmsg(cmd, "Zonemgr", "Zonemgr")
         self.cc_session.group_sendmsg(cmd, "Stats", "Stats")
 
-    def stop_process(self, process, sendto):
+    def stop_process(self, process, recipient):
         """
         Stop the given process, friendly-like. The process is the name it has
-        (in logs, etc), the sendto is the address on msgq.
+        (in logs, etc), the recipient is the address on msgq.
         """
         if self.verbose:
             sys.stdout.write("[bind10] Asking %s to terminate\n" % process)
@@ -617,8 +623,8 @@ class BoB:
         # help. We can even store it in the dict, it is used only as a set
         self.expected_shutdowns[process] = 1
         # Ask the process to die willingly
-        self.cc_session.group_sendmsg({'command': ['shutdown']}, sendto,
-            sendto)
+        self.cc_session.group_sendmsg({'command': ['shutdown']}, recipient,
+            recipient)
 
     # Series of stop_process wrappers
     def stop_resolver(self):
diff --git a/src/bin/bind10/tests/bind10_test.py b/src/bin/bind10/tests/bind10_test.py
index 70ffdfa..ffa06bc 100644
--- a/src/bin/bind10/tests/bind10_test.py
+++ b/src/bin/bind10/tests/bind10_test.py
@@ -148,7 +148,7 @@ class TestBoB(unittest.TestCase):
 # of the unit test, by overriding the process start methods we can check
 # that the right processes are started depending on the configuration
 # options.
-class StartCheckBob(BoB):
+class StartStopCheckBob(BoB):
     def __init__(self):
         BoB.__init__(self)
 
@@ -240,8 +240,8 @@ class TestStartStopProcessesBob(unittest.TestCase):
     """
     def check_started(self, bob, core, auth, resolver):
         """
-        Check that the right sets of processes are started. The ones that
-        should running are specified by the core, auth and resolver parameters
+        Check that the right sets of services are started. The ones that
+        should be running are specified by the core, auth and resolver parameters
         (they are groups of processes, eg. auth means b10-auth, -xfrout, -xfrin
         and -zonemgr).
         """
@@ -289,7 +289,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
     # is specified.
     def test_start_none(self):
         # Create BoB and ensure correct initialization
-        bob = StartCheckBob()
+        bob = StartStopCheckBob()
         self.check_preconditions(bob)
 
         # Start processes and check what was started
@@ -302,7 +302,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
     # Checks the processes started when starting only the auth process
     def test_start_auth(self):
         # Create BoB and ensure correct initialization
-        bob = StartCheckBob()
+        bob = StartStopCheckBob()
         self.check_preconditions(bob)
 
         # Start processes and check what was started
@@ -316,7 +316,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
     # Checks the processes started when starting only the resolver process
     def test_start_resolver(self):
         # Create BoB and ensure correct initialization
-        bob = StartCheckBob()
+        bob = StartStopCheckBob()
         self.check_preconditions(bob)
 
         # Start processes and check what was started
@@ -330,7 +330,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
     # Checks the processes started when starting both auth and resolver process
     def test_start_both(self):
         # Create BoB and ensure correct initialization
-        bob = StartCheckBob()
+        bob = StartStopCheckBob()
         self.check_preconditions(bob)
 
         # Start processes and check what was started
@@ -348,7 +348,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
         """
 
         # Create BoB and ensure correct initialization
-        bob = StartCheckBob()
+        bob = StartStopCheckBob()
         self.check_preconditions(bob)
 
         # Start processes (nothing much should be started, as in
@@ -413,7 +413,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
         Tests that a process is started only once.
         """
         # Create BoB and ensure correct initialization
-        bob = StartCheckBob()
+        bob = StartStopCheckBob()
         self.check_preconditions(bob)
 
         # Start processes (both)
@@ -439,7 +439,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
         Test that processes are not started by the config handler before
         startup.
         """
-        bob = StartCheckBob()
+        bob = StartStopCheckBob()
         self.check_preconditions(bob)
 
         bob.start_auth = lambda: self.fail("Started auth again")




More information about the bind10-changes mailing list