BIND 10 trac2252, updated. 31f138b96f8713469feb16ff361e40334ec8b83d [2252] simplify complicated nested try-except statements

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Apr 25 02:44:58 UTC 2013


The branch, trac2252 has been updated
       via  31f138b96f8713469feb16ff361e40334ec8b83d (commit)
       via  4b79543220fa1f81ffaf16bdcfb79845587f51cd (commit)
      from  8544c8e88d5519acf996ef6c4659b75b52ce6839 (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 31f138b96f8713469feb16ff361e40334ec8b83d
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Apr 24 22:21:44 2013 +0900

    [2252] simplify complicated nested try-except statements
    
    get rid of the inner try-except statement, and increment a xfrsuccess and stop
    a timer, or increment a xfrfail counter in the "finally" statement

commit 4b79543220fa1f81ffaf16bdcfb79845587f51cd
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Thu Apr 25 11:27:54 2013 +0900

    [2252] update documentation for the test cases

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

Summary of changes:
 src/bin/xfrin/tests/xfrin_test.py |    8 ++++----
 src/bin/xfrin/xfrin.py.in         |   40 +++++++++++++------------------------
 2 files changed, 18 insertions(+), 30 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/xfrin/tests/xfrin_test.py b/src/bin/xfrin/tests/xfrin_test.py
index 651b266..07d4e4b 100644
--- a/src/bin/xfrin/tests/xfrin_test.py
+++ b/src/bin/xfrin/tests/xfrin_test.py
@@ -2208,8 +2208,8 @@ class TestStatisticsXfrinAXFRv4(TestStatisticsXfrinConn):
 
     def test_axfrreq_xfrsuccess_last_axfr_duration2(self):
         '''tests that axfrreqv4 or axfrreqv6 and xfrsuccess counters
-        and last_axfr_duration timer are incremented even if a successful
-        XfrinZoneUptodate is raised while handling an xfr response'''
+        and last_axfr_duration timer are incremented when raising
+        XfrinZoneUptodate. The exception is treated as success.'''
         def exception_raiser():
             raise XfrinZoneUptodate()
         self.conn._handle_xfrin_responses = exception_raiser
@@ -2257,8 +2257,8 @@ class TestStatisticsXfrinIXFRv4(TestStatisticsXfrinConn):
 
     def test_ixfrreq_xfrsuccess_last_ixfr_duration2(self):
         '''tests that ixfrreqv4 or ixfrreqv6 and xfrsuccess counters
-        and last_ixfr_duration timer are incremented even if a successful
-        XfrinZoneUptodate is raised while handling an xfr response'''
+        and last_ixfr_duration timer are incremented when raising
+        XfrinZoneUptodate. The exception is treated as success.'''
         def exception_raiser():
             raise XfrinZoneUptodate()
         self.conn._handle_xfrin_responses = exception_raiser
diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in
index 4d3a8b8..8610821 100755
--- a/src/bin/xfrin/xfrin.py.in
+++ b/src/bin/xfrin/xfrin.py.in
@@ -968,28 +968,9 @@ class XfrinConnection(asyncore.dispatcher):
             self._counters.inc('zones', self._zone_name.to_text(),
                                req_str.lower() + 'req' +
                                self._get_ipver_str())
-            try:
-                self._send_query(self._request_type)
-                self.__state = XfrinInitialSOA()
-                self._handle_xfrin_responses()
-            except XfrinZoneUptodate:
-                # Note: Catching an exception XfrinZoneUptodate
-                # defines that IXFR succeeded.  xfrsuccess is
-                # incremented and the timer is stopped here.
-                self._counters.inc('zones', self._zone_name.to_text(),
-                                   'xfrsuccess')
-                self._counters.stop_timer('zones', self._zone_name.to_text(),
-                                          'last_' + req_str.lower() +
-                                          '_duration')
-                raise
-            except:
-                # The AXFR or IXFR request failed.
-                self._counters.inc('zones', self._zone_name.to_text(),
-                                   'xfrfail')
-                raise
-            # The AXFR or IXFR request succeeded.
-            self._counters.inc('zones', self._zone_name.to_text(),
-                               'xfrsuccess')
+            self._send_query(self._request_type)
+            self.__state = XfrinInitialSOA()
+            self._handle_xfrin_responses()
             # Depending what data was found, we log different status reports
             # (In case of an AXFR-style IXFR, print the 'AXFR' message)
             if self._transfer_stats.axfr_rr_count == 0:
@@ -1013,10 +994,6 @@ class XfrinConnection(asyncore.dispatcher):
                             "%.3f" % self._transfer_stats.get_running_time(),
                             "%.f" % self._transfer_stats.get_bytes_per_second()
                            )
-            # stop statistics timer
-            self._counters.stop_timer('zones', self._zone_name.to_text(),
-                                      'last_' + req_str.lower() + '_duration')
-
         except XfrinZoneUptodate:
             # Eventually we'll probably have to treat this case as a trigger
             # of trying another primary server, etc, but for now we treat it
@@ -1052,6 +1029,17 @@ class XfrinConnection(asyncore.dispatcher):
                          self.zone_str(), str(e))
             ret = XFRIN_FAIL
         finally:
+            # A xfrsuccess or xfrfail counter is incremented depending on
+            # the result.
+            result = {XFRIN_OK: 'xfrsuccess', XFRIN_FAIL: 'xfrfail'}[ret]
+            self._counters.inc('zones', self._zone_name.to_text(), result)
+            # The started statistics timer is finally stopped only in
+            # a successful case.
+            if ret == XFRIN_OK:
+                self._counters.stop_timer('zones',
+                                          self._zone_name.to_text(),
+                                          'last_' + req_str.lower() +
+                                          '_duration')
             # Make sure any remaining transaction in the diff is closed
             # (if not yet - possible in case of xfr-level exception) as soon
             # as possible



More information about the bind10-changes mailing list