/*
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2005 Nokia. All rights reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#if defined(__TANDEM) && defined(_SPT_MODEL_)
# include <spthread.h>
# include <spt_extensions.h> /* timeval */
#endif
#include <stdio.h>
#include <openssl/rand.h>
#include <openssl/engine.h>
#include "internal/refcount.h"
#include "internal/cryptlib.h"
#include "ssl_local.h"
#include "statem/statem_local.h"
static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s);
static void SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s);
static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck);
DEFINE_STACK_OF(SSL_SESSION)
__owur static ossl_inline int sess_timedout(OSSL_TIME t, SSL_SESSION *ss)
{
return ossl_time_compare(t, ss->calc_timeout) > 0;
}
/*
* Returns -1/0/+1 as other XXXcmp-type functions
* Takes calculated timeout into consideration
*/
__owur static ossl_inline int timeoutcmp(SSL_SESSION *a, SSL_SESSION *b)
{
return ossl_time_compare(a->calc_timeout, b->calc_timeout);
}
/*
* Calculates effective timeout
* Locking must be done by the caller of this