Parcourir la source

Revert "[1828] Make code safer in case socket.socket() raises an exception"

This reverts commit e295b40a31dedb3671705ab44c2683624f3d541c.
Mukund Sivaraman il y a 13 ans
Parent
commit
1fafcf498b
1 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 6 6
      src/bin/xfrout/xfrout.py.in

+ 6 - 6
src/bin/xfrout/xfrout.py.in

@@ -804,13 +804,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. '''
-        try:
-            with socket.socket(socket.AF_UNIX) as sock:
+        with socket.socket(socket.AF_UNIX) as sock:
+            try:
                 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