From f1b23c8077593334ec8bc94fcb40287b7d31f7a5 Mon Sep 17 00:00:00 2001 From: Eric Windisch Date: Sun, 13 Jan 2013 14:11:49 -0500 Subject: [PATCH] Fix zmq socket.close() with eventlet 0.9.17 A bug/change in eventlet 0.9.17 blocks the kwargs from close() from passing through to pyzmq. As this code was only explicitly passing defaults, no argument is necessary. This addresses file descriptor leaks reported in bug 1099185. This bug does not affect installations with eventlet<=0.9.16 The code will now log an error if a socket cannot be closed. Change-Id: Id438dab9744042328b7fac44693d02e116d8c1d9 --- openstack/common/rpc/impl_zmq.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py index d595212b1..c5f37c1bc 100644 --- a/openstack/common/rpc/impl_zmq.py +++ b/openstack/common/rpc/impl_zmq.py @@ -185,11 +185,15 @@ def close(self): pass self.subscriptions = [] - # Linger -1 prevents lost/dropped messages try: - self.sock.close(linger=-1) + # Default is to linger + self.sock.close() except Exception: - pass + # While this is a bad thing to happen, + # it would be much worse if some of the code calling this + # were to fail. For now, lets log, and later evaluate + # if we can safely raise here. + LOG.error("ZeroMQ socket could not be closed.") self.sock = None def recv(self):