BIND 10 trac1001, updated. 9395f12c95a2519803a0dc15b56424c22df88c84 [trac1001] fix code style and update unittest

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jun 27 05:28:37 UTC 2011


The branch, trac1001 has been updated
       via  9395f12c95a2519803a0dc15b56424c22df88c84 (commit)
      from  5ac59583a36f1d83d35ba8d159f87bb281d3edc5 (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 9395f12c95a2519803a0dc15b56424c22df88c84
Author: chenzhengzhang <jerry.zzpku at gmail.com>
Date:   Mon Jun 27 13:27:43 2011 +0800

    [trac1001] fix code style and update unittest

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

Summary of changes:
 src/lib/python/isc/notify/notify_out.py            |   11 ++++----
 src/lib/python/isc/notify/tests/notify_out_test.py |   26 ++++++++++++++++++-
 2 files changed, 29 insertions(+), 8 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/notify/notify_out.py b/src/lib/python/isc/notify/notify_out.py
index 3401caa..4b25463 100644
--- a/src/lib/python/isc/notify/notify_out.py
+++ b/src/lib/python/isc/notify/notify_out.py
@@ -54,10 +54,6 @@ class ZoneNotifyInfo:
     '''This class keeps track of notify-out information for one zone.'''
 
     def __init__(self, zone_name_, class_):
-        '''notify_timeout_: absolute time for next notify reply. when the zone
-        is preparing for sending notify message, notify_timeout_ is set to now,
-        that means the first sending is triggered by the 'Timeout' mechanism.
-        '''
         self._notify_current = None
         self._slave_index = 0
         self._sock = None
@@ -66,8 +62,11 @@ class ZoneNotifyInfo:
         self.zone_name = zone_name_
         self.zone_class = class_
         self.notify_msg_id = 0
+        # Absolute time for next notify reply. When the zone is preparing for
+        # sending notify message, notify_timeout_ is set to now, that means
+        # the first sending is triggered by the 'Timeout' mechanism.
         self.notify_timeout = None
-        self.notify_try_num = 0  #Notify times sending to one target.
+        self.notify_try_num = 0  # Notify times sending to one target.
 
     def set_next_notify_target(self):
         if self._slave_index < (len(self.notify_slaves) - 1):
@@ -377,8 +376,8 @@ class NotifyOut:
                 self._log_msg('info', 'notify to %s: retried exceeded' % addr_to_str(tgt))
                 self._notify_next_target(zone_notify_info)
             else:
-                retry_timeout = _NOTIFY_TIMEOUT * pow(2, zone_notify_info.notify_try_num)
                 # set exponential backoff according rfc1996 section 3.6
+                retry_timeout = _NOTIFY_TIMEOUT * pow(2, zone_notify_info.notify_try_num)
                 zone_notify_info.notify_timeout = time.time() + retry_timeout
                 self._send_notify_message_udp(zone_notify_info, tgt)
 
diff --git a/src/lib/python/isc/notify/tests/notify_out_test.py b/src/lib/python/isc/notify/tests/notify_out_test.py
index ef54a7b..2423ccd 100644
--- a/src/lib/python/isc/notify/tests/notify_out_test.py
+++ b/src/lib/python/isc/notify/tests/notify_out_test.py
@@ -376,9 +376,31 @@ class TestNotifyOut(unittest.TestCase):
 
     def test_shutdown(self):
         thread = self._notify.dispatcher()
-        # nonblock_event will be cleared since there are no notifying zones.
-        self.assertFalse(self._notify._nonblock_event.isSet())
         self.assertTrue(thread.is_alive())
+        # nonblock_event won't be setted since there are no notifying zones.
+        self.assertFalse(self._notify._nonblock_event.isSet())
+
+        # set nonblock_event manually
+        self._notify._nonblock_event.set()
+        # nonblock_event will be cleared soon since there are no notifying zones.
+        while (self._notify._nonblock_event.isSet()):
+            pass
+        self.assertFalse(self._notify._nonblock_event.isSet())
+
+        # send notify
+        example_net_info = self._notify._notify_infos[('example.net.', 'IN')]
+        example_net_info.notify_slaves = [('127.0.0.1', 53)]
+        example_net_info.create_socket('127.0.0.1')
+        self._notify.send_notify('example.net')
+        self.assertTrue(self._notify._nonblock_event.isSet())
+        # set notify_try_num to _MAX_NOTIFY_TRY_NUM, zone 'example.net' will be removed
+        # from notifying zones soon and nonblock_event will be cleared since there is no 
+        # notifying zone left.
+        example_net_info.notify_try_num = notify_out._MAX_NOTIFY_TRY_NUM
+        while (self._notify._nonblock_event.isSet()):
+            pass
+        self.assertFalse(self._notify._nonblock_event.isSet())
+
         self._notify.shutdown()
         # nonblock_event should have been setted to stop waiting.
         self.assertTrue(self._notify._nonblock_event.isSet())




More information about the bind10-changes mailing list