Concurrent access by multiple threads and global mutex

荒凉一梦 提交于 2019-12-02 06:45:31

问题


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:


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.



来源:https://stackoverflow.com/questions/35611540/concurrent-access-by-multiple-threads-and-global-mutex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!