BIND 10 trac565, updated. 5266058997a5746c04db5a721ac60630bbbc2abd [trac565] Nothing started by config before startup
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Feb 14 15:32:51 UTC 2011
The branch, trac565 has been updated
via 5266058997a5746c04db5a721ac60630bbbc2abd (commit)
via a30321812264615d0f64271ce6ba5e841f7977a5 (commit)
via 93b246f4689918c081d9ed889cea9140b75adc1f (commit)
from 569afbc3c08776e04f1b755dce2ff5aa5c385647 (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 5266058997a5746c04db5a721ac60630bbbc2abd
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Feb 14 16:32:17 2011 +0100
[trac565] Nothing started by config before startup
commit a30321812264615d0f64271ce6ba5e841f7977a5
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Feb 14 16:22:00 2011 +0100
[tra565] Processes are started just once
commit 93b246f4689918c081d9ed889cea9140b75adc1f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Feb 14 16:13:55 2011 +0100
[trac565] Test processes are started just once
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10.py.in | 35 +++++++++++++++++++---------
src/bin/bind10/tests/bind10_test.py | 43 +++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 11 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10.py.in b/src/bin/bind10/bind10.py.in
index 6551b12..e08bf1e 100644
--- a/src/bin/bind10/bind10.py.in
+++ b/src/bin/bind10/bind10.py.in
@@ -215,6 +215,8 @@ class BoB:
self.ccs = None
self.cfg_start_auth = True
self.cfg_start_resolver = False
+ self.started_auth_family = False
+ self.started_resolver_family = False
self.curproc = None
self.dead_processes = {}
self.msgq_socket_file = msgq_socket_file
@@ -226,31 +228,40 @@ class BoB:
self.verbose = verbose
def config_handler(self, new_config):
+ # This is initial update, don't do anything by it, leave it to startup
+ if not self.runnable:
+ return
if self.verbose:
sys.stdout.write("[bind10] Handling new configuration: " +
str(new_config) + "\n")
if 'start_resolver' in new_config:
if new_config['start_resolver']:
- if self.uid is not None:
- sys.stderr.write("[bind10] Starting resolver as a user," +
- "not root. This might fail.\n")
- self.start_resolver(self.c_channel_env)
+ if not self.started_resolver_family:
+ if self.uid is not None:
+ sys.stderr.write("[bind10] Starting resolver as a user," +
+ "not root. This might fail.\n")
+ self.start_resolver(self.c_channel_env)
+ self.started_resolver_family = True
else:
self.stop_resolver()
+ self.started_resolver_family = False
if 'start_auth' in new_config:
if new_config['start_auth']:
- if self.uid is not None:
- sys.stderr.write("[bind10] Starting auth as a user," +
- "not root. This might fail.\n")
- self.start_auth(self.c_channel_env)
- self.start_xfrout(self.c_channel_env)
- self.start_xfrin(self.c_channel_env)
- self.start_zonemgr(self.c_channel_env)
+ if not self.started_auth_family:
+ if self.uid is not None:
+ sys.stderr.write("[bind10] Starting auth as a user," +
+ "not root. This might fail.\n")
+ self.start_auth(self.c_channel_env)
+ self.start_xfrout(self.c_channel_env)
+ self.start_xfrin(self.c_channel_env)
+ self.start_zonemgr(self.c_channel_env)
+ self.started_auth_family = True
else:
self.stop_zonemgr()
self.stop_xfrin()
self.stop_xfrout()
self.stop_auth()
+ self.started_auth_family = False
answer = isc.config.ccsession.create_answer(0)
return answer
@@ -522,6 +533,7 @@ class BoB:
# ... and resolver (if selected):
if self.cfg_start_resolver:
self.start_resolver(c_channel_env)
+ self.started_resolver_family = True
# Everything after the main components can run as non-root.
# TODO: this is only temporary - once the privileged socket creator is
@@ -535,6 +547,7 @@ class BoB:
self.start_xfrout(c_channel_env)
self.start_xfrin(c_channel_env)
self.start_zonemgr(c_channel_env)
+ self.started_auth_family = True
# ... and finally start the remaining processes
self.start_stats(c_channel_env)
diff --git a/src/bin/bind10/tests/bind10_test.py b/src/bin/bind10/tests/bind10_test.py
index d13d9cc..17b78b1 100644
--- a/src/bin/bind10/tests/bind10_test.py
+++ b/src/bin/bind10/tests/bind10_test.py
@@ -381,6 +381,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
bob.cfg_start_resolver = False
bob.start_all_processes()
+ bob.runnable = True
self.check_started_none(bob)
# Enable both at once
@@ -431,5 +432,47 @@ class TestStartStopProcessesBob(unittest.TestCase):
bob.config_handler({'start_auth': True, 'start_resolver': False})
self.check_started_auth(bob)
+ def test_config_start_once(self):
+ """
+ Tests that a process is started only once.
+ """
+ # Created Bob and ensure initialization correct
+ bob = StartAllProcessesBob()
+ self.check_preconditions(bob)
+
+ # Start processes (both)
+ bob.cfg_start_auth = True
+ bob.cfg_start_resolver = True
+
+ bob.start_all_processes()
+ bob.runnable = True
+ self.check_started_both(bob)
+
+ bob.start_auth = lambda: self.fail("Started auth again")
+ bob.start_xfrout = lambda: self.fail("Started xfrout again")
+ bob.start_xfrin = lambda: self.fail("Started xfrin again")
+ bob.start_zonemgr = lambda: self.fail("Started zonemgr again")
+ bob.start_resolver = lambda: self.fail("Started resolver again")
+
+ # Send again we want to start them. Should not do it, as they are.
+ bob.config_handler({'start_auth': True})
+ bob.config_handler({'start_resolver': True})
+
+ def test_config_not_started_early(self):
+ """
+ Test that processes are not started by the config handler before
+ startup.
+ """
+ bob = StartAllProcessesBob()
+ self.check_preconditions(bob)
+
+ bob.start_auth = lambda: self.fail("Started auth again")
+ bob.start_xfrout = lambda: self.fail("Started xfrout again")
+ bob.start_xfrin = lambda: self.fail("Started xfrin again")
+ bob.start_zonemgr = lambda: self.fail("Started zonemgr again")
+ bob.start_resolver = lambda: self.fail("Started resolver again")
+
+ bob.config_handler({'start_auth': True, 'start_resolver': True})
+
if __name__ == '__main__':
unittest.main()
More information about the bind10-changes
mailing list