M2Crypto-0.17 blocks python threads?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • reizes@gmail.com

    #1

    M2Crypto-0.17 blocks python threads?

    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.thread ing.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_ne w_thread(echo_h andler, (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.tab lus.com/ST=CA/C=US/
    emailAddress=co nalarm_ca@tablu s.com/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

  • Heikki Toivonen

    #2
    Re: M2Crypto-0.17 blocks python threads?

    reizes@gmail.co m wrote:
    I am having a problem with python threads and M2Crypto. It appears
    the M2Crypto used in multi-thread application blocks other threads
    from running:
    This turned into https://bugzilla.osafoundation.org/show_bug.cgi?id=9401

    Thanks for the report!

    --
    Heikki Toivonen

    Comment

    • John Nagle

      #3
      Re: M2Crypto-0.17 blocks python threads?

      Heikki Toivonen wrote:
      reizes@gmail.co m wrote:
      >
      >>I am having a problem with python threads and M2Crypto. It appears
      >>the M2Crypto used in multi-thread application blocks other threads
      >>from running:
      >
      >
      This turned into https://bugzilla.osafoundation.org/show_bug.cgi?id=9401
      >
      Thanks for the report!
      That helps. I've been getting occasional stalls and timeouts in
      a multithreaded program that can have several M2Crypto operations
      going, and this is probably the explaination.

      John Nagle

      Comment

      Working...