It's used instead of accessing c->quic->parent->data directly. Apart from being
simpler, it allows to change the way session is stored in the future by changing
the macro.
#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_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_v3_connection_t *h3c;
c = r->connection;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
h3scf = ngx_http_get_module_srv_conf(r, ngx_http_v3_module);
ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0,
goto failed;
}
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
ngx_memcpy(hc, h3c, sizeof(ngx_http_connection_t));
c->data = hc;
clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
if (h3c->goaway) {
ngx_quic_reset_stream(c, NGX_HTTP_V3_ERR_REQUEST_REJECTED);
ngx_http_core_loc_conf_t *clcf;
ngx_http_v3_connection_t *h3c;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
if (--h3c->nrequests == 0) {
clcf = ngx_http_v3_get_module_loc_conf(c, ngx_http_core_module);
ngx_http_v3_uni_stream_t *us;
us = c->data;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 close stream");
c = rev->data;
us = c->data;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 read stream type");
goto failed;
}
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
h3c->npushing++;
cln->handler = ngx_http_v3_push_cleanup;
index = -1;
}
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
if (index >= 0) {
if (h3c->known_streams[index]) {
ngx_http_v3_srv_conf_t *h3scf;
ngx_http_v3_connection_t *h3c;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings");
{
ngx_http_v3_connection_t *h3c;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
"http3 MAX_PUSH_ID:%uL", max_push_id);
ngx_http_v3_push_t *push;
ngx_http_v3_connection_t *h3c;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
"http3 CANCEL_PUSH:%uL", push_id);
return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR;
}
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
dt = &h3c->table;
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0,
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
"http3 set capacity %ui", capacity);
- pc = c->quic->parent;
- h3c = pc->data;
+ h3c = ngx_http_v3_get_session(c);
h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module);
if (capacity > h3scf->max_table_capacity) {
}
if (dt->elts == NULL) {
+ pc = c->quic->parent;
+
cln = ngx_pool_cleanup_add(pc->pool, 0);
if (cln == NULL) {
return NGX_ERROR;
ngx_http_v3_connection_t *h3c;
ngx_http_v3_dynamic_table_t *dt;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
dt = &h3c->table;
if (need > dt->capacity) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 duplicate %ui", index);
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
dt = &h3c->table;
if (dt->base + dt->nelts <= index) {
ngx_http_v3_connection_t *h3c;
ngx_http_v3_dynamic_table_t *dt;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
dt = &h3c->table;
if (index < dt->base || index - dt->base >= dt->nelts) {
return NGX_OK;
}
- h3c = c->quic->parent->data;
+ 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);
ngx_http_v3_check_insert_count(ngx_connection_t *c, ngx_uint_t insert_count)
{
size_t n;
- ngx_connection_t *pc;
ngx_pool_cleanup_t *cln;
ngx_http_v3_block_t *block;
ngx_http_v3_srv_conf_t *h3scf;
ngx_http_v3_connection_t *h3c;
ngx_http_v3_dynamic_table_t *dt;
- pc = c->quic->parent;
- h3c = pc->data;
+ h3c = ngx_http_v3_get_session(c);
dt = &h3c->table;
n = dt->base + dt->nelts;
ngx_http_v3_block_t *block;
ngx_http_v3_connection_t *h3c;
- h3c = c->quic->parent->data;
+ h3c = ngx_http_v3_get_session(c);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
"http3 new dynamic header, blocked:%ui", h3c->nblocked);