Always close sockets when defuncting connections
Under certain error conditions, this could result in an FD leak for the socket handles. (In my testing, they seemed to eventually be GC'ed and closed, but this behavior is probably not dependable.) Fixes #80
This commit is contained in:
@@ -6,6 +6,8 @@ Bug Fixes
|
||||
---------
|
||||
* Include table indexes in ``KeyspaceMetadata.export_as_string()``
|
||||
* Fix broken token awareness on ByteOrderedPartitioner
|
||||
* Always close socket when defuncting error'ed connections to avoid a potential
|
||||
file descriptor leak
|
||||
|
||||
Other
|
||||
-----
|
||||
|
@@ -173,11 +173,11 @@ class AsyncoreConnection(Connection, asyncore.dispatcher):
|
||||
with _starting_conns_lock:
|
||||
_starting_conns.discard(self)
|
||||
|
||||
# don't leave in-progress operations hanging
|
||||
self.connected_event.set()
|
||||
if not self.is_defunct:
|
||||
self._error_all_callbacks(
|
||||
ConnectionShutdown("Connection to %s was closed" % self.host))
|
||||
# don't leave in-progress operations hanging
|
||||
self.connected_event.set()
|
||||
|
||||
def defunct(self, exc):
|
||||
with self.lock:
|
||||
@@ -194,6 +194,7 @@ class AsyncoreConnection(Connection, asyncore.dispatcher):
|
||||
id(self), self.host, exc)
|
||||
|
||||
self.last_error = exc
|
||||
self.close()
|
||||
self._error_all_callbacks(exc)
|
||||
self.connected_event.set()
|
||||
return exc
|
||||
|
@@ -246,6 +246,7 @@ class LibevConnection(Connection):
|
||||
log.debug("Defuncting connection (%s) to %s: %s", id(self), self.host, exc)
|
||||
|
||||
self.last_error = exc
|
||||
self.close()
|
||||
self._error_all_callbacks(exc)
|
||||
self.connected_event.set()
|
||||
return exc
|
||||
|
Reference in New Issue
Block a user