Fix issues found by -fsanitize=thread.

This commit is contained in:
Kareem Abuobeid
2020-09-30 14:21:00 -07:00
parent 20d28e1b65
commit d59784e646
3 changed files with 22 additions and 7 deletions

View File

@ -1099,7 +1099,17 @@ static void* DoMonitor(void* arg)
}
if (FD_ISSET(crl->mfd, &readfds)) {
word64 r64;
int rlen;
WOLFSSL_MSG("got custom shutdown event, breaking out");
/* read out the bytes written to the event to clean up */
rlen = (int) read(crl->mfd, &r64, sizeof(r64));
if (rlen < 0) {
WOLFSSL_MSG("read custom event failure");
}
break;
}

View File

@ -27490,10 +27490,11 @@ static void test_wolfSSL_either_side(void)
XMEMSET(&client_cb, 0, sizeof(callback_functions));
XMEMSET(&server_cb, 0, sizeof(callback_functions));
/* Use same CTX for both client and server */
/* Use different CTX for client and server */
client_cb.ctx = wolfSSL_CTX_new(wolfSSLv23_method());
AssertNotNull(client_cb.ctx);
server_cb.ctx = client_cb.ctx;
server_cb.ctx = wolfSSL_CTX_new(wolfSSLv23_method());
AssertNotNull(server_cb.ctx);
/* we are responsible for free'ing WOLFSSL_CTX */
server_cb.isSharedCtx = client_cb.isSharedCtx = 1;
@ -27511,6 +27512,7 @@ static void test_wolfSSL_either_side(void)
#endif
wolfSSL_CTX_free(client_cb.ctx);
wolfSSL_CTX_free(server_cb.ctx);
FreeTcpReady(&ready);
#ifndef SINGLE_THREADED
@ -27558,10 +27560,11 @@ static void test_wolfSSL_DTLS_either_side(void)
XMEMSET(&client_cb, 0, sizeof(callback_functions));
XMEMSET(&server_cb, 0, sizeof(callback_functions));
/* Use same CTX for both client and server */
/* Use different CTX for client and server */
client_cb.ctx = wolfSSL_CTX_new(wolfDTLS_method());
AssertNotNull(client_cb.ctx);
server_cb.ctx = client_cb.ctx;
server_cb.ctx = wolfSSL_CTX_new(wolfDTLS_method());
AssertNotNull(server_cb.ctx);
/* we are responsible for free'ing WOLFSSL_CTX */
server_cb.isSharedCtx = client_cb.isSharedCtx = 1;
@ -27579,6 +27582,7 @@ static void test_wolfSSL_DTLS_either_side(void)
#endif
wolfSSL_CTX_free(client_cb.ctx);
wolfSSL_CTX_free(server_cb.ctx);
FreeTcpReady(&ready);
#ifndef SINGLE_THREADED

View File

@ -836,11 +836,12 @@ WOLFSSL_API int wolfCrypt_Cleanup(void);
#endif
#endif
#if !defined(XGMTIME) && !defined(TIME_OVERRIDES)
#if defined(WOLFSSL_GMTIME) || !defined(HAVE_GMTIME_R) || defined(WOLF_C99)
#define XGMTIME(c, t) gmtime((c))
#else
/* Always use gmtime_r if available. */
#if defined(HAVE_GMTIME_R)
#define XGMTIME(c, t) gmtime_r((c), (t))
#define NEED_TMP_TIME
#else
#define XGMTIME(c, t) gmtime((c))
#endif
#endif
#if !defined(XVALIDATE_DATE) && !defined(HAVE_VALIDATE_DATE)