[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] More anti-leak work.
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv4914/lib/mixminion
Modified Files:
MMTPClient.py benchmark.py test.py
Log Message:
More anti-leak work.
benchmark, test:
- More code to test tls functionality for leaks.
MMTPServer:
- Try harder to avoid cyclic garbage, so GC has an easier time.
tls.c:
- Kill another leak.
Index: MMTPClient.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/MMTPClient.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- MMTPClient.py 30 May 2003 08:29:45 -0000 1.32
+++ MMTPClient.py 3 Jun 2003 17:28:11 -0000 1.33
@@ -271,6 +271,7 @@
def __init__(self):
self.cache = {}
+
def check(self, tls, targetKeyID, address):
"""Check whether the certificate chain on the TLS connection 'tls'
is valid, current, and matches the keyID 'targetKeyID'. If so,
Index: benchmark.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/benchmark.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- benchmark.py 28 May 2003 06:37:35 -0000 1.36
+++ benchmark.py 3 Jun 2003 17:28:11 -0000 1.37
@@ -849,6 +849,74 @@
n += 1
print n, "sent"
+
+import gc
+import pprint
+
+def testLeaks5_send2():
+ from mixminion.test import _getMMTPServer
+ from mixminion.test import TEST_PORT, _getTLSContext
+ import mixminion.MMTPClient
+
+ #msg = "X" * 32 * 1024
+ n = 0
+ server, listener, messagesIn, keyid = _getMMTPServer(1,port=(TEST_PORT+1))
+ #t = threading.Thread(None, testLeaks5_send,
+ # args=(keyid,))
+ #t.start()
+
+ sending = [0]
+ def sentHook(sending=sending):
+ sending[0]=0
+
+ certcache = mixminion.MMTPClient.PeerCertificateCache()
+
+ print len(gc.get_objects())
+
+ import socket
+
+ context = _getTLSContext(0)
+
+ i = 0
+ while 0:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.setblocking(1)
+ sock.connect(("127.0.0.1", TEST_PORT))
+ tls = _getTLSContext(0).sock(sock)
+ tls.connect()
+ #tls.check_cert_alive()
+ #tls.verify_cert_and_get_identity_pk()
+ #tls.get_peer_cert_pk()
+ certcache.check(tls, keyid, ("127.0.0.1", TEST_PORT))
+ #print certcache.cache
+
+ tls.shutdown()
+ sock.close()
+
+
+
+ while 1:
+ clientcon = mixminion.server.MMTPServer.MMTPClientConnection(
+ _getTLSContext(0), "127.0.0.1", TEST_PORT, keyid,
+ ["X"*(32*1024), "JUNK"], ["z", None],
+ finishedCallback=sentHook, certCache=certcache)
+ clientcon.register(server)
+ i += 1
+ sending[0] = 1
+ print "Sending",i
+ while sending[0]:
+ server.process(0.5)
+
+ #pprint.pprint( clientcon.__dict__ )
+ old = clientcon
+ clientcon = None
+ gc.collect()
+ #print len(certcache.cache)
+ print len(gc.get_objects())
+ print len(server.readers), len(server.writers)
+ print gc.get_referrers(old)
+
+
def testLeaks6():
import socket
p = pk_generate(512)
@@ -904,7 +972,7 @@
#----------------------------------------------------------------------
def timeAll(name, args):
if 1:
- serverQueueTiming()
+ testLeaks5_send()
return
cryptoTiming()
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- test.py 2 Jun 2003 20:55:23 -0000 1.114
+++ test.py 3 Jun 2003 17:28:11 -0000 1.115
@@ -2969,7 +2969,7 @@
keyid = sha1(ident.encode_key(1))
return keyid
-def _getMMTPServer(minimal=0,reject=0):
+def _getMMTPServer(minimal=0,reject=0,port=TEST_PORT):
"""Helper function: create a new MMTP server with a listener connection
Return a tuple of AsyncServer, ListenerConnection, list of received
messages, and keyid."""
@@ -2999,7 +2999,7 @@
if minimal:
conFactory = conFactoryMin
listener = mixminion.server.MMTPServer.ListenConnection("127.0.0.1",
- TEST_PORT, 5, conFactory)
+ port, 5, conFactory)
listener.register(server)
keyid = _getTLSContextKeyID()
@@ -5746,7 +5746,7 @@
tc = loader.loadTestsFromTestCase
if 0:
- suite.addTest(tc(ClientMainTests))
+ suite.addTest(tc(MMTPTests))
return suite
suite.addTest(tc(MiscTests))