M2Crypto-0.17 blocks python threads?

R

reizes

I am having a problem with python threads and M2Crypto. It appears
the M2Crypto used in multi-thread application blocks other threads
from running:

Environment: Linux 2.6 (centos 5.0), OpenSSL 0.9.8b, M2Crypto-0.17

I am using echod-thread.py and echo.py as test vehicles.

Start up echod-thread.py
Connect with echo.py - everything looks ok, but connect with second
echo.py and notice that the server does not respond until after the
first echo session is terminated. And yes, echod-thread.py does call
M2Crypto.threading.init()

So my questions are has anyone seen this kind of threading behavior?
If so how did you fix it?

(NOTE: This used to work with old M2Crytpo-0.13)

I edited a version of the server to print some debug messages. Around
the main server loop:

while 1:
print "#### waiting for connection on port 9999"
conn, addr = sock.accept()
thread.start_new_thread(echo_handler, (ctx, conn, addr))
print "#### started thread, main thread sleeping for 2
seconds"
time.sleep(2) # give first session time to start

[tablus@belgrade ssl]$ python echod-thread.py
#### waiting for connection on port 9999
#### started thread, main thread sleeping for 2 seconds
<NOTE: main thread does not continue until thread started with first
echo session terminates!>

< first echo session thread -- works ok>
[tablus@belgrade ssl]$ python echo.py -h belgrade.tablus.com
LOOP: SSL connect: before/connect initialization
LOOP: SSL connect: SSLv3 write client hello A
LOOP: SSL connect: SSLv3 read server hello A
LOOP: SSL connect: SSLv3 read server certificate A
LOOP: SSL connect: SSLv3 read server key exchange A
LOOP: SSL connect: SSLv3 read server done A
LOOP: SSL connect: SSLv3 write client key exchange A
LOOP: SSL connect: SSLv3 write change cipher spec A
LOOP: SSL connect: SSLv3 write finished A
LOOP: SSL connect: SSLv3 flush data
LOOP: SSL connect: SSLv3 read finished A
INFO: SSL connect: SSL negotiation finished successfully
Host = belgrade.tablus.com
Cipher = DHE-RSA-AES256-SHA
Server = /CN=belgrade.tablus.com/ST=CA/C=US/
[email protected]/O=Root Certification Authority
Ye Newe Threading Echo Servre
Echo this
Echo this

< second echo session thread -- hangs waiting for server to respond
until first session exits>
[tablus@belgrade ssl]$ python echo.py -h belgrade.tablus.com
LOOP: SSL connect: before/connect initialization
LOOP: SSL connect: SSLv3 write client hello A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top