[Commits] (heikki) Use correct threading model for server. Use logging. We get as far as accepting SSL client, but the handshake does not finish.

commits at osafoundation.org commits at osafoundation.org
Thu Apr 8 16:56:58 PDT 2004


Commit by: heikki
Modified files:
osaf/chandler/Chandler/crypto/tests/parcels/pkitest/PKITest.py 1.3 1.4
osaf/chandler/Chandler/crypto/tests/parcels/pkitest/server.py 1.1 1.2

Log message:
Use correct threading model for server. Use logging. We get as far as accepting SSL client, but the handshake does not finish.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/crypto/tests/parcels/pkitest/PKITest.py.diff?r1=text&tr1=1.3&r2=text&tr2=1.4
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/crypto/tests/parcels/pkitest/server.py.diff?r1=text&tr1=1.1&r2=text&tr2=1.2

Index: osaf/chandler/Chandler/crypto/tests/parcels/pkitest/PKITest.py
diff -u osaf/chandler/Chandler/crypto/tests/parcels/pkitest/PKITest.py:1.3 osaf/chandler/Chandler/crypto/tests/parcels/pkitest/PKITest.py:1.4
--- osaf/chandler/Chandler/crypto/tests/parcels/pkitest/PKITest.py:1.3	Thu Apr  8 11:33:22 2004
+++ osaf/chandler/Chandler/crypto/tests/parcels/pkitest/PKITest.py	Thu Apr  8 16:56:27 2004
@@ -46,6 +46,10 @@
 class PKITestView(BoxContainer):
 
     def OnStartStopServerEvent(self, notification):
+        log = logging.getLogger('m2seeder')
+        log.setLevel(logging.INFO)
+        log.info('Start/Stop server called')
+        
         serverPort = Globals.repository.find('//parcels/pkitest/views/PKITestView/ServerPortText')
         wxServerPortText = Globals.association[serverPort.getUUID( )]
         sPort = wxServerPortText.GetValue()
@@ -56,7 +60,11 @@
         sock.bind(('', int(sPort)))
         sock.listen(5)
         conn, addr = sock.accept()
-        thread.start_new_thread(server.server_thread, (ctx, conn, addr))
+
+        log.info('accepted: ' + str(conn) + str(addr))
+        
+        self.server = server.Server(ctx, conn, addr)
+        self.server.start()
 
     def OnConnectDisconnectClientEvent(self, notification):
         ctx = setup_client_ctx()

Index: osaf/chandler/Chandler/crypto/tests/parcels/pkitest/server.py
diff -u osaf/chandler/Chandler/crypto/tests/parcels/pkitest/server.py:1.1 osaf/chandler/Chandler/crypto/tests/parcels/pkitest/server.py:1.2
--- osaf/chandler/Chandler/crypto/tests/parcels/pkitest/server.py:1.1	Thu Apr  8 11:33:22 2004
+++ osaf/chandler/Chandler/crypto/tests/parcels/pkitest/server.py	Thu Apr  8 16:56:27 2004
@@ -1,6 +1,7 @@
 from M2Crypto import SSL, Rand, threading
-import thread
+import threading
 from socket import *
+import logging
 
 verbose_debug = 1
 
@@ -61,18 +62,31 @@
         return 1
     return 0
 
-def server_thread(ctx, sock, addr):
-    conn = SSL.Connection(ctx, sock)
-    conn.setup_addr(addr)
-    conn.set_accept_state()
-    conn.setup_ssl()
-    conn.accept_ssl()
+class Server(threading.Thread):
+    """
+    SSL server.
+    """
+    def __init__(self, ctx, sock, addr):
+        self.ctx = ctx
+        self.sock = sock
+        self.addr = addr
+
+    def run(self):
+        log = logging.getLogger('sslserver')
+        log.setLevel(logging.INFO)
+        log.info('Accepting SSL client connection:' + str(self.ctx)
+                 + str(self.sock) + str(self.addr))
+        
+        self.conn = SSL.Connection(self.ctx, self.sock)
+        self.conn.setup_addr(self.addr)
+        self.connx.set_accept_state()
+        self.conn.setup_ssl()
+        self.conn.accept_ssl()
+
+        log.info('SSL Connection opened')
+        if do_server_loop(self.conn):
+            self.conn.close()
+        else:
+            self.conn.clear()
+        log.info('SSL Connection closed')
     
-    post_connection_check(conn)
-
-    print 'SSL Connection opened'
-    if do_server_loop(conn):
-        conn.close()
-    else:
-        conn.clear()
-    print 'SSL Connection closed'        



More information about the Commits mailing list