Welcome! Log In Create A New Profile

Advanced

Re: How to bind variable with connection in a customized module?

Maxim Dounin
January 22, 2013 07:32AM
Hello!

On Tue, Jan 22, 2013 at 08:16:36PM +0800, Liu Haifeng wrote:

> hi all,
>
> I want save state during a long connection (keep-alive) for
> performance optimization in my own HTTP handler module, thus I
> can peek up the saved state when handling requests, to speed up
> response. Actually it's quite like session concept. I saw
> request struct has a member ctx, but what I want is a ctx on the
> connection. It seems no way to save any customized variable to
> the ngx_connection_t structure. What's the suggested way to make
> this if I don't want the client hold something like session_id?

This was recently discussed on nginx-devel@ mailing list, and
probably the best way currently available is to install connection
pool cleanup handler with custom data and then iterate over
connection pool cleanup handlers to find your data. It is
relatively costly, but allows to keep memory footprint from
keepalive connections low and still allows modules to keep their
per-connection data in rare cases when they really need to.

See here:
http://mailman.nginx.org/pipermail/nginx-devel/2012-December/003049.html

Note well though, that HTTP is stateless protocol, and the fact
that request came from the same connection means mostly nothing:
it might be a request from a completely different user.

--
Maxim Dounin
http://nginx.com/support.html

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

How to bind variable with connection in a customized module?

Liu Haifeng January 22, 2013 07:18AM

Re: How to bind variable with connection in a customized module?

Maxim Dounin January 22, 2013 07:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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