|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] [xen-unstable] [XEND] Ignore socket.shutdown() exception
# 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 <=
|
|
|
|
|