Source
/* variable for passing information from callback functions if PSK was found among host PSKs or autoregistration PSK */
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/* for OpenSSL 1.0.1/1.0.2 (before 1.1.0) or LibreSSL */
/* mutexes for multi-threaded OpenSSL (see "man 3ssl threads" and example in crypto/threads/mttest.c) */
typedef zbx_mutex_t tls_mutex_t;
int tls_mutex_create(tls_mutex_t *mutex, char **error)
{
return zbx_mutex_create(mutex, NULL, &error))
}
void tls_mutex_destroy(tls_mutex_t *mutex)
{
zbx_mutex_destroy(mutex);
}
void tls_mutex_lock(tls_mutex_t mutex)
{
zbx_mutex_lock(mutex);
}
void tls_mutex_unlock(tls_mutex_t mutex)
{
zbx_mutex_unlock(mutex);
}
typedef pthread_mutex_t * tls_mutex_t;
int tls_mutex_create(tls_mutex_t *mutex, char **error)
{
*mutex = (pthread_mutex_t *)zbx_malloc(NULL, sizeof(pthread_mutex_t));
if (0 != pthread_mutex_init(*mutex, NULL))
{
*error = zbx_dsprintf(*error, "cannot create mutex: %s", zbx_strerror(errno));
return FAIL;
}
return SUCCEED;
}
void tls_mutex_destroy(tls_mutex_t *mutex)
{
pthread_mutex_destroy(*mutex);
zbx_free(*mutex);
}
void tls_mutex_lock(tls_mutex_t mutex)
{
pthread_mutex_lock(mutex);
}