Next: , Previous: Preparation, Up: How to use GnuTLS in applications


7.2 Multi-threaded applications

Although the GnuTLS library is thread safe by design, some parts of the crypto backend, such as the random generator, are not. Since libgcrypt 1.1.92 there was an automatic detection of the thread library used by the application, so most applications wouldn't need to do any changes to ensure thread-safety. Due to the unportability of the automatic thread detection, this was removed from later releases of libgcrypt, so applications have now to register callback functions to ensure proper locking in sensitive parts of libgcrypt.

There are helper macros to help you properly initialize the libraries. Examples are shown below.