Improvements to session locking to allow per-row. Can manually be enabled with ENABLE_SESSION_CACHE_ROW_LOCK or forcefully disabled using NO_SESSION_CACHE_ROW_LOCK. Enabled by default for Titan cache. ZD 12715.

This commit is contained in:
David Garske
2021-08-16 16:30:06 -07:00
parent e7ef48d2b7
commit c8926a45ab
4 changed files with 373 additions and 261 deletions

View File

@ -2452,7 +2452,6 @@ WOLFSSL_API int wolfSSL_GetSessionAtIndex(int index, WOLFSSL_SESSION* session);
} }
\endcode \endcode
\sa get_locked_session_stats
\sa wolfSSL_GetSessionAtIndex \sa wolfSSL_GetSessionAtIndex
\sa wolfSSL_GetSessionIndex \sa wolfSSL_GetSessionIndex
\sa AddSession \sa AddSession
@ -11510,7 +11509,6 @@ WOLFSSL_API int wolfSSL_PrintSessionStats(void);
return ret; return ret;
\endcode \endcode
\sa get_locked_session_stats
\sa wolfSSL_PrintSessionStats \sa wolfSSL_PrintSessionStats
*/ */
WOLFSSL_API int wolfSSL_get_session_stats(unsigned int* active, WOLFSSL_API int wolfSSL_get_session_stats(unsigned int* active,

View File

@ -3654,6 +3654,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes,
if (ret == 0 && session->flags.cached == 0) { if (ret == 0 && session->flags.cached == 0) {
if (session->sslServer->options.haveSessionId) { if (session->sslServer->options.haveSessionId) {
#ifndef NO_SESSION_CACHE
WOLFSSL_SESSION* sess = GetSession(session->sslServer, NULL, 0); WOLFSSL_SESSION* sess = GetSession(session->sslServer, NULL, 0);
if (sess == NULL) { if (sess == NULL) {
AddSession(session->sslServer); /* don't re add */ AddSession(session->sslServer); /* don't re add */
@ -3662,6 +3663,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes,
#endif #endif
} }
session->flags.cached = 1; session->flags.cached = 1;
#endif
} }
} }
@ -5682,7 +5684,7 @@ int ssl_EnableRecovery(int onOff, int maxMemory, char* error)
#ifdef WOLFSSL_SESSION_STATS #if defined(WOLFSSL_SESSION_STATS) && !defined(NO_SESSION_CACHE)
int ssl_GetSessionStats(unsigned int* active, unsigned int* total, int ssl_GetSessionStats(unsigned int* active, unsigned int* total,
unsigned int* peak, unsigned int* maxSessions, unsigned int* peak, unsigned int* maxSessions,

623
src/ssl.c

File diff suppressed because it is too large Load Diff

View File

@ -3333,6 +3333,7 @@ struct WOLFSSL_X509_CHAIN {
/* wolfSSL session type */ /* wolfSSL session type */
struct WOLFSSL_SESSION { struct WOLFSSL_SESSION {
int cacheRow; /* row in session cache */
word32 bornOn; /* create time in seconds */ word32 bornOn; /* create time in seconds */
word32 timeout; /* timeout in seconds */ word32 timeout; /* timeout in seconds */
byte sessionID[ID_LEN]; /* id for protocol */ byte sessionID[ID_LEN]; /* id for protocol */
@ -3368,7 +3369,7 @@ struct WOLFSSL_SESSION {
wolfSSL_Mutex refMutex; /* ref count mutex */ wolfSSL_Mutex refMutex; /* ref count mutex */
#endif #endif
int refCount; /* reference count */ int refCount; /* reference count */
#endif #endif /* OPENSSL_EXTRA */
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
byte peerVerifyRet; /* cert verify error */ byte peerVerifyRet; /* cert verify error */
#endif #endif
@ -3398,7 +3399,7 @@ struct WOLFSSL_SESSION {
WOLFSSL_CRYPTO_EX_DATA ex_data; WOLFSSL_CRYPTO_EX_DATA ex_data;
#endif #endif
byte side; /* Either WOLFSSL_CLIENT_END or byte side; /* Either WOLFSSL_CLIENT_END or
WOLFSSL_SERVER_END */ WOLFSSL_SERVER_END */
}; };