Commit 0355bddc authored by Naoki Kambe's avatar Naoki Kambe

Merge branch 'trac698'

Conflicts:
	ChangeLog
parents 62a61edf dec73bbd
212. [bug] naokikambe
Fixed that the ModuleCCSession object may group_unsubscribe in the
closed CC session in being deleted.
(Trac #698, git tbdtbdtbdtbdtbdtbdtbdtbdtbdtbdtbdtbdttbd)
211. [func] shane
Implement "--brittle" option, which causes the server to exit
if any of BIND 10's processes dies.
......
......@@ -151,6 +151,9 @@ class ModuleCCSession(ConfigData):
self._remote_module_configs = {}
def __del__(self):
# If the CC Session obejct has been closed, it returns
# immediately.
if self._session._closed: return
self._session.group_unsubscribe(self._module_name, "*")
for module_name in self._remote_module_configs:
self._session.group_unsubscribe(module_name)
......
......@@ -234,7 +234,18 @@ class TestModuleCCSession(unittest.TestCase):
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec1.spec", None, None, fake_session)
mccs.close()
self.assertEqual("closed", fake_session._socket)
self.assertEqual(None, fake_session._socket)
def test_del_opened(self):
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec1.spec", None, None, fake_session)
mccs.__del__() # with opened fake_session
def test_del_closed(self):
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec1.spec", None, None, fake_session)
fake_session.close()
mccs.__del__() # with closed fake_session
def my_config_handler_ok(self, new_config):
return isc.config.ccsession.create_answer(0)
......
......@@ -35,6 +35,7 @@ class FakeModuleCCSession:
# the message_queue is empty when receive is called, throw
# a SessionTimeout
self._timeout = 0
self._closed = False
def group_subscribe(self, group_name, instance_name = None):
if not group_name in self.subscriptions:
......@@ -43,6 +44,11 @@ class FakeModuleCCSession:
self.subscriptions[group_name].append(instance_name)
def group_unsubscribe(self, group_name, instance_name = None):
# raises SessionError if the session has been already closed.
if self._closed:
raise isc.cc.SessionError("Session has been closed.")
if group_name in self.subscriptions:
if instance_name:
if len(self.subscriptions[group_name]) > 1:
......@@ -94,7 +100,8 @@ class FakeModuleCCSession:
def close(self):
# need to pass along somehow that this function has been called,
self._socket = "closed"
self._socket = None
self._closed = True
def set_timeout(self, timeout):
self._timeout = timeout
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment