Callback needed to perform locking on shared data structures. From the OpenSSL documentation: OpenSSL uses a number of global data structures that will be implicitly shared whenever multiple threads use OpenSSL. Multi-threaded applications will crash at random if [the locking function] is not set.
| 220 | // Multi-threaded applications will crash at random if [the locking |
| 221 | // function] is not set. |
| 222 | void locking_function(int mode, int n, const char* /*file*/, int /*line*/) |
| 223 | { |
| 224 | if (mode & CRYPTO_LOCK) { |
| 225 | mutexes[n].lock(); |
| 226 | } else { |
| 227 | mutexes[n].unlock(); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | |
| 232 | // OpenSSL callback that returns the current thread ID, necessary for |