ganeti-noded: Close listening socket in child
authorMichael Hanselmann <hansmi@google.com>
Tue, 25 Aug 2009 15:52:31 +0000 (17:52 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 25 Aug 2009 15:53:14 +0000 (17:53 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/http/server.py

index b3e5b78..d7e374c 100644 (file)
@@ -522,6 +522,16 @@ class HttpServer(http.HttpBase, asyncore.dispatcher):
     if pid == 0:
       # Child process
       try:
+        # The client shouldn't keep the listening socket open. If the parent
+        # process is restarted, it would fail when there's already something
+        # listening (in this case its own child from a previous run) on the
+        # same port.
+        try:
+          self.socket.close()
+        except socket.error:
+          pass
+        self.socket = None
+
         self.request_executor(self, connection, client_addr)
       except Exception:
         logging.exception("Error while handling request from %s:%s",