mirror of
https://github.com/nginx/nginx.git
synced 2024-12-19 21:53:31 -06:00
use ngx_queue.h
This commit is contained in:
parent
181abe549f
commit
01a129d823
@ -1234,11 +1234,7 @@ ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone, void *data)
|
||||
ngx_rbtree_init(&cache->session_rbtree, &cache->sentinel,
|
||||
ngx_ssl_session_rbtree_insert_value);
|
||||
|
||||
cache->session_cache_head.prev = NULL;
|
||||
cache->session_cache_head.next = &cache->session_cache_tail;
|
||||
|
||||
cache->session_cache_tail.prev = &cache->session_cache_head;
|
||||
cache->session_cache_tail.next = NULL;
|
||||
ngx_queue_init(&cache->expire_queue);
|
||||
|
||||
shm_zone->data = cache;
|
||||
|
||||
@ -1353,10 +1349,7 @@ ngx_ssl_new_session(ngx_ssl_conn_t *ssl_conn, ngx_ssl_session_t *sess)
|
||||
|
||||
sess_id->expire = ngx_time() + SSL_CTX_get_timeout(ssl_ctx);
|
||||
|
||||
sess_id->next = cache->session_cache_head.next;
|
||||
sess_id->next->prev = sess_id;
|
||||
sess_id->prev = &cache->session_cache_head;
|
||||
cache->session_cache_head.next = sess_id;
|
||||
ngx_queue_insert_head(&cache->expire_queue, &sess_id->queue);
|
||||
|
||||
ngx_rbtree_insert(&cache->session_rbtree, &sess_id->node);
|
||||
|
||||
@ -1456,8 +1449,7 @@ ngx_ssl_get_cached_session(ngx_ssl_conn_t *ssl_conn, u_char *id, int len,
|
||||
return sess;
|
||||
}
|
||||
|
||||
sess_id->next->prev = sess_id->prev;
|
||||
sess_id->prev->next = sess_id->next;
|
||||
ngx_queue_remove(&sess_id->queue);
|
||||
|
||||
ngx_rbtree_delete(&cache->session_rbtree, node);
|
||||
|
||||
@ -1539,8 +1531,8 @@ ngx_ssl_remove_session(SSL_CTX *ssl, ngx_ssl_session_t *sess)
|
||||
rc = ngx_memn2cmp(id, sess_id->id, len, (size_t) node->data);
|
||||
|
||||
if (rc == 0) {
|
||||
sess_id->next->prev = sess_id->prev;
|
||||
sess_id->prev->next = sess_id->next;
|
||||
|
||||
ngx_queue_remove(&sess_id->queue);
|
||||
|
||||
ngx_rbtree_delete(&cache->session_rbtree, node);
|
||||
|
||||
@ -1571,30 +1563,32 @@ ngx_ssl_expire_sessions(ngx_ssl_session_cache_t *cache,
|
||||
ngx_slab_pool_t *shpool, ngx_uint_t n)
|
||||
{
|
||||
time_t now;
|
||||
ngx_queue_t *q;
|
||||
ngx_ssl_sess_id_t *sess_id;
|
||||
|
||||
now = ngx_time();
|
||||
|
||||
while (n < 3) {
|
||||
|
||||
sess_id = cache->session_cache_tail.prev;
|
||||
|
||||
if (sess_id == &cache->session_cache_head) {
|
||||
if (ngx_queue_empty(&cache->expire_queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
q = ngx_queue_last(&cache->expire_queue);
|
||||
|
||||
sess_id = ngx_queue_data(q, ngx_ssl_sess_id_t, queue);
|
||||
|
||||
if (n++ != 0 && sess_id->expire > now) {
|
||||
return;
|
||||
}
|
||||
|
||||
sess_id->next->prev = sess_id->prev;
|
||||
sess_id->prev->next = sess_id->next;
|
||||
|
||||
ngx_rbtree_delete(&cache->session_rbtree, &sess_id->node);
|
||||
ngx_queue_remove(q);
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ngx_cycle->log, 0,
|
||||
"expire session: %08Xi", sess_id->node.key);
|
||||
|
||||
ngx_rbtree_delete(&cache->session_rbtree, &sess_id->node);
|
||||
|
||||
ngx_slab_free_locked(shpool, sess_id->session);
|
||||
#if (NGX_PTR_SIZE == 4)
|
||||
ngx_slab_free_locked(shpool, sess_id->id);
|
||||
|
@ -64,8 +64,7 @@ struct ngx_ssl_sess_id_s {
|
||||
u_char *id;
|
||||
size_t len;
|
||||
u_char *session;
|
||||
ngx_ssl_sess_id_t *prev;
|
||||
ngx_ssl_sess_id_t *next;
|
||||
ngx_queue_t queue;
|
||||
time_t expire;
|
||||
#if (NGX_PTR_SIZE == 8)
|
||||
void *stub;
|
||||
@ -77,8 +76,7 @@ struct ngx_ssl_sess_id_s {
|
||||
typedef struct {
|
||||
ngx_rbtree_t session_rbtree;
|
||||
ngx_rbtree_node_t sentinel;
|
||||
ngx_ssl_sess_id_t session_cache_head;
|
||||
ngx_ssl_sess_id_t session_cache_tail;
|
||||
ngx_queue_t expire_queue;
|
||||
} ngx_ssl_session_cache_t;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user