All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: xen-devel <xen-devel@lists.xensource.com>
Cc: Ewan Mellor <ewan@xensource.com>
Subject: [PATCH 1/4] Fix Xend's HTTP/1.1 Keep-Alive support
Date: Wed, 14 Jun 2006 14:31:35 -0500	[thread overview]
Message-ID: <44906417.6070606@us.ibm.com> (raw)
In-Reply-To: <44906357.90107@us.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 51 bytes --]

Repost of earlier patch

Regards,

Anthony Liguori

[-- Attachment #2: xend-keep-alive.diff --]
[-- Type: text/plain, Size: 3043 bytes --]

# HG changeset patch
# User anthony@rhesis.austin.ibm.com
# Node ID 9ad475c664bff5e668cebbf864861807583d657d
# Parent  4f1e39ec05d6ec711f9ba4a66a3653ed3e168311
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@us.ibm.com>

diff -r 4f1e39ec05d6 -r 9ad475c664bf tools/python/xen/util/xmlrpclib2.py
--- a/tools/python/xen/util/xmlrpclib2.py	Thu Jun  8 15:51:39 2006
+++ b/tools/python/xen/util/xmlrpclib2.py	Fri Jun  9 23:16:19 2006
@@ -39,6 +39,31 @@
 # httpu:///absolute/path/to/socket.sock
 #
 # 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):
@@ -94,6 +119,10 @@
 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)
         try:
@@ -131,10 +160,10 @@
 # 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]
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  reply	other threads:[~2006-06-14 19:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-14 19:28 [PATCH 0/4] Add support for XML-RPC over SSH (take two) Anthony Liguori
2006-06-14 19:31 ` Anthony Liguori [this message]
2006-06-14 19:32 ` [PATCH 2/4] Add support for an xm serve command Anthony Liguori
2006-06-14 19:33 ` [PATCH 2/4] Client support for XML-RPC over SSH Anthony Liguori
2006-06-14 19:34 ` [PATCH 4/4] Add support for XM_SERVER variable to choose XML-RPC URI Anthony Liguori
2006-06-20  9:26 ` [PATCH 0/4] Add support for XML-RPC over SSH (take two) Ewan Mellor
2006-06-20 12:49   ` Ewan Mellor
2006-06-20 21:07     ` Anthony Liguori
2006-06-21  6:30       ` Ewan Mellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44906417.6070606@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=ewan@xensource.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.