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] Add support to Xend XML-RPC server for HT

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Add support to Xend XML-RPC server for HTTP/1.1 Keep-Alive.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Jun 2006 15:01:32 +0000
Delivery-date: Tue, 20 Jun 2006 08:03:48 -0700
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 anthony@xxxxxxxxxxxxxxxxxxxxx
# Node ID 0fe87421cc8026fdbb13a5ac85c936fd951d3c0e
# Parent  410c81420109918fa9ebeac3a350a9d13ccf463f
Add support to Xend XML-RPC server for HTTP/1.1 Keep-Alive.

This patch fixes a few bugs in the Python SimpleXMLRPC server and enables
HTTP/1.1 by default.  This allows a client to use Keep-Alive.  Keep-Alive
improves performance by eliminating the overhead of connection setup and,
more importantly, avoids credential caching when executing multiple
commands over a secure connection.

Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>
---
 tools/python/xen/util/xmlrpclib2.py |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)

diff -r 410c81420109 -r 0fe87421cc80 tools/python/xen/util/xmlrpclib2.py
--- a/tools/python/xen/util/xmlrpclib2.py       Mon Jun 19 17:43:04 2006 +0100
+++ b/tools/python/xen/util/xmlrpclib2.py       Tue Jun 20 10:25:18 2006 +0100
@@ -40,6 +40,31 @@ from xen.xend.XendLogging import log
 #
 # It assumes that the RPC handler is /RPC2.  This probably needs to be improved
 
+# We're forced to subclass the RequestHandler class so that we can work around
+# some bugs in Keep-Alive handling and also enabled it by default
+class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
+    protocol_version = "HTTP/1.1"
+
+    # this is inspired by SimpleXMLRPCRequestHandler's do_POST but differs
+    # in a few non-trivial ways
+    # 1) we never generate internal server errors.  We let the exception
+    #    propagate so that it shows up in the Xend debug logs
+    # 2) we don't bother checking for a _dispatch function since we don't
+    #    use one
+    # 3) we never shutdown the connection.  This appears to be a bug in
+    #    SimpleXMLRPCServer.py as it breaks HTTP Keep-Alive
+    def do_POST(self):
+        data = self.rfile.read(int(self.headers["content-length"]))
+        rsp = self.server._marshaled_dispatch(data)
+
+        self.send_response(200)
+        self.send_header("Content-Type", "text/xml")
+        self.send_header("Content-Length", str(len(rsp)))
+        self.end_headers()
+
+        self.wfile.write(rsp)
+        self.wfile.flush()
+
 class HTTPUnixConnection(HTTPConnection):
     def connect(self):
         self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -93,6 +118,10 @@ class ServerProxy(xmlrpclib.ServerProxy)
 
 class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
     allow_reuse_address = True
+
+    def __init__(self, addr, requestHandler=XMLRPCRequestHandler,
+                 logRequests=1):
+        SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests)
 
     def _marshaled_dispatch(self, data, dispatch_method = None):
         params, method = xmlrpclib.loads(data)
@@ -131,10 +160,10 @@ class TCPXMLRPCServer(SocketServer.Threa
 # It implements proper support for allow_reuse_address by
 # unlink()'ing an existing socket.
 
-class UnixXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
+class UnixXMLRPCRequestHandler(XMLRPCRequestHandler):
     def address_string(self):
         try:
-            return SimpleXMLRPCRequestHandler.address_string(self)
+            return XMLRPCRequestHandler.address_string(self)
         except ValueError, e:
             return self.client_address[:2]
 

_______________________________________________
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] Add support to Xend XML-RPC server for HTTP/1.1 Keep-Alive., Xen patchbot-unstable <=