Skip to content

Commit 42fcdbe

Browse files
add thread local storage to error queue buffer and update macro guard on tests
1 parent d5267ae commit 42fcdbe

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎tests/api.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22808,8 +22808,9 @@ static int test_wc_ERR_remove_state(void)
2280822808
ExpectIntEQ(ERR_get_error(), 0);
2280922809
#endif
2281022810

22811-
#if !defined(NO_ERROR_QUEUE) && defined(OPENSSL_EXTRA) && \
22812-
defined(DEBUG_WOLFSSL) && !defined(ERROR_QUEUE_PER_THREAD)
22811+
#if defined(WOLFSSL_HAVE_ERROR_QUEUE) && !defined(NO_ERROR_QUEUE) && \
22812+
defined(OPENSSL_EXTRA) && defined(DEBUG_WOLFSSL) && \
22813+
!defined(ERROR_QUEUE_PER_THREAD)
2281322814
{
2281422815
/* with the global queue the returned file string must not point into
2281522816
* the node, which is freed when the error is removed */

‎wolfcrypt/src/logging.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,10 +1074,11 @@ static void* wc_error_heap;
10741074
* Pointers returned to the caller point here rather than into a node, so a
10751075
* remove or clear from another thread after the mutex is released can not
10761076
* leave the caller with a pointer to freed memory. The contents are only valid
1077-
* until the next peek or pull. Only written with the mutex held and the last
1078-
* byte is never written, so the strings are always terminated. */
1079-
static char wc_errq_file[WOLFSSL_MAX_ERROR_SZ];
1080-
static char wc_errq_reason[WOLFSSL_MAX_ERROR_SZ];
1077+
* until the next peek or pull by the same thread. Only written with the mutex
1078+
* held and the last byte is never written, so the strings are always
1079+
* terminated. */
1080+
static THREAD_LS_T char wc_errq_file[WOLFSSL_MAX_ERROR_SZ];
1081+
static THREAD_LS_T char wc_errq_reason[WOLFSSL_MAX_ERROR_SZ];
10811082

10821083
/* mutex for list operation protection */
10831084
static wolfSSL_Mutex wc_error_mutex WOLFSSL_MUTEX_INITIALIZER_CLAUSE(wc_error_mutex);

0 commit comments

Comments
 (0)