Welcome! Log In Create A New Profile

Advanced

ngx_http_v3_init_session function

Clima Gabriel
February 05, 2024 04:26PM
Hello everyone,

(the code is probably clearer and attached below)
This function modifies what ngx_connection_t->data points to.
ngx_connection_t->data is initially *ngx_http_connection_t.
The *ngx_http_connection_t is assigned to
ngx_http_v3_session_t->http_connection
And the *ngx_http_v3_session_t assigned to ngx_connection_t->data.

Result: before ngx_connection_t->data is *ngx_http_connection_t
after ngx_connection_t->data is *ngx_http_v3_session_t

My question is: what is the proper way to find out what c->data is at any
given time? I need to know this because I'm writing a function which uses
the ngx_http_connection_t to obtain the hostname of the request, and it may
be invoked before or after the ngx_http_v3_init_session.

ngx_int_t
ngx_http_v3_init_session(ngx_connection_t *c)
{
ngx_pool_cleanup_t *cln;
ngx_http_connection_t *hc;
ngx_http_v3_session_t *h3c;

hc = c->data;

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session");

h3c = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_session_t));
if (h3c == NULL) {
goto failed;
}

h3c->http_connection = hc;

ngx_queue_init(&h3c->blocked);

h3c->keepalive.log = c->log;
h3c->keepalive.data = c;
h3c->keepalive.handler = ngx_http_v3_keepalive_handler;

h3c->table.send_insert_count.log = c->log;
h3c->table.send_insert_count.data = c;
h3c->table.send_insert_count.handler =
ngx_http_v3_inc_insert_count_handler;

cln = ngx_pool_cleanup_add(c->pool, 0);
if (cln == NULL) {
goto failed;
}

cln->handler = ngx_http_v3_cleanup_session;
cln->data = h3c;

c->data = h3c;

return NGX_OK;

failed:

ngx_log_error(NGX_LOG_ERR, c->log, 0, "failed to create http3 session");
return NGX_ERROR;
}

Regards,
Gabriel
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

ngx_http_v3_init_session function

Clima Gabriel February 05, 2024 04:26PM

Re: ngx_http_v3_init_session function

J Carter February 05, 2024 07:18PM

Re: ngx_http_v3_init_session function

J Carter February 05, 2024 07:46PM

Re: ngx_http_v3_init_session function

J Carter February 06, 2024 12:10AM

Re: ngx_http_v3_init_session function

Roman Arutyunyan February 07, 2024 04:30AM

Re: ngx_http_v3_init_session function

Clima Gabriel February 07, 2024 08:36AM

Re: ngx_http_v3_init_session function

Roman Arutyunyan February 09, 2024 07:00AM

Re: ngx_http_v3_init_session function

Clima Gabriel February 14, 2024 11:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 88
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready