summaryrefslogtreecommitdiffstats
path: root/ssl/ssl_asn1.c
diff options
context:
space:
mode:
authorTodd Short <tshort@akamai.com>2019-04-05 14:17:22 -0400
committerPauli <pauli@openssl.org>2021-06-10 18:32:25 +1000
commit25959e04c350c2b82d545ea38b18ff714acf61ba (patch)
tree7fd75f13eee0b56bfccea99f18d78bcbe85ba4b8 /ssl/ssl_asn1.c
parentde5a0198b22c36884fd36021d9e4f589b939674f (diff)
Optimize session cache flushing
Sort SSL_SESSION structures by timeout in the linked list. Iterate over the linked list for timeout, stopping when no more session can be flushed. Do SSL_SESSION_free() outside of SSL_CTX lock Update timeout upon use Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8687)
Diffstat (limited to 'ssl/ssl_asn1.c')
-rw-r--r--ssl/ssl_asn1.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ssl/ssl_asn1.c b/ssl/ssl_asn1.c
index c4479c2dd6..2cbd95fa1b 100644
--- a/ssl/ssl_asn1.c
+++ b/ssl/ssl_asn1.c
@@ -163,8 +163,8 @@ int i2d_SSL_SESSION(const SSL_SESSION *in, unsigned char **pp)
ssl_session_oinit(&as.session_id_context, &sid_ctx,
in->sid_ctx, in->sid_ctx_length);
- as.time = in->time;
- as.timeout = in->timeout;
+ as.time = (int64_t)in->time;
+ as.timeout = (int64_t)in->timeout;
as.verify_result = in->verify_result;
as.peer = in->peer;
@@ -302,14 +302,15 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
ret->master_key_length = tmpl;
if (as->time != 0)
- ret->time = (long)as->time;
+ ret->time = (time_t)as->time;
else
- ret->time = (long)time(NULL);
+ ret->time = time(NULL);
if (as->timeout != 0)
- ret->timeout = (long)as->timeout;
+ ret->timeout = (time_t)as->timeout;
else
ret->timeout = 3;
+ ssl_session_calculate_timeout(ret);
X509_free(ret->peer);
ret->peer = as->peer;