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@redhat.com>
This commit is contained in:
Ewan Mellor committed 2006-12-07 12:07:53 +00:00
1 parent 0bbc8c5421
commit 09ddbb1ce5
1 file changed
+28 -16
+28 -16
View File
@@ -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()
@@ -314,19 +339,6 @@ class HttpServer:
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)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.