Opened 7 years ago
Closed 7 years ago
#1426 closed defect (invalid)
nginx master-worker communication channel problem?
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | major | Milestone: | |
Component: | other | Version: | 1.10.x |
Keywords: | Cc: | ||
uname -a: | Linux midea-S30 4.4.0-98-generic #121~14.04.1-Ubuntu SMP Wed Oct 11 11:54:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux | ||
nginx -V: |
nginx version: nginx/1.10.3
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) built with OpenSSL 1.0.2g 1 Mar 2016 TLS SNI support enabled configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.40 --with-zlib=../zlib-1.2.11 |
Description
nginx version: nginx1.10.3
In ngx_process.c, function ngx_spawn_process() use the following:
<pre>
socketpair(AF_UNIX, SOCK_STREAM, 0, ngx_processes[s].channel)
</pre>
and create two channel, then use fork() to create a new process. In the child process, it close the channel[0] and use channel[1] to receive the master's message . The master process use channel[0] to send message to the worker. And here I found that the master's channel[1] has not closed, is it a bug?
Note:
See TracTickets
for help on using tickets.
No, certainly it is not a bug - nothing wrong happens due to this behaviour. Moreover, clearly this is intentional, as the code closes unneeded
channel[1]
sockets in thengx_worker_process_init()
function, andngx_close_channel()
unconditionally closes both sockets.The code probably can be optimized to close
channel[1]
earlier, though this will require changes in various places, including ones mentioned above.