Fixes issue with client-tis-perf and async by splitting read wait and read (async return was waiting again and blocking). Added debug enable option. Cleanup mutex locking around total bytes, so only is done once. Fix for Makefile to include math lib (required for DH pow/log.

pull/31/head
David Garske 2016-11-17 19:15:47 -08:00
parent 7d89c4c424
commit 2e65dafbcc
4 changed files with 22 additions and 10 deletions

4
tls/Makefile 100644 → 100755
View File

@ -1,6 +1,8 @@
CC=gcc
CFLAGS=-Wall
LIBS=-lwolfssl
LIBS=-lwolfssl -lm
DEBUG_FLAGS=-g -DDEBUG
#CFLAGS+=$(DEBUG_FLAGS)
OS_DET=UNKNOWN
CPU_DET=UNKNOWN

12
tls/client-tls-perf.c 100644 → 100755
View File

@ -56,7 +56,7 @@
/* The states of the SSL connection. */
typedef enum SSLState { INIT, CONNECT, WRITE, READ, CLOSE } SSLState;
typedef enum SSLState { INIT, CONNECT, WRITE, READ_WAIT, READ, CLOSE } SSLState;
/* Data for each active connection. */
typedef struct SSLConn {
@ -572,14 +572,16 @@ static int SSLConn_ReadWrite(SSLConn_CTX* ctx, SSLConn* sslConn)
}
if (ret == 1)
sslConn->state = READ;
sslConn->state = READ_WAIT;
break;
case READ:
case READ_WAIT:
ret = TCP_Select(sslConn->sockfd, 0);
if (ret != 1)
break;
sslConn->state = READ;
case READ:
len = ctx->bufferLen;
if (ctx->maxBytes > 0) {
len = min(len, ctx->maxBytes - ctx->totalReadBytes);
@ -675,6 +677,10 @@ static int WolfSSLCtx_Init(int version, char* cert, char* key, char* verifyCert,
WOLFSSL_CTX* ctx;
wolfSSL_method_func method = NULL;
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
/* Initialize wolfSSL */
wolfSSL_Init();

4
tls/server-tls-epoll-perf.c 100644 → 100755
View File

@ -638,6 +638,10 @@ static int WolfSSLCtx_Init(int version, char* cert, char* key, char* verifyCert,
WOLFSSL_CTX* ctx;
wolfSSL_method_func method = NULL;
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
/* Initialize wolfSSL */
wolfSSL_Init();

12
tls/server-tls-epoll-threaded.c 100644 → 100755
View File

@ -305,18 +305,14 @@ static int SSL_Read(WOLFSSL* ssl, char* buffer, int len, int* totalBytes,
pthread_mutex_lock(&sslConnMutex);
*readTime += diff;
if (rwret > 0)
*totalBytes += rwret;
pthread_mutex_unlock(&sslConnMutex);
if (rwret == 0) {
return 0;
}
if (rwret > 0) {
pthread_mutex_lock(&sslConnMutex);
*totalBytes += rwret;
pthread_mutex_unlock(&sslConnMutex);
}
error = wolfSSL_get_error(ssl, 0);
if (error == SSL_ERROR_WANT_READ)
return 2;
@ -1194,6 +1190,10 @@ int main(int argc, char* argv[])
}
}
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
/* Initialize wolfSSL */
wolfSSL_Init();