Welcome! Log In Create A New Profile

Advanced

Re: Module: exit master

Maxim Dounin
February 03, 2012 09:36AM
Hello!

On Fri, Feb 03, 2012 at 02:25:21PM +0100, Laurent wrote:

> Hi,
>
> I'm experiencing some troubles (and headaches) with my little nginx module.
> I've seen a lot of module code lately, and a ton of stuff about nginx
> modules but I can't manage to do what I need to.
> Here is my problem:
> I have created my own nginx module called "mymodule". Its loc_conf
> structure looks like that:
>
> typedef struct {
> void *serverConf;
> ngx_str_t server_file;
> } ngx_http_mymodule_loc_conf_t;
>
> its command structure looks like that:
>
> static ngx_command_t ngx_http_mymodule_commands[] = {
> {
> ngx_string("mymodule"),
> NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
> ngx_http_mymodule,
> NGX_HTTP_LOC_CONF_OFFSET,
> 0,
> NULL
> },
> ngx_null_command };
>
> in the ngx_http_mymodule function I do some stuff and set the
> serverConf pointer in the ngx_http_mymodule_loc_conf_t.
> The problem is that I would like to retrieve that serverConf pointer
> when the thread / process is exited. But the only parameter given to
> ngx_module_t while exiting thread process or master is a ngx_cycle_t*
> and I can't find how to retrieve the ngx_http_mymodule_loc_conf_t from
> it in order to work on that serverConf pointer.

You can't get location config from a cycle, as there are multiple
locations and each has it's own config. You may get module main
config via ngx_http_cycle_get_module_main_conf().

Alternatively, depending on what you are trying to do, just a pool
cleanup handler on configuration pool (with arbitrary opaque data
passed) may be a better solution.

Maxim Dounin

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

Module: exit master

Laurent 1054 February 03, 2012 08:26AM

Re: Module: exit master

Maxim Dounin 631 February 03, 2012 09:36AM



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

Online Users

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