-#ifdef HTTP_NEED_OPENSSL_TSL
-/* {{{ */
-static MUTEX_T *http_openssl_tsl = NULL;
-
-static void http_ssl_lock(int mode, int n, const char * file, int line)
-{
- if (mode & CRYPTO_LOCK) {
- tsrm_mutex_lock(http_openssl_tsl[n]);
- } else {
- tsrm_mutex_unlock(http_openssl_tsl[n]);
- }
-}
-
-static ulong http_ssl_id(void)
-{
- return (ulong) tsrm_thread_id();
-}
-
-static inline void http_ssl_init(void)
-{
- int i, c = CRYPTO_num_locks();
-
- http_openssl_tsl = malloc(c * sizeof(MUTEX_T));
-
- for (i = 0; i < c; ++i) {
- http_openssl_tsl[i] = tsrm_mutex_alloc();
- }
-
- CRYPTO_set_id_callback(http_ssl_id);
- CRYPTO_set_locking_callback(http_ssl_lock);
-}
-
-static inline void http_ssl_cleanup(void)
-{
- if (http_openssl_tsl) {
- int i, c = CRYPTO_num_locks();
-
- CRYPTO_set_id_callback(NULL);
- CRYPTO_set_locking_callback(NULL);
-
- for (i = 0; i < c; ++i) {
- tsrm_mutex_free(http_openssl_tsl[i]);
- }
-
- free(http_openssl_tsl);
- http_openssl_tsl = NULL;
- }
-}
-#endif /* HTTP_NEED_OPENSSL_TSL */
-/* }}} */
-
-#ifdef HTTP_NEED_GNUTLS_TSL
-/* {{{ */
-static int http_ssl_mutex_create(void **m)
-{
- if (*((MUTEX_T *) m) = tsrm_mutex_alloc()) {
- return SUCCESS;
- } else {
- return FAILURE;
- }
-}
-
-static int http_ssl_mutex_destroy(void **m)
-{
- tsrm_mutex_free(*((MUTEX_T *) m));
- return SUCCESS;
-}
-
-static int http_ssl_mutex_lock(void **m)
-{
- return tsrm_mutex_lock(*((MUTEX_T *) m));
-}
-
-static int http_ssl_mutex_unlock(void **m)
-{
- return tsrm_mutex_unlock(*((MUTEX_T *) m));
-}
-
-static struct gcry_thread_cbs http_gnutls_tsl = {
- GCRY_THREAD_OPTIONS_USER,
- NULL,
- http_ssl_mutex_create,
- http_ssl_mutex_destroy,
- http_ssl_mutex_lock,
- http_ssl_mutex_unlock
-};
-
-static inline void http_ssl_init(void)
-{
- gcry_control(GCRYCTL_SET_THREAD_CBS, &http_gnutls_tsl);
-}
-
-static inline void http_ssl_cleanup(void)
-{
- return;
-}
-#endif /* HTTP_NEED_GNUTLS_TSL */
-/* }}} */
-