[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:
Alastair Tse committed 2007-01-25 14:52:36 +00:00
1 parent 4b4cd53657
commit 2f8bdad823
2 files changed
+22 -10

No files matched your search

+7 -3
View File
@@ -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):
+15 -7
View File
@@ -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
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.