]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1828] Make code safer in case socket.socket() raises an exception
authorMukund Sivaraman <muks@isc.org>
Thu, 14 Jun 2012 21:22:02 +0000 (02:52 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 14 Jun 2012 21:22:02 +0000 (02:52 +0530)
src/bin/xfrout/xfrout.py.in

index ce7d3b3ea6b4db46acf7d905b98fdabbc8c59466..0a9f1220b261541693a21665cd211113f0dd1b67 100755 (executable)
@@ -798,13 +798,13 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
         '''Check whether the socket file 'sock_file' exists and
         is being used by one running xfrout process. If it is,
         return True, or else return False. '''
-        with socket.socket(socket.AF_UNIX) as sock:
-            try:
+        try:
+            with socket.socket(socket.AF_UNIX) as sock:
                 sock.connect(sock_file)
-            except socket.error as err:
-                return False
-            else:
-                return True
+        except socket.error as err:
+            return False
+        else:
+            return True
 
     def shutdown(self):
         self._write_sock.send(b"shutdown") #terminate the xfrout session thread