ssl_cache: return the error code for mutex failure

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
This commit is contained in:
Pengyu Lv 2023-03-15 14:37:32 +08:00
parent 744b507866
commit 0b9c012f21
2 changed files with 8 additions and 8 deletions

View File

@ -134,7 +134,7 @@ int mbedtls_ssl_cache_set(void *data,
* *
* \return 0: The cache entry for session with provided ID * \return 0: The cache entry for session with provided ID
* is removed or does not exist. * is removed or does not exist.
* 1: Internal error. * Otherwise: fail.
*/ */
int mbedtls_ssl_cache_remove(void *data, int mbedtls_ssl_cache_remove(void *data,
unsigned char const *session_id, unsigned char const *session_id,

View File

@ -92,8 +92,8 @@ int mbedtls_ssl_cache_get(void *data,
mbedtls_ssl_cache_entry *entry; mbedtls_ssl_cache_entry *entry;
#if defined(MBEDTLS_THREADING_C) #if defined(MBEDTLS_THREADING_C)
if (mbedtls_mutex_lock(&cache->mutex) != 0) { if ((ret = mbedtls_mutex_lock(&cache->mutex)) != 0) {
return 1; return ret;
} }
#endif #endif
@ -114,7 +114,7 @@ int mbedtls_ssl_cache_get(void *data,
exit: exit:
#if defined(MBEDTLS_THREADING_C) #if defined(MBEDTLS_THREADING_C)
if (mbedtls_mutex_unlock(&cache->mutex) != 0) { if (mbedtls_mutex_unlock(&cache->mutex) != 0) {
ret = 1; ret = MBEDTLS_ERR_THREADING_MUTEX_ERROR;
} }
#endif #endif
@ -318,7 +318,7 @@ int mbedtls_ssl_cache_set(void *data,
exit: exit:
#if defined(MBEDTLS_THREADING_C) #if defined(MBEDTLS_THREADING_C)
if (mbedtls_mutex_unlock(&cache->mutex) != 0) { if (mbedtls_mutex_unlock(&cache->mutex) != 0) {
ret = 1; ret = MBEDTLS_ERR_THREADING_MUTEX_ERROR;
} }
#endif #endif
@ -341,8 +341,8 @@ int mbedtls_ssl_cache_remove(void *data,
mbedtls_ssl_cache_entry *prev; mbedtls_ssl_cache_entry *prev;
#if defined(MBEDTLS_THREADING_C) #if defined(MBEDTLS_THREADING_C)
if (mbedtls_mutex_lock(&cache->mutex) != 0) { if ((ret = mbedtls_mutex_lock(&cache->mutex)) != 0) {
return 1; return ret;
} }
#endif #endif
@ -373,7 +373,7 @@ free:
exit: exit:
#if defined(MBEDTLS_THREADING_C) #if defined(MBEDTLS_THREADING_C)
if (mbedtls_mutex_unlock(&cache->mutex) != 0) { if (mbedtls_mutex_unlock(&cache->mutex) != 0) {
ret = 1; ret = MBEDTLS_ERR_THREADING_MUTEX_ERROR;
} }
#endif #endif