Welcome! Log In Create A New Profile

Advanced

[PATCH] Events: closed unused listening fds in worker processes.

Zexuan Luo
April 18, 2019 06:14AM
# HG changeset patch
# User spacewander <spacewanderlzx@gmail.com>
# Date 1555581540 -28800
# Thu Apr 18 17:59:00 2019 +0800
# Branch ident
# Node ID 4fb5603514f2d324c50cb7e12c6ed0dc8935de0f
# Parent e0834ca20c9c68c4f0728f85efb3651732134ee2
Events: closed unused listening fds in worker processes.

It doesn't affect the listening socket, since there is
only one used fd which associates to the socket with or
without this change.

diff -r e0834ca20c9c -r 4fb5603514f2 src/core/ngx_connection.c
--- a/src/core/ngx_connection.c Thu Apr 05 12:33:14 2018 +0800
+++ b/src/core/ngx_connection.c Thu Apr 18 17:59:00 2019 +0800
@@ -975,6 +975,14 @@
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {

+#if (NGX_HAVE_REUSEPORT)
+
+ if (ls[i].fd == (ngx_socket_t) -1) {
+ continue;
+ }
+
+#endif
+
c = ls[i].connection;

if (c) {
diff -r e0834ca20c9c -r 4fb5603514f2 src/event/ngx_event.c
--- a/src/event/ngx_event.c Thu Apr 05 12:33:14 2018 +0800
+++ b/src/event/ngx_event.c Thu Apr 18 17:59:00 2019 +0800
@@ -735,6 +735,18 @@

#if (NGX_HAVE_REUSEPORT)
if (ls[i].reuseport && ls[i].worker != ngx_worker) {
+ ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
+ "close unused listening %V #%d ",
+ &ls[i].addr_text, ls[i].fd);
+
+ if (ngx_close_socket(ls[i].fd) == -1) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
+ ngx_close_socket_n " %V failed",
+ &ls[i].addr_text);
+ }
+
+ ls[i].fd = (ngx_socket_t) -1;
+
continue;
}
#endif
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Events: closed unused listening fds in worker processes.

Zexuan Luo 302 April 18, 2019 06:14AM

Re: [PATCH] Events: closed unused listening fds in worker processes.

Zexuan Luo 122 April 18, 2019 06:20AM

Re: [PATCH] Events: closed unused listening fds in worker processes.

Maxim Dounin 152 April 18, 2019 09:34AM



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

Online Users

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