[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] The HTTP service used for SEXPR based RPC calls currently serializes all



# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID c287052a0a654a74153f176fbd8159cb1d75211b
# Parent  60bbcf799384d779c2a561b9d9ba30f28e31d970
The HTTP service used for SEXPR based RPC calls currently serializes all
incoming client requests. Since some requests can take non-trivial time
blocking out other clients in this way has bad consequences. The attached
patch makes XenD spawn a new thread to handle each incoming HTTP request.
This same approach is already taken in the XML-RPC service in XenD so I
don't anticipate any multi-thread issues (at least none which don't already
exist).

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tools/python/xen/web/httpserver.py |   44 +++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 16 deletions(-)

diff -r 60bbcf799384 -r c287052a0a65 tools/python/xen/web/httpserver.py
--- a/tools/python/xen/web/httpserver.py        Thu Dec 07 11:52:26 2006 +0000
+++ b/tools/python/xen/web/httpserver.py        Thu Dec 07 12:07:53 2006 +0000
@@ -264,7 +264,32 @@ class HttpServerRequest(http.HttpRequest
             s += x + "/"
             self.write(' <a href="%s">%s</a>/' % (s, x))
         self.write("</h1>")
-        
+
+class HttpServerClient:
+
+    def __init__(self, server, sock, addr):
+        self.server = server
+        self.sock = sock
+        self.addr = addr
+
+    def process(self):
+        thread = threading.Thread(target=self.doProcess)
+        thread.setDaemon(True)
+        thread.start()
+
+    def doProcess(self):
+        try:
+            rp = RequestProcessor(self.server, self.sock, self.addr)
+            rp.process()
+        except SystemExit:
+            raise
+        except Exception, ex:
+            print 'HttpServer>processRequest> exception: ', ex
+            try:
+                self.sock.close()
+            except:
+                pass
+
 class HttpServer:
 
     backlog = 5
@@ -286,8 +311,8 @@ class HttpServer:
 
         while not self.closed:
             (sock, addr) = self.accept()
-            self.processRequest(sock, addr)
-
+            cl = HttpServerClient(self, sock, addr)
+            cl.process()
 
     def stop(self):
         self.close()
@@ -313,19 +338,6 @@ class HttpServer:
             self.socket.close()
         except:
             pass
-
-    def processRequest(self, sock, addr):
-        try:
-            rp = RequestProcessor(self, sock, addr)
-            rp.process()
-        except SystemExit:
-            raise
-        except Exception, ex:
-            print 'HttpServer>processRequest> exception: ', ex
-            try:
-                sock.close()
-            except:
-                pass
 
     def getServerAddr(self):
         return (socket.gethostname(), self.port)

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.