Merge pull request #1777 from dgarske/async_fixes

Build fixes for async
This commit is contained in:
toddouska
2018-08-23 08:23:20 -07:00
committed by GitHub
3 changed files with 38 additions and 38 deletions

View File

@ -6380,7 +6380,7 @@ static int TLSX_KeyShare_ProcessDh(WOLFSSL* ssl, KeyShareEntry* keyShareEntry)
#ifdef WOLFSSL_ASYNC_CRYPT #ifdef WOLFSSL_ASYNC_CRYPT
/* TODO: Make this function non-blocking */ /* TODO: Make this function non-blocking */
if (ret == WC_PENDING_E) { if (ret == WC_PENDING_E) {
ret = wc_AsyncWait(ret, dhKey->asyncDev, WC_ASYNC_FLAG_NONE); ret = wc_AsyncWait(ret, &dhKey->asyncDev, WC_ASYNC_FLAG_NONE);
} }
#endif #endif
/* RFC 8446 Section 7.4.1: /* RFC 8446 Section 7.4.1:

View File

@ -756,71 +756,71 @@ static THREAD_LS_T byte* bench_iv = NULL;
const char* algo, int strength, const char* desc, int doAsync, const char* algo, int strength, const char* desc, int doAsync,
double perfsec, int ret) double perfsec, int ret)
{ {
bench_stats_t* stat; bench_stats_t* bstat;
/* protect bench_stats_head and bench_stats_tail access */ /* protect bench_stats_head and bench_stats_tail access */
pthread_mutex_lock(&bench_lock); pthread_mutex_lock(&bench_lock);
/* locate existing in list */ /* locate existing in list */
for (stat = bench_stats_head; stat != NULL; stat = stat->next) { for (bstat = bench_stats_head; bstat != NULL; bstat = bstat->next) {
/* match based on algo, strength and desc */ /* match based on algo, strength and desc */
if (stat->algo == algo && stat->strength == strength && stat->desc == desc && stat->doAsync == doAsync) { if (bstat->algo == algo && bstat->strength == strength && bstat->desc == desc && bstat->doAsync == doAsync) {
break; break;
} }
} }
if (stat == NULL) { if (bstat == NULL) {
/* allocate new and put on list */ /* allocate new and put on list */
stat = (bench_stats_t*)XMALLOC(sizeof(bench_stats_t), NULL, DYNAMIC_TYPE_INFO); bstat = (bench_stats_t*)XMALLOC(sizeof(bench_stats_t), NULL, DYNAMIC_TYPE_INFO);
if (stat) { if (bstat) {
XMEMSET(stat, 0, sizeof(bench_stats_t)); XMEMSET(bstat, 0, sizeof(bench_stats_t));
/* add to list */ /* add to list */
stat->next = NULL; bstat->next = NULL;
if (bench_stats_tail == NULL) { if (bench_stats_tail == NULL) {
bench_stats_head = stat; bench_stats_head = bstat;
} }
else { else {
bench_stats_tail->next = stat; bench_stats_tail->next = bstat;
stat->prev = bench_stats_tail; bstat->prev = bench_stats_tail;
} }
bench_stats_tail = stat; /* add to the end either way */ bench_stats_tail = bstat; /* add to the end either way */
} }
} }
if (stat) { if (bstat) {
int isLast = 0; int isLast = 0;
stat->type = type; bstat->type = type;
stat->algo = algo; bstat->algo = algo;
stat->strength = strength; bstat->strength = strength;
stat->desc = desc; bstat->desc = desc;
stat->doAsync = doAsync; bstat->doAsync = doAsync;
stat->perfsec += perfsec; bstat->perfsec += perfsec;
stat->finishCount++; bstat->finishCount++;
if (stat->lastRet > ret) if (bstat->lastRet > ret)
stat->lastRet = ret; /* track last error */ bstat->lastRet = ret; /* track last error */
if (stat->finishCount == g_threadCount) { if (bstat->finishCount == g_threadCount) {
isLast = 1; isLast = 1;
} }
pthread_mutex_unlock(&bench_lock); pthread_mutex_unlock(&bench_lock);
/* wait until remaining are complete */ /* wait until remaining are complete */
while (stat->finishCount < g_threadCount) { while (bstat->finishCount < g_threadCount) {
wc_AsyncThreadYield(); wc_AsyncThreadYield();
} }
/* print final stat */ /* print final stat */
if (isLast) { if (isLast) {
if (stat->type == BENCH_STAT_SYM) { if (bstat->type == BENCH_STAT_SYM) {
printf("%-12s%s %8.3f MB/s\n", stat->desc, printf("%-12s%s %8.3f MB/s\n", bstat->desc,
BENCH_ASYNC_GET_NAME(stat->doAsync), stat->perfsec); BENCH_ASYNC_GET_NAME(bstat->doAsync), bstat->perfsec);
} }
else { else {
printf("%-5s %4d %-9s %s %.3f ops/sec\n", printf("%-5s %4d %-9s %s %.3f ops/sec\n",
stat->algo, stat->strength, stat->desc, bstat->algo, bstat->strength, bstat->desc,
BENCH_ASYNC_GET_NAME(stat->doAsync), stat->perfsec); BENCH_ASYNC_GET_NAME(bstat->doAsync), bstat->perfsec);
} }
} }
} }
@ -828,7 +828,7 @@ static THREAD_LS_T byte* bench_iv = NULL;
pthread_mutex_unlock(&bench_lock); pthread_mutex_unlock(&bench_lock);
} }
return stat; return bstat;
} }
#endif /* WOLFSSL_ASYNC_CRYPT && !WC_NO_ASYNC_THREADING */ #endif /* WOLFSSL_ASYNC_CRYPT && !WC_NO_ASYNC_THREADING */
@ -956,11 +956,11 @@ static void bench_stats_asym_finish(const char* algo, int strength,
static WC_INLINE void bench_stats_free(void) static WC_INLINE void bench_stats_free(void)
{ {
#if defined(WOLFSSL_ASYNC_CRYPT) && !defined(WC_NO_ASYNC_THREADING) #if defined(WOLFSSL_ASYNC_CRYPT) && !defined(WC_NO_ASYNC_THREADING)
bench_stats_t* stat; bench_stats_t* bstat;
for (stat = bench_stats_head; stat != NULL; ) { for (bstat = bench_stats_head; bstat != NULL; ) {
bench_stats_t* next = stat->next; bench_stats_t* next = bstat->next;
XFREE(stat, NULL, DYNAMIC_TYPE_INFO); XFREE(bstat, NULL, DYNAMIC_TYPE_INFO);
stat = next; bstat = next;
} }
bench_stats_head = NULL; bench_stats_head = NULL;
bench_stats_tail = NULL; bench_stats_tail = NULL;

View File

@ -1619,9 +1619,9 @@ extern void uITRON4_free(void *p) ;
#define HAVE_WOLF_EVENT #define HAVE_WOLF_EVENT
#ifdef WOLFSSL_ASYNC_CRYPT_TEST #ifdef WOLFSSL_ASYNC_CRYPT_TEST
#define WC_ASYNC_DEV_SIZE 320+24 #define WC_ASYNC_DEV_SIZE 328+24
#else #else
#define WC_ASYNC_DEV_SIZE 320 #define WC_ASYNC_DEV_SIZE 328
#endif #endif
#if !defined(HAVE_CAVIUM) && !defined(HAVE_INTEL_QA) && \ #if !defined(HAVE_CAVIUM) && !defined(HAVE_INTEL_QA) && \