1.删除缓存测试无效代码
2.修改header链表结构为TQ 3,重构h2_half_ops_field_read,h2_half_ops_field_write等接口
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
> File Name: http_stream.h
|
||||
> Author:
|
||||
> Mail:
|
||||
> Created Time: 2018年09月12日 星期三 15时56分05秒
|
||||
> Created Time: 2018<EFBFBD><EFBFBD>?09<30><39>?12<31><32>? 星期<E6989F><E69C9F>? 15<31><35>?56<35><36>?05<30><35>?
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _HTTP_STREAM_H
|
||||
@@ -14,41 +14,40 @@
|
||||
#include <nghttp2/nghttp2.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
typedef int (*event_cb)(struct http2_half_private * hf_private,
|
||||
typedef int (*event_cb)(struct tfe_h2_half_private * hf_private,
|
||||
tfe_http_event ev, const unsigned char * data,
|
||||
size_t len, void * user);
|
||||
|
||||
enum nghttp2_manage_stage
|
||||
enum h2_read_state
|
||||
{
|
||||
MANAGE_STAGE_INIT,
|
||||
MANAGE_STAGE_READING,
|
||||
MANAGE_STAGE_COMPLETE,
|
||||
H2_READ_STATE_BEGIN,
|
||||
H2_READ_STATE_READING,
|
||||
H2_READ_STATE_COMPLETE,
|
||||
};
|
||||
|
||||
struct data_t
|
||||
struct tfe_h2_payload
|
||||
{
|
||||
int gzip;
|
||||
uint8_t flags;
|
||||
ssize_t padlen;
|
||||
struct z_stream_st *inflater;
|
||||
struct z_stream_st *inflate;
|
||||
struct z_stream_st *deflate;
|
||||
struct evbuffer * evbuf_body;
|
||||
};
|
||||
|
||||
struct header_data{
|
||||
struct tfe_h2_field{
|
||||
TAILQ_ENTRY(tfe_h2_field) next;
|
||||
nghttp2_nv nv;
|
||||
struct http_field_name field;
|
||||
struct header_data *prev, *next;
|
||||
struct http_field_name *field;
|
||||
};
|
||||
|
||||
struct http2_headers{
|
||||
int nvlen;
|
||||
int complete;
|
||||
uint8_t flag;
|
||||
struct header_data *head, *tail;
|
||||
struct tfe_h2_header{
|
||||
TAILQ_HEAD(h2_field_list_head, tfe_h2_field) h2_field_list;
|
||||
int nvlen;
|
||||
uint8_t flag;
|
||||
};
|
||||
|
||||
struct http2_half_private
|
||||
struct tfe_h2_half_private
|
||||
{
|
||||
/* PUBLIC STRUCTURE */
|
||||
struct tfe_http_half half_public;
|
||||
@@ -60,19 +59,20 @@ struct http2_half_private
|
||||
int by_stream;
|
||||
|
||||
char * url_storage;
|
||||
struct data_t body;
|
||||
struct http2_headers headers;
|
||||
struct http2_headers promised;
|
||||
struct tfe_h2_payload body;
|
||||
struct tfe_h2_header header;
|
||||
struct tfe_h2_header promised;
|
||||
|
||||
/*Read Cache**/
|
||||
int32_t stream_id;
|
||||
nghttp2_session *session;
|
||||
struct tfe_h2_session *father_session;
|
||||
|
||||
enum nghttp2_manage_stage body_state;
|
||||
enum nghttp2_manage_stage message_state;
|
||||
enum h2_read_state body_state;
|
||||
enum h2_read_state message_state;
|
||||
|
||||
/* Callback Function */
|
||||
int (*event_cb)(struct http2_half_private * half_private, tfe_http_event ev,
|
||||
int (*event_cb)(struct tfe_h2_half_private * half_private, tfe_http_event ev,
|
||||
const unsigned char * data, size_t len, void * user);
|
||||
/* Callback Function User Pointer */
|
||||
void * event_cb_user;
|
||||
@@ -84,35 +84,32 @@ struct cache_trapper_t{
|
||||
int spd_set;
|
||||
int spd_valid;
|
||||
int rse_set;
|
||||
//int set_cnt;
|
||||
//int flag_end;
|
||||
int spd_set_cnt;
|
||||
int spd_cnt;
|
||||
tfe_http_event spd_event;
|
||||
};
|
||||
|
||||
struct h2_stream_data_t{
|
||||
struct tfe_h2_session{
|
||||
struct tfe_http_session tfe_session;
|
||||
TAILQ_ENTRY(h2_stream_data_t) next;
|
||||
TAILQ_ENTRY(tfe_h2_session) next;
|
||||
const struct tfe_stream *tf_stream;
|
||||
|
||||
int32_t stream_id;
|
||||
nghttp2_session *session;
|
||||
int32_t ngh2_stream_id;
|
||||
nghttp2_session *session;
|
||||
struct tfe_h2_stream *father_stream;
|
||||
|
||||
struct cache_trapper_t cache;
|
||||
struct http_frame_session_ctx *frame_ctx;
|
||||
struct http2_half_private *req, *pangu_req;
|
||||
struct http2_half_private *resp, *pangu_resp;
|
||||
struct tfe_h2_half_private *req, *plugin_built_req;
|
||||
struct tfe_h2_half_private *resp, *plugin_built_resp;
|
||||
};
|
||||
|
||||
struct tfe_session_info_t
|
||||
struct tfe_h2_stream
|
||||
{
|
||||
TAILQ_HEAD(list_head, h2_stream_data_t) list;
|
||||
TAILQ_HEAD(list_head, tfe_h2_session) h2_session_list;
|
||||
|
||||
int goaway;
|
||||
|
||||
int32_t stream_id;
|
||||
|
||||
enum tfe_stream_action stream_action;
|
||||
|
||||
unsigned int thread_id;
|
||||
@@ -130,67 +127,52 @@ struct stream_tap_info_t
|
||||
/** IS PREEMPTED */
|
||||
unsigned int preempted;
|
||||
/** sess manage */
|
||||
struct tfe_session_info_t *session_info;
|
||||
struct tfe_h2_stream *h2_stream_info;
|
||||
};
|
||||
|
||||
/*STREAM STATE **/
|
||||
#define TFE_NGHTTP2_DATA 0x00000001
|
||||
#define TFE_NGHTTP2_HEADERS 0x00000002
|
||||
#define TFE_NGHTTP2_PRIORITY 0x00000020
|
||||
#define TFE_NGHTTP2_RST_STREAM 0x00000040
|
||||
#define TFE_NGHTTP2_SETTINGS 0x00000080
|
||||
#define TFE_NGHTTP2_PUSH_PROMISE 0x00000100
|
||||
#define TFE_NGHTTP2_PING 0x00000200
|
||||
#define TFE_NGHTTP2_GOAWAY 0x00000400
|
||||
#define TFE_NGHTTP2_WINDOW_UPDATE 0x00000800
|
||||
#define TFE_NGHTTP2_CONTINUATION 0x00001000
|
||||
#define TFE_NGHTTP2_ALTSVC 0x00002000
|
||||
#define TFE_NGHTTP2_RESPONSE 0x00004000
|
||||
|
||||
#define ACTION_USER_DATA 3
|
||||
#define NGHTTP2_NO_USER_ERROR 0x0e
|
||||
|
||||
static inline const struct http2_half_private *
|
||||
static inline const struct tfe_h2_half_private *
|
||||
nghttp2_to_half_private(const struct tfe_http_half * half_public)
|
||||
{
|
||||
if(!half_public)
|
||||
return NULL;
|
||||
return container_of(half_public, struct http2_half_private, half_public);
|
||||
return container_of(half_public, struct tfe_h2_half_private, half_public);
|
||||
}
|
||||
|
||||
static inline struct http2_half_private *
|
||||
static inline struct tfe_h2_half_private *
|
||||
nghttp2_to_half_private(struct tfe_http_half * half_public)
|
||||
{
|
||||
if(!half_public)
|
||||
return NULL;
|
||||
return container_of(half_public, struct http2_half_private, half_public);
|
||||
return container_of(half_public, struct tfe_h2_half_private, half_public);
|
||||
}
|
||||
|
||||
static inline struct h2_stream_data_t *
|
||||
static inline struct tfe_h2_session *
|
||||
nghttp2_to_stream_data(struct tfe_http_session * hs_public)
|
||||
{
|
||||
if (hs_public == NULL)
|
||||
return NULL;
|
||||
return container_of(hs_public, struct h2_stream_data_t, tfe_session);
|
||||
return container_of(hs_public, struct tfe_h2_session, tfe_session);
|
||||
}
|
||||
|
||||
extern struct tfe_session_info_t* tfe_session_info_init();
|
||||
extern void sess_data_ctx_fini(struct tfe_session_info_t *session_info, const struct tfe_stream * stream,
|
||||
extern struct tfe_h2_stream* tfe_session_info_init();
|
||||
extern void sess_data_ctx_fini(struct tfe_h2_stream *h2_stream_info, const struct tfe_stream * stream,
|
||||
unsigned int thread_id);
|
||||
|
||||
extern enum tfe_stream_action
|
||||
detect_down_stream_protocol(struct tfe_session_info_t *session_info, const struct tfe_stream *tfe_stream,
|
||||
detect_down_stream_protocol(struct tfe_h2_stream *h2_stream_info, const struct tfe_stream *tfe_stream,
|
||||
unsigned int thread_id, const unsigned char *data, size_t len);
|
||||
|
||||
extern enum tfe_stream_action
|
||||
detect_up_stream_protocol(struct tfe_session_info_t *session_info, const struct tfe_stream *tfe_stream,
|
||||
detect_up_stream_protocol(struct tfe_h2_stream *h2_stream_info, const struct tfe_stream *tfe_stream,
|
||||
unsigned int thread_id, const unsigned char *data, size_t len);
|
||||
|
||||
enum tfe_stream_action
|
||||
nghttp2_client_mem_send(struct tfe_session_info_t *session_info);
|
||||
nghttp2_client_mem_send(struct tfe_h2_stream *h2_stream_info);
|
||||
|
||||
enum tfe_stream_action
|
||||
nghttp2_server_mem_send(struct tfe_session_info_t *session_info);
|
||||
nghttp2_server_mem_send(struct tfe_h2_stream *h2_stream_info);
|
||||
|
||||
/*for test **/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user