第一个数据包仅解析一次,节省cpu
This commit is contained in:
@@ -6,9 +6,11 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <MESA/stream_inc/stream_base.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include <MESA/stream.h>
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "quic.h"
|
||||
#include "quic_entry.h"
|
||||
#include "quic_process.h"
|
||||
@@ -141,44 +143,44 @@ void quic_free_client_hello(struct quic_client_hello *client_hello, int thread_s
|
||||
return ;
|
||||
}
|
||||
|
||||
void quic_free_context(void** pme, int thread_seq)
|
||||
void quic_free_context(const struct streaminfo *a_stream, int bridge_id, void *data)
|
||||
{
|
||||
if(NULL==*pme)
|
||||
if(NULL!=data)
|
||||
{
|
||||
return ;
|
||||
struct quic_context *context = (struct quic_context *)data;
|
||||
quic_free_client_hello(context->quic_info.client_hello, a_stream->threadnum);
|
||||
|
||||
dictator_free(a_stream->threadnum, data);
|
||||
}
|
||||
|
||||
struct quic_context *context = (struct quic_context *)*pme;
|
||||
quic_free_client_hello(context->quic_info.client_hello, thread_seq);
|
||||
|
||||
dictator_free(thread_seq, *pme);
|
||||
*pme=NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
extern "C" unsigned char QUIC_ENTRY(struct streaminfo *pstream, void**pme, int thread_seq, void *a_packet)
|
||||
extern "C" unsigned char QUIC_ENTRY(const struct streaminfo *pstream, void**pme, int thread_seq, const void *a_packet)
|
||||
{
|
||||
unsigned char state=0;
|
||||
struct quic_context *context=(struct quic_context *)*pme;
|
||||
|
||||
if((g_quic_param.quic_interested_region_flag<QUIC_KEY) || (!is_quic_port(pstream)))
|
||||
{
|
||||
return APP_STATE_DROPME;
|
||||
}
|
||||
|
||||
if(*pme==NULL)
|
||||
if(pstream->opstate==OP_STATE_PENDING)
|
||||
{
|
||||
quic_init_context(pme, thread_seq);
|
||||
context=(struct quic_context *)*pme;
|
||||
*pme=stream_bridge_async_data_get(pstream, g_quic_param.context_bridge_id);
|
||||
if(*pme==NULL)
|
||||
{
|
||||
*pme=dictator_malloc(thread_seq, sizeof(struct quic_context));
|
||||
memset(*pme, 0, sizeof(struct quic_context));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char state=0;
|
||||
struct quic_context *context=(struct quic_context *)*pme;
|
||||
|
||||
state=quic_analyze_entry(pstream, context, thread_seq, a_packet);
|
||||
|
||||
if(state&APP_STATE_DROPME || pstream->opstate==OP_STATE_CLOSE)
|
||||
{
|
||||
quic_call_business_plug(pstream, context, NULL, 0, QUIC_INTEREST_KEY_MASK, a_packet);
|
||||
quic_free_context(pme, thread_seq);
|
||||
quic_free_context(pstream, g_quic_param.context_bridge_id, *pme);
|
||||
stream_bridge_async_data_put(pstream, g_quic_param.context_bridge_id, NULL);
|
||||
*pme=NULL;
|
||||
return state;
|
||||
}
|
||||
@@ -230,7 +232,7 @@ extern "C" int QUIC_INIT(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(g_quic_param.quic_conf_regionname[region_id], region_name, strlen(region_name));
|
||||
memcpy(g_quic_param.quic_conf_regionname[region_id], region_name, MIN(sizeof(g_quic_param.quic_conf_regionname[region_id])-1, strlen(region_name)));
|
||||
g_quic_param.quic_region_cnt++;
|
||||
memset(region_name, 0, sizeof(region_name));
|
||||
}
|
||||
@@ -243,6 +245,9 @@ extern "C" int QUIC_INIT(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_quic_param.context_bridge_id=stream_bridge_build("QUIC_CONTEXT", "w");
|
||||
stream_bridge_register_data_free_cb(g_quic_param.context_bridge_id, quic_free_context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user