Question about source code: Any need to call ngx_event_pipe_remove_shadow_links in ngx_event_pipe_read_upstream?

Maxim Dounin mdounin at mdounin.ru
Mon May 18 19:11:08 UTC 2015


Hello!

On Sun, May 17, 2015 at 02:36:08PM +0800, J.J J wrote:

> Hi, all:
> 
> nginx code version: 1.7.9 ( I have checked v1.9.0, no change about this)
> 
> The bufs used to invoke ngx_event_pipe_remove_shadow_links  in
> ngx_event_pipe_read_upstream come from p->preread_bufs or p->free_raw_bufs
> or new allocated buf.
> 
> Both p->preread_bufs and new allocated buf have no shadow link.
> 
> p->preread_bufs is inited to be NULL, and there  are two places which will
> add free buffer into it: ngx_event_pipe_write_chain_to_temp_file and
>  ngx_event_pipe_write_to_downstream.
> 
> In both places, shadow links are cleared by ngx_event_pipe_add_free_buf or
> by ngx_event_pipe_remove_shadow_links.
> 
> So, there is no need to call ngx_event_pipe_remove_shadow_links
> in ngx_event_pipe_read_upstream at all, for shadow link will always be NULL.
> 
> Am I missing something ? Or just lack of code review ?

Most likely you are right and these calls are not needed.  I came 
to a similar conslusion while looking into this code a while ago.  
The code to work with shadow links was introduced in ancient 
times, before nginx 0.1.0, and it needs some cleanup.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list