Add session table & session

This commit is contained in:
luwenpeng
2023-12-11 16:35:26 +08:00
parent 015b4e7695
commit 006315fb7c
12 changed files with 1024 additions and 20 deletions

View File

@@ -0,0 +1,92 @@
/*
* The current file is private to the plugin, and pulgin can only use session.h
* The current file can only be used by session.cpp/session_pool.cpp/session_table.cpp
*/
#ifndef _SESSION_PRIVATE_H
#define _SESSION_PRIVATE_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include "uthash.h"
#include "session.h"
#include "session_address.h"
#define EX_DATA_MAX_COUNT 128
#define SESSION_EVENT_QUEUE_SIZE 256
struct event_queue
{
uint32_t head_idx;
uint32_t tail_idx;
uint32_t events[SESSION_EVENT_QUEUE_SIZE];
};
struct session
{
// session state
enum session_state state;
// session type
enum session_type type;
// session metrics
uint64_t c2s_bytes;
uint64_t s2c_bytes;
uint64_t c2s_packets;
uint64_t s2c_packets;
// session metadata
struct metadata c2s_1st_md;
struct metadata s2c_1st_md;
// session timestamp
uint64_t create_time;
uint64_t last_time;
uint64_t expire_time;
/******************************
* Session Ev Queue Zone
******************************/
struct event_queue events;
/******************************
* Session Ex Data Zone
******************************/
void *ex_data[EX_DATA_MAX_COUNT];
/******************************
* Session Timer Zone
******************************/
// session timer
/******************************
* Session Pool Zone
******************************/
// session pool recycle handle
struct session *next;
/******************************
* Session Table Zone
******************************/
// session table key
uint64_t id;
struct session_address addr;
// session table handle
UT_hash_handle hh1; /* handle for root_id hash table */
UT_hash_handle hh2; /* handle for root_addr hash table */
};
#ifdef __cpluscplus
}
#endif
#endif