WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Close the server when instructed, so that

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Close the server when instructed, so that we can reload on the same port, and
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 04 Dec 2006 21:50:16 +0000
Delivery-date: Mon, 04 Dec 2006 13:49:57 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID 565cd8f32c70da8ae7dbaaeb9dff28aa8b6307e1
# Parent  3629873ee1e607f8e803ba674c387e7850757269
Close the server when instructed, so that we can reload on the same port, and
diagnose a server that fails to start.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/server/XMLRPCServer.py |   40 +++++++++++++++++----------
 1 files changed, 26 insertions(+), 14 deletions(-)

diff -r 3629873ee1e6 -r 565cd8f32c70 
tools/python/xen/xend/server/XMLRPCServer.py
--- a/tools/python/xen/xend/server/XMLRPCServer.py      Mon Dec 04 13:56:27 
2006 +0000
+++ b/tools/python/xen/xend/server/XMLRPCServer.py      Mon Dec 04 13:57:18 
2006 +0000
@@ -16,6 +16,8 @@
 # Copyright (C) 2006 XenSource Ltd.
 #============================================================================
 
+import errno
+import socket
 import types
 import xmlrpclib
 from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
@@ -105,20 +107,25 @@ class XMLRPCServer:
                    "; authentication has been disabled for this server." or
                    ".")
 
-        if self.use_tcp:
-            log.info("Opening TCP XML-RPC server on %s%d%s",
-                     self.host and '%s:' % self.host or
-                     'all interfaces, port ',
-                     self.port, authmsg)
-            self.server = TCPXMLRPCServer((self.host, self.port),
-                                          self.hosts_allowed,
-                                          logRequests = False)
-        else:
-            log.info("Opening Unix domain socket XML-RPC server on %s%s",
-                     self.path, authmsg)
-            self.server = UnixXMLRPCServer(self.path, self.hosts_allowed,
-                                           logRequests = False)
-
+        try:
+            if self.use_tcp:
+                log.info("Opening TCP XML-RPC server on %s%d%s",
+                         self.host and '%s:' % self.host or
+                         'all interfaces, port ',
+                         self.port, authmsg)
+                self.server = TCPXMLRPCServer((self.host, self.port),
+                                              self.hosts_allowed,
+                                              logRequests = False)
+            else:
+                log.info("Opening Unix domain socket XML-RPC server on %s%s",
+                         self.path, authmsg)
+                self.server = UnixXMLRPCServer(self.path, self.hosts_allowed,
+                                               logRequests = False)
+        except socket.error, exn:
+            log.error('Cannot start server: %s!', exn.args[1])
+            ready = True
+            running = False
+            return
 
         # Register Xen API Functions
         # -------------------------------------------------------------------
@@ -177,6 +184,11 @@ class XMLRPCServer:
 
     def cleanup(self):
         log.debug("XMLRPCServer.cleanup()")
+        try:
+            self.server.socket.close()
+        except Exception, exn:
+            log.exception(exn)
+            pass
 
     def shutdown(self):
         self.running = False

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Close the server when instructed, so that we can reload on the same port, and, Xen patchbot-unstable <=