Welcome! Log In Create A New Profile

Advanced

Re: Context for connections

August 19, 2011 06:20PM
Hi Brian,

On 19/08/2011 17:50, Akins, Brian wrote:
> I'd like to be able to store some per-module, per-connection data. Like the
> ctx in the requests. I was wondering if I should just patch nginx, or if
> someone else had done something similar.
Can I assume that in your case just storing the data in the c->data slot
isn't going to work (easily/nicely)? e.g.

typedef struct {
ngx_http_request_t *r; /* or whatever other info you need */
void **ctx;
} ngx_my_connection_data_t;

Assuming you're talking about hooking into the http requests somehow,
you probably don't want to be playing around with the main connection in
this way, because there are loads of functions that assume that c->data
= (some ngx_http_request_t* - either the parent or a subrequest) - it's
doable, but messy.

However, if you're creating your own connections, then there's no reason
you can't use such a construction. You'd have to make sure that all
your event handlers and other callbacks were able to handle this data
struct of course, though.

If you are talking about doing this for connections including 'standard'
ones, like the main http request, I'd patch the ngx_connection_t struct
to just add an extra ctx to it. It's a very minor addition, and would
be much easier than trying to deal with changing event handlers all over
the place.

Cheers,

Marcus.

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Context for connections

Akins, Brian 1810 August 19, 2011 10:52AM

Re: Context for connections

Eugaia 1064 August 19, 2011 06:20PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 325
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