Welcome! Log In Create A New Profile

Advanced

Re: ngx_conf_handler

nn hust
January 01, 2011 11:34PM
Yes,it help me understand the code more clearly

在 2010年12月31日 下午7:18,eagle sbc <sbc19861004@gmail.com>写道:

> hi, nn hust:
> First, the 'cf->ctx' is a context variable. When in the DIRECT_CONF or
> MAIN_CONF context, it point to 'void*[MAX_MODULE]' array, while in the HTTP
> context, it point to a 'ngx_http_conf_ctx_t', which is a structure with
> there pointers each point to a 'void *[MAX_HTTP_MODULE]' array. Other CORE
> module act the same as HTTP.
> I draw a diagram to make seems more clear :
> [image: cf.jpg]
>
> Every module structure has a 'index' member and 'ctx_index' member. 'index'
> indicate its own data position in the glocal 'void *' array, while
> 'ctx_index' indicate the context related. (According to what I understand,
> The module type already choose which kind of array it will use, so the two
> index is not necessary)
>
> The different between DIRECT and MAIN is: DIRECT means the memory is
> already allocated, and the cmd's set function can directly use it, so pass
> the pointer to the allocated memory; MAIN means the memory to be allocated
> depend on the module, so pass the pointer to the pointer in the array.
>
> cmd's 'conf' member indicate which context it will store its data. As in
> HTTP, we can choose MAIN, SRV, LOC.
>
> And I think the code is now easy to understand.
> On Fri, Dec 31, 2010 at 4:46 PM, nn hust <nzjemail@gmail.com> wrote:
>
>> I am confused by the multi dimensions pointer of the module configure
>> structure
>>
>> if (cmd->type & NGX_DIRECT_CONF) {
>> conf = ((void **) cf->ctx)[ngx_modules[i]->index];
>>
>> } else if (cmd->type & NGX_MAIN_CONF) {
>> conf = &(((void **) cf->ctx)[ngx_modules[i]->index]);
>>
>> } else if (cf->ctx) {
>> confp = *(void **) ((char *) cf->ctx + cmd->conf);
>>
>> if (confp) {
>> conf = confp[ngx_modules[i]->ctx_index];
>> }
>> }
>>
>> rv = cmd->set(cf, cmd, conf);
>>
>>
>>
>>
>> _______________________________________________
>> nginx-devel mailing list
>> nginx-devel@nginx.org
>> http://nginx.org/mailman/listinfo/nginx-devel
>>
>>
>
>
> --
> 自由是我生命之基石,尊重是我行为之准绳
> 也许我以千百种方式生活在这世上,但我坚守我人生之信仰
> 所以,我的朋友
> 请平视的看着我,带着你的微笑
>
>
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://nginx.org/mailman/listinfo/nginx-devel
>
>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

ngx_conf_handler

nn hust 1720 December 31, 2010 03:48AM

Re: ngx_conf_handler Attachments

eagle sbc 545 December 31, 2010 06:46AM

Re: ngx_conf_handler

nn hust 721 January 01, 2011 11:34PM



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

Online Users

Guests: 71
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready