From 44ab2143089ac020f4b377f432e20a383f5a757f Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 20 Oct 2023 13:58:33 -0700 Subject: [PATCH] Threading Fix 1. The wolfSSL version number to check for the old threading code was v5.5.2, not v5.5.1. 2. A new wrapper was introduced around return for threading in what will be wolfSSL v5.6.4. Added that wrapper if it didn't exist. 3. Some other types for threading are added in v5.6.4, wolfSSH needs to use the old threading model if using wolfSSL v5.6.3. --- wolfssh/test.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wolfssh/test.h b/wolfssh/test.h index b4db3b4d5..975be13a5 100644 --- a/wolfssh/test.h +++ b/wolfssh/test.h @@ -887,6 +887,8 @@ static INLINE void WaitTcpReady(func_args* args) #endif /* WOLFSSH_TEST_LOCKING */ +#include +#include #include /* @@ -899,10 +901,11 @@ static INLINE void WaitTcpReady(func_args* args) * used by the examples to define themselves for use as threads by the test * tools, but they themselves do not use threading. */ -#define WOLFSSL_V5_5_1 0x05005001 +#define WOLFSSL_V5_5_2 0x05005002 +#define WOLFSSL_V5_6_4 0x05006004 -#if (LIBWOLFSSL_VERSION_HEX < WOLFSSL_V5_5_1) && !defined(WOLFSSL_THREAD) - #define WOLFSSH_OLD_THREADING +#if (LIBWOLFSSL_VERSION_HEX < WOLFSSL_V5_5_2) && !defined(WOLFSSL_THREAD) + #define WOLFSSH_OLDER_THREADING #ifdef SINGLE_THREADED typedef unsigned int THREAD_RETURN; typedef void* THREAD_TYPE; @@ -927,11 +930,17 @@ static INLINE void WaitTcpReady(func_args* args) #define WOLFSSH_THREAD WOLFSSL_THREAD #endif +#if (LIBWOLFSSL_VERSION_HEX < WOLFSSL_V5_6_4) \ + && !defined(WOLFSSL_RETURN_FROM_THREAD) + #define WOLFSSL_RETURN_FROM_THREAD(x) return (THREAD_RETURN)(x) + #define WOLFSSH_OLD_THREADING +#endif + #ifdef WOLFSSH_TEST_THREADING -#ifndef WOLFSSH_OLD_THREADING +#if !defined(WOLFSSH_OLD_THREADING) && !defined(WOLFSSH_OLDER_THREADING) static INLINE void ThreadStart(THREAD_CB fun, void* args, THREAD_TYPE* thread) {