Concurrent access by multiple threads and global m

2019-03-02 11:46发布

The OpenSSL FAQ states that it can be used in threaded applications:

1. Is OpenSSL thread-safe?

Provided an application sets up the thread callback functions, the answer is yes.

This callback functions refers to a global SSL-lock, thus if you have 2 ssl connections running these will both use this global lock.

However the FAQ continues:

There are limitations; for example, an SSL connection cannot be used concurrently by multiple threads. This is true for most OpenSSL objects.

This indicates that an additional mutex is needed for every SSL-connection. Is this correct? Or do I not need the additional mutex for every SSL-connection?

1条回答
霸刀☆藐视天下
2楼-- · 2019-03-02 12:23

It means that if your connection is shared by multiple threads, you need to have a mutex to avoid them all manipulating the connection at the same time.

As long as any single connection is only used by one thread at a time (which in most applications is the normal case), you don't need any further locking.

查看更多
登录 后发表回答