Browse Source

[2225_xfrout] raise again an exception after incrementing the counter

It should raises again an exception after incrementing the counter if it's
raised while initializing ThreadingUnixStreamServer.
Naoki Kambe 12 years ago
parent
commit
67b451a114
2 changed files with 7 additions and 1 deletions
  1. 6 1
      src/bin/xfrout/tests/xfrout_test.py.in
  2. 1 0
      src/bin/xfrout/xfrout.py.in

+ 6 - 1
src/bin/xfrout/tests/xfrout_test.py.in

@@ -1588,7 +1588,12 @@ class TestUnixSockServerForCounter(unittest.TestCase):
                           self.unix._counters.get,
                           'socket', 'unixdomain', 'openfail')
         xfrout.ThreadingUnixStreamServer = DummySocketserverException
-        self.unix = UnixSockServer(None, None, None, None, None)
+        try:
+            self.unix = UnixSockServer(None, None, None, None, None)
+        except Exception:
+            pass
+        else:
+            self.fail("an exception should be raised")
         self.assertEqual(
             self.unix._counters.get('socket', 'unixdomain', 'open'), 1)
         self.assertEqual(

+ 1 - 0
src/bin/xfrout/xfrout.py.in

@@ -665,6 +665,7 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
                                                    handle_class)
         except:
             self._counters.inc('socket', 'unixdomain', 'openfail')
+            raise
         else:
             self._counters.inc('socket', 'unixdomain', 'open')
         self._shutdown_event = shutdown_event