From bbc208ad336335de2a0316041b36f177599e394d Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 11 Jul 2019 17:39:54 -0500 Subject: [PATCH] Updated some more globals in the sniffer and session cache with being shared. --- src/sniffer.c | 32 +++++++++++++++++--------------- src/ssl.c | 9 +++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/sniffer.c b/src/sniffer.c index d82516182..8931b5310 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -404,35 +404,37 @@ typedef struct SnifferSession { /* Sniffer Server List and mutex */ -static SnifferServer* ServerList = 0; -static wolfSSL_Mutex ServerListMutex; +static WOLFSSL_SHARED SnifferServer* ServerList = 0; +static WOLFSSL_SHARED wolfSSL_Mutex ServerListMutex; /* Session Hash Table, mutex, and count */ -static SnifferSession* SessionTable[HASH_SIZE]; -static wolfSSL_Mutex SessionMutex; -static int SessionCount = 0; +static WOLFSSL_SHARED SnifferSession* SessionTable[HASH_SIZE]; +static WOLFSSL_SHARED wolfSSL_Mutex SessionMutex; +static WOLFSSL_SHARED int SessionCount = 0; /* Recovery of missed data switches and stats */ -static wolfSSL_Mutex RecoveryMutex; /* for stats */ -static int RecoveryEnabled = 0; /* global switch */ -static int MaxRecoveryMemory = -1; /* per session max recovery memory */ -static word32 MissedDataSessions = 0; /* # of sessions with missed data */ +static WOLFSSL_SHARED wolfSSL_Mutex RecoveryMutex; /* for stats */ +static WOLFSSL_SHARED int RecoveryEnabled = 0; /* global switch */ +static WOLFSSL_SHARED int MaxRecoveryMemory = -1; + /* per session max recovery memory */ +static WOLFSSL_SHARED word32 MissedDataSessions = 0; + /* # of sessions with missed data */ /* Connection Info Callback */ -static SSLConnCb ConnectionCb; -static void* ConnectionCbCtx = NULL; +static WOLFSSL_SHARED SSLConnCb ConnectionCb; +static WOLFSSL_SHARED void* ConnectionCbCtx = NULL; #ifdef WOLFSSL_SNIFFER_STATS /* Sessions Statistics */ -static SSLStats SnifferStats; -static wolfSSL_Mutex StatsMutex; +static WOLFSSL_SHARED SSLStats SnifferStats; +static WOLFSSL_SHARED wolfSSL_Mutex StatsMutex; #endif #ifdef WOLFSSL_SNIFFER_WATCH /* Watch Key Callback */ -static SSLWatchCb WatchCb; -static void* WatchCbCtx = NULL; +static WOLFSSL_SHARED SSLWatchCb WatchCb; +static WOLFSSL_SHARED void* WatchCbCtx = NULL; #endif diff --git a/src/ssl.c b/src/ssl.c index 6bdec2214..6c190dfdd 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -4658,13 +4658,13 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify) WOLFSSL_SESSION Sessions[SESSIONS_PER_ROW]; } SessionRow; - static SessionRow SessionCache[SESSION_ROWS]; + static WOLFSSL_SHARED SessionRow SessionCache[SESSION_ROWS]; #if defined(WOLFSSL_SESSION_STATS) && defined(WOLFSSL_PEAK_SESSIONS) - static word32 PeakSessions; + static WOLFSSL_SHARED word32 PeakSessions; #endif - static wolfSSL_Mutex session_mutex; /* SessionCache mutex */ + static WOLFSSL_SHARED wolfSSL_Mutex session_mutex; /* SessionCache mutex */ #ifndef NO_CLIENT_CACHE @@ -4679,7 +4679,8 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify) ClientSession Clients[SESSIONS_PER_ROW]; } ClientRow; - static ClientRow ClientCache[SESSION_ROWS]; /* Client Cache */ + static WOLFSSL_SHARED ClientRow ClientCache[SESSION_ROWS]; + /* Client Cache */ /* uses session mutex */ #endif /* NO_CLIENT_CACHE */