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] [XEND] Ignore socket.shutdown() exception

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEND] Ignore socket.shutdown() exceptions
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 26 Jan 2007 05:35:12 -0800
Delivery-date: Fri, 26 Jan 2007 05:36:08 -0800
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 Alastair Tse <atse@xxxxxxxxxxxxx>
# Date 1169736756 0
# Node ID 0843e4261753c3d2d99d7e5163491ccee1dc33a3
# Parent  2a9b6b1f848f6aa4f01fbaa5daccf982f75c56d4
[XEND] Ignore socket.shutdown() exceptions

Add further comments about why that shutdown() exists.

Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx>
---
 tools/python/xen/web/httpserver.py           |   12 ++++++++----
 tools/python/xen/xend/server/XMLRPCServer.py |   22 +++++++++++++++-------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff -r 2a9b6b1f848f -r 0843e4261753 tools/python/xen/web/httpserver.py
--- a/tools/python/xen/web/httpserver.py        Thu Jan 25 13:05:15 2007 +0000
+++ b/tools/python/xen/web/httpserver.py        Thu Jan 25 14:52:36 2007 +0000
@@ -333,11 +333,15 @@ class HttpServer:
     def close(self):
         self.closed = True
         self.ready = False
-        try:
-            # shutdown socket explicitly to allow reuse
-            self.socket.shutdown(socket.SHUT_RDWR)
+        # shutdown socket explicitly to allow reuse
+        try:
+            self.socket.shutdown(2)
+        except socket.error:
+            pass
+
+        try:
             self.socket.close()
-        except:
+        except socket.error:
             pass
 
     def getServerAddr(self):
diff -r 2a9b6b1f848f -r 0843e4261753 
tools/python/xen/xend/server/XMLRPCServer.py
--- a/tools/python/xen/xend/server/XMLRPCServer.py      Thu Jan 25 13:05:15 
2007 +0000
+++ b/tools/python/xen/xend/server/XMLRPCServer.py      Thu Jan 25 14:52:36 
2007 +0000
@@ -188,14 +188,22 @@ class XMLRPCServer:
 
     def cleanup(self):
         log.debug('XMLRPCServer.cleanup()')
-        try:
-            if hasattr(self, 'server'):
-                # shutdown socket explicitly to allow reuse
-                self.server.socket.shutdown(socket.SHUT_RDWR)
+        if hasattr(self, 'server'):
+            try:
+                # This is here to make sure the socket is actually
+                # cleaned up when close() is called. Otherwise
+                # SO_REUSEADDR doesn't take effect. To replicate,
+                # try 'xend reload' and look for EADDRINUSE.
+                #
+                # May be caued by us calling close() outside of
+                # the listen()ing thread.
+                self.server.socket.shutdown(2)
+            except socket.error, e:
+                pass # ignore any socket errors
+            try:
                 self.server.socket.close()
-        except Exception, exn:
-            log.exception(exn)
-            pass
+            except socket.error, e:
+                pass
 
     def shutdown(self):
         self.running = False

_______________________________________________
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] [XEND] Ignore socket.shutdown() exceptions, Xen patchbot-unstable <=