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

[Xen-changelog] [xen-unstable] Do not bother waiting for the old HttpServer and UnixHttpServer threads when



# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID dc1c8ae0a87aadfb6c098ad1e3e81babcc3d09fc
# Parent  b6c6a1efbfaf49a1d999699cb9b7dd1f4b32bf3f
Do not bother waiting for the old HttpServer and UnixHttpServer threads when
shutting down -- they don't have exit handling themselves and ought to just
be made daemon threads.

Added some logging to dialog shutdown problems.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/server/SrvServer.py |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff -r b6c6a1efbfaf -r dc1c8ae0a87a tools/python/xen/xend/server/SrvServer.py
--- a/tools/python/xen/xend/server/SrvServer.py Mon Nov 27 12:00:01 2006 +0000
+++ b/tools/python/xen/xend/server/SrvServer.py Mon Nov 27 12:50:30 2006 +0000
@@ -62,12 +62,14 @@ class XendServers:
 
     def __init__(self):
         self.servers = []
+        self.cleaningUp = False
 
     def add(self, server):
         self.servers.append(server)
 
     def cleanup(self, signum = 0, frame = None):
         log.debug("SrvServer.cleanup()")
+        self.cleaningUp = True
         for server in self.servers:
             try:
                 server.shutdown()
@@ -84,7 +86,9 @@ class XendServers:
         Vifctl.network('start')
         threads = []
         for server in self.servers:
-            thread = Thread(target=server.run)
+            thread = Thread(target=server.run, name=server.__class__.__name__)
+            if isinstance(server, HttpServer):
+                thread.setDaemon(True)
             thread.start()
             threads.append(thread)
 
@@ -117,12 +121,16 @@ class XendServers:
         #   Reason:   The above will cause python signal handlers to be
         #             blocked so we're not able to catch SIGTERM in any
         #             way for cleanup
-        runningThreads = len([t for t in threads if t.isAlive()])
-        while runningThreads > 0:
+        runningThreads = threads
+        while len(runningThreads) > 0:
             try:
                 for t in threads:
                     t.join(1.0)
-                runningThreads = len([t for t in threads if t.isAlive()])
+                runningThreads = [t for t in threads
+                                  if t.isAlive() and not t.isDaemon()]
+                if self.cleaningUp and len(runningThreads) > 0:
+                    log.debug("Waiting for %s." %
+                              [x.getName() for x in runningThreads])
             except:
                 pass
 

_______________________________________________
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®.