回复: Re: How to

=?UTF-8?Q?bind_variable_with?=

=?UTF-8?Q?_connection_in_a_customized_module=3F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=“utf-8”
Content-Transfer-Encoding: quoted-printable

Thank you very much. And for your note, I know the connections are
reusable=
, it’s not a problem for me. To be sure, during a client is alive, the
conn=
ection won’t serve other clients, is it correct?

Maxim D. [email protected]=E7=BC=96=E5=86=99=EF=BC=9A

Hello!

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

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

This was recently discussed on [email protected] mailing list, and=20
probably the best way currently available is to install connection=20
pool cleanup handler with custom data and then iterate over=20
connection pool cleanup handlers to find your data. It is=20
relatively costly, but allows to keep memory footprint from=20
keepalive connections low and still allows modules to keep their=20
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=20
that request came from the same connection means mostly nothing:=20
it might be a request from a completely different user.

–=20
Maxim D.


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Hello!

(Just a side note: it looks like you mail client have problems
with proper mail encoding. I have to recover message headers by
hand, as the Subject header was split across multiple
non-consecutive lines, breaking other headers as well.)

On Tue, Jan 22, 2013 at 05:33:31AM -0800, Haifeng Liu wrote:

Thank you very much. And for your note, I know the connections
are reusable, it’s not a problem for me. To be sure, during a
client is alive, the connection won’t serve other clients, is it
correct?

This depends on what do you mean by “client”. If next hop http
client - true, the connection is always with one client. But on
the same connection request from different users might appear,
e.g. if requests are proxied via the same proxy server (“client”
from nginx point of view).

It might be helpfull to read this section of RFC2616 for better
understanding:

http://tools.ietf.org/html/rfc2616#section-1.4

I want save state during a long connection (keep-alive) for
pool cleanup handler with custom data and then iterate over
it might be a request from a completely different user.


Maxim D.
http://nginx.com/support.html


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx


Maxim D.
http://nginx.com/support.html

Thank you again. Last mail was sent from my mobile phone(android). Sorry
for the trouble.

Proxied connection is not a big problem for me for now. But good note,
I’ll think about it in the future.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs