BIND 10 trac2856, updated. 4f96d3ab2e65356e9cb778ba140a9b8793f8e879 [2856] Raise an exception if start_update() is called in any state other than READY

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jul 24 09:53:41 UTC 2013


The branch, trac2856 has been updated
       via  4f96d3ab2e65356e9cb778ba140a9b8793f8e879 (commit)
       via  77e3dfce7c96bc924de4f1ca7060287c147e53e5 (commit)
      from  724e39ef6eaba76229a8208d2bf33449f16f3c01 (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 4f96d3ab2e65356e9cb778ba140a9b8793f8e879
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Jul 24 15:23:17 2013 +0530

    [2856] Raise an exception if start_update() is called in any state other than READY

commit 77e3dfce7c96bc924de4f1ca7060287c147e53e5
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Jul 24 15:18:34 2013 +0530

    [2856] Simplify code (old_readers will be empty before syncing readers)

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

Summary of changes:
 src/lib/python/isc/memmgr/datasrc_info.py          |   16 ++++++++++------
 .../python/isc/memmgr/tests/datasrc_info_tests.py  |   19 ++++++++-----------
 2 files changed, 18 insertions(+), 17 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/memmgr/datasrc_info.py b/src/lib/python/isc/memmgr/datasrc_info.py
index 84d8bb4..763176a 100644
--- a/src/lib/python/isc/memmgr/datasrc_info.py
+++ b/src/lib/python/isc/memmgr/datasrc_info.py
@@ -144,11 +144,15 @@ class SegmentInfo:
         event (without removing it from the pending events queue). This
         tells the caller (memmgr) that it should initiate the update
         process with the builder. In all other cases it returns None."""
-        if self.__state == self.READY and self.__events:
-            self.__state = self.UPDATING
-            return self.__events[0]
+        if self.__state == self.READY:
+            if self.__events:
+                self.__state = self.UPDATING
+                return self.__events[0]
+            else:
+                return None
 
-        return None
+        raise SegmentInfoError('start_update() called in ' +
+                               'incorrect state: ' + str(self.__state))
 
     def complete_update(self):
         """This method should be called when memmgr is notified by the
@@ -163,8 +167,8 @@ class SegmentInfo:
         UPDATING and COPYING."""
         if self.__state == self.UPDATING:
             self.__state = self.SYNCHRONIZING
-            self.__old_readers.update(self.__readers)
-            self.__readers.clear()
+            self.__old_readers = self.__readers
+            self.__readers = set()
             return self.__sync_reader_helper(self.SYNCHRONIZING)
         elif self.__state == self.COPYING:
             self.__state = self.READY
diff --git a/src/lib/python/isc/memmgr/tests/datasrc_info_tests.py b/src/lib/python/isc/memmgr/tests/datasrc_info_tests.py
index e07e005..845d246 100644
--- a/src/lib/python/isc/memmgr/tests/datasrc_info_tests.py
+++ b/src/lib/python/isc/memmgr/tests/datasrc_info_tests.py
@@ -134,25 +134,22 @@ class TestSegmentInfo(unittest.TestCase):
         self.assertTupleEqual(e, (42,))
         self.assertEqual(self.__sgmt_info.get_state(), SegmentInfo.UPDATING)
 
-        # in UPDATING state, it should always return None and not change
-        # state.
+        # in UPDATING state, it should always raise an exception and not
+        # change state.
         self.__si_to_updating_state()
-        e = self.__sgmt_info.start_update()
-        self.assertIsNone(e)
+        self.assertRaises(SegmentInfoError, self.__sgmt_info.start_update)
         self.assertEqual(self.__sgmt_info.get_state(), SegmentInfo.UPDATING)
 
-        # in SYNCHRONIZING state, it should always return None and not
-        # change state.
+        # in SYNCHRONIZING state, it should always raise an exception
+        # and not change state.
         self.__si_to_synchronizing_state()
-        e = self.__sgmt_info.start_update()
-        self.assertIsNone(e)
+        self.assertRaises(SegmentInfoError, self.__sgmt_info.start_update)
         self.assertEqual(self.__sgmt_info.get_state(), SegmentInfo.SYNCHRONIZING)
 
-        # in COPYING state, it should always return None and not
+        # in COPYING state, it should always raise an exception and not
         # change state.
         self.__si_to_copying_state()
-        e = self.__sgmt_info.start_update()
-        self.assertIsNone(e)
+        self.assertRaises(SegmentInfoError, self.__sgmt_info.start_update)
         self.assertEqual(self.__sgmt_info.get_state(), SegmentInfo.COPYING)
 
     def test_complete_update(self):



More information about the bind10-changes mailing list