From 7cfa62f6187ddecfdf7149cc501778b66d8cfcc8 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Tue, 23 Mar 2010 20:34:58 +0000 Subject: fixed resource leakage on repeated connection open/close git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@926766 13f79535-47bb-0310-9956-ffa450edef68 --- python/qpid/tests/messaging/endpoints.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'python/qpid/tests/messaging') diff --git a/python/qpid/tests/messaging/endpoints.py b/python/qpid/tests/messaging/endpoints.py index 5d4fc1646b..5888413f2f 100644 --- a/python/qpid/tests/messaging/endpoints.py +++ b/python/qpid/tests/messaging/endpoints.py @@ -20,7 +20,7 @@ # setup, usage, teardown, errors(sync), errors(async), stress, soak, # boundary-conditions, config -import time +import errno, os, time from qpid import compat from qpid.messaging import * from qpid.tests.messaging import Base @@ -48,6 +48,29 @@ class SetupTests(Base): # XXX: should verify that e includes appropriate diagnostic info pass + def use_fds(self): + fds = [] + try: + while True: + fds.append(os.open("/dev/null", os.O_RDONLY)) + except OSError, e: + if e.errno != errno.EMFILE: + raise e + else: + return fds + + def testOpenCloseResourceLeaks(self): + fds = self.use_fds() + try: + for i in range(32): + if fds: os.close(fds.pop()) + for i in xrange(64): + conn = Connection.open(self.broker.host, self.broker.port) + conn.close() + finally: + while fds: + os.close(fds.pop()) + class ConnectionTests(Base): def setup_connection(self): -- cgit v1.2.1