Return codes and missed srtp.

This commit is contained in:
David Garske
2023-08-08 13:58:38 -07:00
parent 39f632d096
commit c7b6fa2931
2 changed files with 20 additions and 14 deletions

View File

@ -3705,7 +3705,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
if (pthread_mutex_init(&cond->mutex, NULL) != 0)
return MEMORY_E;
if (pthread_cond_init(&cond->cond, NULL) != 0) {
pthread_mutex_destroy(&cond->mutex);
(void)pthread_mutex_destroy(&cond->mutex);
return MEMORY_E;
}
return 0;
@ -3716,8 +3716,8 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
if (cond == NULL)
return BAD_FUNC_ARG;
pthread_mutex_destroy(&cond->mutex);
pthread_cond_destroy(&cond->cond);
(void)pthread_mutex_destroy(&cond->mutex);
(void)pthread_cond_destroy(&cond->cond);
return 0;
}
@ -3726,10 +3726,12 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
if (cond == NULL)
return BAD_FUNC_ARG;
pthread_mutex_lock(&cond->mutex);
pthread_cond_signal(&cond->cond);
pthread_mutex_unlock(&cond->mutex);
return 0;
if (pthread_mutex_lock(&cond->mutex) == 0) {
(void)pthread_cond_signal(&cond->cond);
(void)pthread_mutex_unlock(&cond->mutex);
return 0;
}
return BAD_MUTEX_E;
}
int wolfSSL_CondWait(COND_TYPE* cond)
@ -3737,10 +3739,12 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
if (cond == NULL)
return BAD_FUNC_ARG;
pthread_mutex_lock(&cond->mutex);
pthread_cond_wait(&cond->cond, &cond->mutex);
pthread_mutex_unlock(&cond->mutex);
return 0;
if (pthread_mutex_lock(&cond->mutex) == 0) {
(void)pthread_cond_wait(&cond->cond, &cond->mutex);
(void)pthread_mutex_unlock(&cond->mutex);
return 0;
}
return BAD_MUTEX_E;
}
#else
/* Apple style dispatch semaphore */

View File

@ -691,10 +691,12 @@ static WC_INLINE void srtp_helper_init(srtp_test_helper *srtp)
static WC_INLINE void srtp_helper_get_ekm(srtp_test_helper *srtp,
uint8_t **ekm, size_t *size)
{
if (srtp->server_srtp_ekm == NULL)
THREAD_CHECK_RET(wolfSSL_CondWait(&srtp->cond, &srtp->mutex));
THREAD_CHECK_RET(wc_LockMutex(&srtp->mutex));
if (srtp->server_srtp_ekm == NULL) {
THREAD_CHECK_RET(wc_UnLockMutex(&srtp->mutex));
THREAD_CHECK_RET(wolfSSL_CondWait(&srtp->cond));
THREAD_CHECK_RET(wc_LockMutex(&srtp->mutex));
}
*ekm = srtp->server_srtp_ekm;
*size = srtp->server_srtp_ekm_size;