mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Fixes for the STM Cube TLS in-memory example for CMSIS RTOS v2.
This commit is contained in:
@ -76,6 +76,9 @@
|
|||||||
/* use non-blocking mode for read/write IO */
|
/* use non-blocking mode for read/write IO */
|
||||||
#define BENCH_USE_NONBLOCK
|
#define BENCH_USE_NONBLOCK
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef RECV_WAIT_TIMEOUT
|
||||||
|
#define RECV_WAIT_TIMEOUT 4000
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Private types/enumerations/variables
|
* Private types/enumerations/variables
|
||||||
@ -539,10 +542,14 @@ static int ServerMemRecv(info_t* info, char* buf, int sz)
|
|||||||
!info->client.done) {
|
!info->client.done) {
|
||||||
osSemaphoreRelease(info->server.mutex);
|
osSemaphoreRelease(info->server.mutex);
|
||||||
#ifdef CMSIS_OS2_H_
|
#ifdef CMSIS_OS2_H_
|
||||||
osThreadFlagsWait(1, osFlagsWaitAny, osWaitForever);
|
if (osThreadFlagsWait(1, osFlagsWaitAny, RECV_WAIT_TIMEOUT) == osFlagsErrorTimeout) {
|
||||||
|
return WOLFSSL_CBIO_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
osSemaphoreAcquire(info->server.mutex, osWaitForever);
|
osSemaphoreAcquire(info->server.mutex, osWaitForever);
|
||||||
#else
|
#else
|
||||||
osSignalWait(1, osWaitForever);
|
if (osSignalWait(1, RECV_WAIT_TIMEOUT) == osEventTimeout) {
|
||||||
|
return WOLFSSL_CBIO_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
osSemaphoreWait(info->server.mutex, osWaitForever);
|
osSemaphoreWait(info->server.mutex, osWaitForever);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -624,10 +631,14 @@ static int ClientMemRecv(info_t* info, char* buf, int sz)
|
|||||||
!info->server.done) {
|
!info->server.done) {
|
||||||
osSemaphoreRelease(info->client.mutex);
|
osSemaphoreRelease(info->client.mutex);
|
||||||
#ifdef CMSIS_OS2_H_
|
#ifdef CMSIS_OS2_H_
|
||||||
osThreadFlagsWait(1, osFlagsWaitAny, osWaitForever);
|
if (osThreadFlagsWait(1, osFlagsWaitAny, RECV_WAIT_TIMEOUT) == osFlagsErrorTimeout) {
|
||||||
|
return WOLFSSL_CBIO_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
osSemaphoreAcquire(info->client.mutex, osWaitForever);
|
osSemaphoreAcquire(info->client.mutex, osWaitForever);
|
||||||
#else
|
#else
|
||||||
osSignalWait(1, osWaitForever);
|
if (osSignalWait(1, RECV_WAIT_TIMEOUT) == osEventTimeout) {
|
||||||
|
return WOLFSSL_CBIO_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
osSemaphoreWait(info->client.mutex, osWaitForever);
|
osSemaphoreWait(info->client.mutex, osWaitForever);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -936,6 +947,9 @@ static void client_thread(const void* args)
|
|||||||
int ret;
|
int ret;
|
||||||
info_t* info = (info_t*)args;
|
info_t* info = (info_t*)args;
|
||||||
|
|
||||||
|
#ifdef CMSIS_OS2_H_
|
||||||
|
info->client.threadId = osThreadGetId();
|
||||||
|
#endif
|
||||||
do {
|
do {
|
||||||
ret = bench_tls_client(info);
|
ret = bench_tls_client(info);
|
||||||
|
|
||||||
@ -949,13 +963,14 @@ static void client_thread(const void* args)
|
|||||||
}
|
}
|
||||||
info->client.ret = ret;
|
info->client.ret = ret;
|
||||||
info->client.done = 1;
|
info->client.done = 1;
|
||||||
osThreadSuspend(NULL);
|
osThreadSuspend(info->client.threadId);
|
||||||
|
|
||||||
if (info->doShutdown)
|
if (info->doShutdown)
|
||||||
info->client.done = 1;
|
info->client.done = 1;
|
||||||
} while (!info->doShutdown);
|
} while (!info->doShutdown);
|
||||||
|
|
||||||
osThreadTerminate(info->client.threadId);
|
osThreadTerminate(info->client.threadId);
|
||||||
|
info->client.threadId = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bench_tls_server(info_t* info)
|
static int bench_tls_server(info_t* info)
|
||||||
@ -1207,6 +1222,9 @@ static void server_thread(const void* args)
|
|||||||
int ret;
|
int ret;
|
||||||
info_t* info = (info_t*)args;
|
info_t* info = (info_t*)args;
|
||||||
|
|
||||||
|
#ifdef CMSIS_OS2_H_
|
||||||
|
info->server.threadId = osThreadGetId();
|
||||||
|
#endif
|
||||||
do {
|
do {
|
||||||
ret = bench_tls_server(info);
|
ret = bench_tls_server(info);
|
||||||
|
|
||||||
@ -1220,13 +1238,14 @@ static void server_thread(const void* args)
|
|||||||
}
|
}
|
||||||
info->server.ret = ret;
|
info->server.ret = ret;
|
||||||
info->server.done = 1;
|
info->server.done = 1;
|
||||||
osThreadSuspend(NULL);
|
osThreadSuspend(info->server.threadId);
|
||||||
|
|
||||||
if (info->doShutdown)
|
if (info->doShutdown)
|
||||||
info->server.done = 1;
|
info->server.done = 1;
|
||||||
} while (!info->doShutdown);
|
} while (!info->doShutdown);
|
||||||
|
|
||||||
osThreadTerminate(info->server.threadId);
|
osThreadTerminate(info->server.threadId);
|
||||||
|
info->server.threadId = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CMSIS_OS2_H_
|
#ifdef CMSIS_OS2_H_
|
||||||
@ -1343,7 +1362,7 @@ int bench_tls(void* args)
|
|||||||
/* start threads */
|
/* start threads */
|
||||||
if (info->server.threadId == 0) {
|
if (info->server.threadId == 0) {
|
||||||
#ifdef CMSIS_OS2_H_
|
#ifdef CMSIS_OS2_H_
|
||||||
info->server.threadId = osThreadNew(server_thread, info, &server_thread_attributes);
|
osThreadNew(server_thread, info, &server_thread_attributes);
|
||||||
#else
|
#else
|
||||||
info->server.threadId = osThreadCreate(&info->server.threadDef, info);
|
info->server.threadId = osThreadCreate(&info->server.threadDef, info);
|
||||||
#endif
|
#endif
|
||||||
@ -1353,7 +1372,7 @@ int bench_tls(void* args)
|
|||||||
}
|
}
|
||||||
if (info->client.threadId == 0) {
|
if (info->client.threadId == 0) {
|
||||||
#ifdef CMSIS_OS2_H_
|
#ifdef CMSIS_OS2_H_
|
||||||
info->client.threadId = osThreadNew(client_thread, info, &client_thread_attributes);
|
osThreadNew(client_thread, info, &client_thread_attributes);
|
||||||
#else
|
#else
|
||||||
info->client.threadId = osThreadCreate(&info->client.threadDef, info);
|
info->client.threadId = osThreadCreate(&info->client.threadDef, info);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user