what's the meaning ? ctx->srv conf = cscfp[s]->ctx->srv conf

Igor Sysoev igor at sysoev.ru
Thu Dec 23 10:11:59 MSK 2010


On Thu, Dec 23, 2010 at 01:46:15AM -0500, garry.lgr wrote:

> [img]http://blog.chinaunix.net/photo/6889_101223144343.jpg[/img]
> I drawed a picture according to the code of the nginx-0.9.1. The top
> part in the picture is built in the ngx_http_block of ngx_http.c.
> 
> When the ngx_http_merge_servers function at line 277 is called,  the
> ctx->srv_conf have hold the address of  cf->ctx->srv_conf. After
> ctx->srv_conf = cscfp[s]->ctx->srv_conf, ctx->srv_conf discard it's
> older address to point to the new address  cscfp[s]->ctx->srv_conf. 

Think ctx->srv_conf like a hidden function parameter available via cf->ctx:

     merge_srv_conf(cf, [ cf->ctx->srv_conf ], ...

> So I think it will generate memory leak.

All memory operated in ngx_http.c and many other files are allocated
from memory pools freed at once. For example, memory in ngx_http.c
is freed after each reconfiguration.


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list