session table support get oldest/newest session

This commit is contained in:
luwenpeng
2023-12-13 17:56:27 +08:00
parent fc5b5857b8
commit 92e5110503
7 changed files with 200 additions and 26 deletions

View File

@@ -20,9 +20,9 @@ struct session_pool *session_pool_create(uint64_t count)
for (uint64_t i = 0; i < count; i++)
{
pool->sess[i].next = &pool->sess[i + 1];
pool->sess[i].next_free_ptr = &pool->sess[i + 1];
}
pool->sess[count - 1].next = NULL;
pool->sess[count - 1].next_free_ptr = NULL;
return pool;
}
@@ -49,8 +49,8 @@ struct session *session_pool_alloc(struct session_pool *pool)
return NULL;
}
pool->sess = sess->next;
sess->next = NULL;
pool->sess = sess->next_free_ptr;
sess->next_free_ptr = NULL;
pool->count--;
return sess;
@@ -63,7 +63,7 @@ void session_pool_free(struct session_pool *pool, struct session *sess)
return;
}
sess->next = pool->sess;
sess->next_free_ptr = pool->sess;
pool->sess = sess;
pool->count++;
}