Welcome! Log In Create A New Profile

Advanced

Inconsistent order for ngx_destroy_pool() and ngx_close_connection()

Lawrence Stewart
October 03, 2016 12:40AM
Hi all,

I need to pull kernel data using getsockopt() for a connection prior to the
socket being closed. A pool cleanup handler registered with the
ngx_connection_t's pool would seem to be the right way to do this, but
ngx_http_close_connection() calls ngx_close_connection() prior to
ngx_destroy_pool(), which means my cleanup handler sees a closed socket.

A look through ngx_close_connection() and the functions it calls would lead
me to believe it should be safe (and possible even desirable in an ordering
sense) to destroy the connection's pool prior to calling
ngx_close_connection(). There is an existence proof in the nginx tree that
this is reasonable to do (see [1]) and there is also a comment in
ngx_close_connection() that implies it expects that the connection's pool
has already been destroyed i.e.

/* we use ngx_cycle->log because c->log was in c->pool */

Are there some subtleties I'm missing, or is it correct and reasonable to
always call ngx_destroy_pool() on a connection's pool prior to calling
ngx_close_connection()?

Cheers,
Lawrence

[1]
http://lxr.nginx.org/source/src/http/modules/ngx_http_upstream_keepalive_module.c?v=nginx-1.10.1#0441
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Inconsistent order for ngx_destroy_pool() and ngx_close_connection()

Lawrence Stewart 834 October 03, 2016 12:40AM

Re: Inconsistent order for ngx_destroy_pool() and ngx_close_connection()

ru@nginx.com 650 October 03, 2016 03:48AM

Re: Inconsistent order for ngx_destroy_pool() and ngx_close_connection()

Lawrence Stewart 369 October 03, 2016 08:38AM

Re: Inconsistent order for ngx_destroy_pool() and ngx_close_connection()

ru@nginx.com 649 October 04, 2016 04:28AM



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

Online Users

Guests: 122
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready