[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] Simple question about multithreading SSL bufferevents.



Hello all,

I am having significant issues with (near immediate) deadlock when trying to send data out a single openssl bufferevent from two separate threads. The individual threads themselves send complete messages with each write. This should present no real problem from a synchronization perspective. In fact, the code works flawlessly when using ordinary bufferevents (not ssl bufferevents).

Are there any known issues with writing to a single openssl bufferevent from multiple threads concurrently? Should I have the expectation of this working, presuming my code is written correctly? I believe I have initialized libevent and openssl correctly for multithreaded execution.

Thanks,
-John


More info, for those interested:

My code fails in the same manner on both OSX and Linux. Both are built with multithreaded libevent/openssl support. (Verified at build time, not programatically. What's a good way to test openssl itself to see if it was built thread safe? I have verified openssl is calling my locking routines with a variety of lock indexes and the like)

I am running:
SSL version: OpenSSL 1.0.1c 10 May 2012
Libevent version: 2.0.21-stable

I have done the following:

1. Initialized openssl per Viega/Messier/Chandra, "Network Security with OpenSSL". (Before using any SSL.)
2. Initialized libevent with evthread_use_pthreads() (Before using any libevent- and verified result)
3. Use option BEV_OPT_THREADSAFE on the bufferevents being created.

And the following, none of which should be required, and none of which helped:

1. Used a global mutex surrounding all calls to libevent.
2. called evbuffer_enable_locking() on both evbuffers associated with the bufferevent.

And verified, for sanity:

1. The shared libraries I am loading are the libraries I expect the system to use.


My server is simply openssl acting as server, using some simple genetated certificates.

I would be happy to share my test code- but it is ~300ish lines due to (primarily) openssl and thread initialization.

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.