plugin_manager adapt session_manager API and rewrite plugin_manger gtest

This commit is contained in:
luwenpeng
2022-08-26 17:33:03 +08:00
parent e3ea4d0729
commit 0ed9a0ccca
52 changed files with 1161 additions and 1575 deletions

View File

@@ -0,0 +1,70 @@
#include <stdlib.h>
#include "session.h"
static char *g_handler = NULL;
struct session_ctx
{
char data[64];
};
static struct session_ctx *session_ctx_create()
{
struct session_ctx *ctx = (struct session_ctx *)calloc(1, sizeof(struct session_ctx));
return ctx;
}
static void session_ctx_destory(struct session_ctx *ctx)
{
if (ctx)
{
free(ctx);
ctx = NULL;
}
}
extern "C" void http_plugin_entry(struct stellar_session *session, enum session_state state, int thread_id, void **ctx)
{
struct session_ctx **sctx = (struct session_ctx **)ctx;
if (state & SESSION_STATE_OPENING)
{
if (*sctx == NULL)
{
struct session_ctx *cur_ctx = session_ctx_create();
memcpy(cur_ctx->data, "http_plugin_entry", 17);
*sctx = *&cur_ctx;
}
}
if (state & SESSION_STATE_ACTIVE)
{
// TODO
}
if (state & SESSION_STATE_CLOSING)
{
session_ctx_destory(*sctx);
*sctx = NULL;
}
}
extern "C" int http_plugin_init(void)
{
if (g_handler == NULL)
{
g_handler = (char *)malloc(1024);
}
return 0;
}
extern "C" void http_plugin_exit(void)
{
if (g_handler)
{
free(g_handler);
g_handler = NULL;
}
}