From: Zoltan F. <zol...@us...> - 2003-01-09 09:30:18
|
Martin Sjögren wrote: > > > I think I've figured out the problem. > > >>class client: >> def __init__(self): >> self.ctx = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD) >> self.ctx.set_verify(OpenSSL.SSL.VERIFY_PEER, self.verifycb) > > > Using self.verifycb introduces a cyclic reference. > > >> self.ctx.use_privatekey_file(client_kf) >> self.ctx.use_certificate_file(client_cf) >> self.ctx.load_verify_locations(ca_cf) >> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> self.co = OpenSSL.tsafe.Connection(self.ctx, sock) > > > The use of self.ctx here is also cyclic. thanks, i'll give it a try not using class methods/attributes for the context/verifycb. (stupid me, the last thing i would think about were cyclic references). > > >> def verifycb(self, conn, cert, errnum, depth, ok): >> return ok >> >> >>if __name__ == '__main__': >> time.sleep(5) >> for i in range(10000): >> print i >> clt = client() >> clt.co.close() >> del clt.ctx >> del clt.co >> time.sleep(10) >> i'll also try to modify the simple server to avoid the leak. what hardware do you use for the test? maybe (i hope) you do not see the leak because the server do not serve as many clients within a few minutes to make it visible. i'll try it with a fixed number (a few thousands) of clients connecting, and send the results. thanks, zoltan |