]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[433] Use a local variable rather than one larger in scope
authorKean Johnston <kean@isc.org>
Thu, 24 Oct 2013 15:49:06 +0000 (17:49 +0200)
committerKean Johnston <kean@isc.org>
Thu, 24 Oct 2013 16:08:48 +0000 (18:08 +0200)
As per review, don't use self._session for the check to see if there is
an existing message queue running. Rather, use a localally scoped
variable that will get cleaned up when the function exits.

src/bin/msgq/msgq.py.in

index a28d97eaa4b23a03e6a487fe1f5bc78debc0b9da..7346f7edd054663425a2568557d676672a85ceec 100755 (executable)
@@ -275,16 +275,14 @@ class MsgQ:
             # connect to the existing socket to see if there is an existing
             # msgq running. Only if that fails do we remove the file and
             # attempt to create a new socket.
-            existing_msgq = True
+            existing_msgq = None
             try:
-                self._session = isc.cc.Session(self.socket_file)
+                existing_msgq = isc.cc.Session(self.socket_file)
             except isc.cc.session.SessionError:
-                existing_msgq = False
-
-            self._session.close()
-            self._session = None
+                existing_msgq = None
 
             if existing_msgq:
+                existing_msgq.close()
                 logger.fatal(MSGQ_ALREADY_RUNNING)
                 raise MsgQRunningError("b10-msgq already running")