Add session table & session
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "session_pool.h"
|
||||
#include "session_private.h"
|
||||
|
||||
struct session_pool
|
||||
{
|
||||
@@ -35,7 +36,7 @@ void session_pool_destroy(struct session_pool *pool)
|
||||
}
|
||||
}
|
||||
|
||||
struct session *session_pool_pop(struct session_pool *pool)
|
||||
struct session *session_pool_alloc(struct session_pool *pool)
|
||||
{
|
||||
if (pool == NULL)
|
||||
{
|
||||
@@ -50,11 +51,12 @@ struct session *session_pool_pop(struct session_pool *pool)
|
||||
|
||||
pool->sess = sess->next;
|
||||
sess->next = NULL;
|
||||
pool->count--;
|
||||
|
||||
return sess;
|
||||
}
|
||||
|
||||
void session_pool_push(struct session_pool *pool, struct session *sess)
|
||||
void session_pool_free(struct session_pool *pool, struct session *sess)
|
||||
{
|
||||
if (pool == NULL || sess == NULL)
|
||||
{
|
||||
@@ -63,4 +65,15 @@ void session_pool_push(struct session_pool *pool, struct session *sess)
|
||||
|
||||
sess->next = pool->sess;
|
||||
pool->sess = sess;
|
||||
pool->count++;
|
||||
}
|
||||
|
||||
uint64_t session_pool_get_count(struct session_pool *pool)
|
||||
{
|
||||
if (pool == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pool->count;
|
||||
}
|
||||
Reference in New Issue
Block a user