mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
[XEND] Ignore socket.shutdown() exceptions
Add further comments about why that shutdown() exists. Signed-off-by: Alastair Tse <atse@xensource.com>
This commit is contained in:
1 parent
4b4cd53657
commit
2f8bdad823
2 files changed
+22
-10
No files matched your search
@@ -333,11 +333,15 @@ class HttpServer:
|
||||
def close(self):
|
||||
self.closed = True
|
||||
self.ready = False
|
||||
# shutdown socket explicitly to allow reuse
|
||||
try:
|
||||
self.socket.shutdown(2)
|
||||
except socket.error:
|
||||
pass
|
||||
|
||||
try:
|
||||
# shutdown socket explicitly to allow reuse
|
||||
self.socket.shutdown(socket.SHUT_RDWR)
|
||||
self.socket.close()
|
||||
except:
|
||||
except socket.error:
|
||||
pass
|
||||
|
||||
def getServerAddr(self):
|
||||
|
||||
@@ -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
|
||||
|
||||