mirror of
https://github.com/nginx/nginx.git
synced 2024-12-04 22:09:01 +08:00
HTTP/3: reference h3c directly from ngx_http_connection_t.
Previously, an ngx_http_v3_connection_t object was created for HTTP/3 and then assinged to c->data instead of the generic ngx_http_connection_t object. Now a direct reference is added to ngx_http_connection_t, which is less confusing and does not require a flag for http3.
This commit is contained in:
parent
82f8734935
commit
38773a3c11
@ -201,7 +201,7 @@ ngx_http_quic_init(ngx_connection_t *c)
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http init quic stream");
|
||||
|
||||
phc = c->quic->parent->data;
|
||||
phc = ngx_http_quic_get_connection(c);
|
||||
|
||||
if (phc->ssl_servername) {
|
||||
hc->ssl_servername = phc->ssl_servername;
|
||||
|
@ -18,6 +18,10 @@
|
||||
#define NGX_HTTP_QUIC_ALPN_DRAFT_FMT "\x05hq-%02uD"
|
||||
|
||||
|
||||
#define ngx_http_quic_get_connection(c) \
|
||||
((ngx_http_connection_t *) (c)->quic->parent->data)
|
||||
|
||||
|
||||
ngx_int_t ngx_http_quic_init(ngx_connection_t *c);
|
||||
|
||||
|
||||
|
@ -21,6 +21,8 @@ typedef struct ngx_http_log_ctx_s ngx_http_log_ctx_t;
|
||||
typedef struct ngx_http_chunked_s ngx_http_chunked_t;
|
||||
typedef struct ngx_http_v2_stream_s ngx_http_v2_stream_t;
|
||||
typedef struct ngx_http_v3_parse_s ngx_http_v3_parse_t;
|
||||
typedef struct ngx_http_v3_connection_s
|
||||
ngx_http_v3_connection_t;
|
||||
|
||||
typedef ngx_int_t (*ngx_http_header_handler_pt)(ngx_http_request_t *r,
|
||||
ngx_table_elt_t *h, ngx_uint_t offset);
|
||||
|
@ -318,6 +318,10 @@ typedef struct {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_V3 || NGX_COMPAT)
|
||||
ngx_http_v3_connection_t *v3_session;
|
||||
#endif
|
||||
|
||||
ngx_chain_t *busy;
|
||||
ngx_int_t nbusy;
|
||||
|
||||
@ -325,7 +329,6 @@ typedef struct {
|
||||
|
||||
unsigned ssl:1;
|
||||
unsigned proxy_protocol:1;
|
||||
unsigned http3:1;
|
||||
} ngx_http_connection_t;
|
||||
|
||||
|
||||
|
@ -74,17 +74,14 @@
|
||||
#define NGX_HTTP_V3_ERR_DECODER_STREAM_ERROR 0x202
|
||||
|
||||
|
||||
#define ngx_http_v3_get_session(c) \
|
||||
((ngx_http_v3_connection_t *) (c)->quic->parent->data)
|
||||
#define ngx_http_v3_get_session(c) ngx_http_quic_get_connection(c)->v3_session
|
||||
|
||||
#define ngx_http_v3_get_module_loc_conf(c, module) \
|
||||
ngx_http_get_module_loc_conf( \
|
||||
((ngx_http_v3_connection_t *) c->quic->parent->data)->hc.conf_ctx, \
|
||||
ngx_http_get_module_loc_conf(ngx_http_quic_get_connection(c)->conf_ctx, \
|
||||
module)
|
||||
|
||||
#define ngx_http_v3_get_module_srv_conf(c, module) \
|
||||
ngx_http_get_module_srv_conf( \
|
||||
((ngx_http_v3_connection_t *) c->quic->parent->data)->hc.conf_ctx, \
|
||||
ngx_http_get_module_srv_conf(ngx_http_quic_get_connection(c)->conf_ctx, \
|
||||
module)
|
||||
|
||||
#define ngx_http_v3_finalize_connection(c, code, reason) \
|
||||
@ -130,9 +127,7 @@ typedef struct {
|
||||
} ngx_http_v3_dynamic_table_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/* the http connection must be first */
|
||||
ngx_http_connection_t hc;
|
||||
struct ngx_http_v3_connection_s {
|
||||
ngx_http_v3_dynamic_table_t table;
|
||||
|
||||
ngx_event_t keepalive;
|
||||
@ -149,7 +144,7 @@ typedef struct {
|
||||
ngx_uint_t goaway; /* unsigned goaway:1; */
|
||||
|
||||
ngx_connection_t *known_streams[NGX_HTTP_V3_MAX_KNOWN_STREAM];
|
||||
} ngx_http_v3_connection_t;
|
||||
};
|
||||
|
||||
|
||||
void ngx_http_v3_init(ngx_connection_t *c);
|
||||
|
@ -46,13 +46,13 @@ ngx_http_v3_init_session(ngx_connection_t *c)
|
||||
{
|
||||
ngx_connection_t *pc;
|
||||
ngx_pool_cleanup_t *cln;
|
||||
ngx_http_connection_t *phc;
|
||||
ngx_http_connection_t *hc;
|
||||
ngx_http_v3_connection_t *h3c;
|
||||
|
||||
pc = c->quic->parent;
|
||||
phc = pc->data;
|
||||
hc = pc->data;
|
||||
|
||||
if (phc->http3) {
|
||||
if (hc->v3_session) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
@ -63,8 +63,6 @@ ngx_http_v3_init_session(ngx_connection_t *c)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
h3c->hc = *phc;
|
||||
h3c->hc.http3 = 1;
|
||||
h3c->max_push_id = (uint64_t) -1;
|
||||
|
||||
ngx_queue_init(&h3c->blocked);
|
||||
@ -83,7 +81,7 @@ ngx_http_v3_init_session(ngx_connection_t *c)
|
||||
cln->handler = ngx_http_v3_cleanup_session;
|
||||
cln->data = h3c;
|
||||
|
||||
pc->data = h3c;
|
||||
hc->v3_session = h3c;
|
||||
|
||||
return ngx_http_v3_send_settings(c);
|
||||
}
|
||||
@ -523,9 +521,6 @@ ngx_http_v3_send_settings(ngx_connection_t *c)
|
||||
size_t n;
|
||||
ngx_connection_t *cc;
|
||||
ngx_http_v3_srv_conf_t *h3scf;
|
||||
ngx_http_v3_connection_t *h3c;
|
||||
|
||||
h3c = ngx_http_v3_get_session(c);
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings");
|
||||
|
||||
@ -534,7 +529,7 @@ ngx_http_v3_send_settings(ngx_connection_t *c)
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module);
|
||||
h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module);
|
||||
|
||||
n = ngx_http_v3_encode_varlen_int(NULL,
|
||||
NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY);
|
||||
|
@ -251,7 +251,7 @@ ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity)
|
||||
"http3 set capacity %ui", capacity);
|
||||
|
||||
h3c = ngx_http_v3_get_session(c);
|
||||
h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module);
|
||||
h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module);
|
||||
|
||||
if (capacity > h3scf->max_table_capacity) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
||||
@ -498,7 +498,7 @@ ngx_http_v3_decode_insert_count(ngx_connection_t *c, ngx_uint_t *insert_count)
|
||||
h3c = ngx_http_v3_get_session(c);
|
||||
dt = &h3c->table;
|
||||
|
||||
h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module);
|
||||
h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module);
|
||||
|
||||
max_entries = h3scf->max_table_capacity / 32;
|
||||
full_range = 2 * max_entries;
|
||||
@ -582,8 +582,7 @@ ngx_http_v3_check_insert_count(ngx_connection_t *c, ngx_uint_t insert_count)
|
||||
}
|
||||
|
||||
if (block->queue.prev == NULL) {
|
||||
h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx,
|
||||
ngx_http_v3_module);
|
||||
h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module);
|
||||
|
||||
if (h3c->nblocked == h3scf->max_blocked_streams) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user