Welcome! Log In Create A New Profile

Advanced

[PATCH 1 of 2] Core: connect() error log message made more verbose

Safar Safarly via nginx-devel
February 08, 2023 10:56AM
# HG changeset patch
# User Safar Safarly <hafl@me.com>
# Date 1675779866 -10800
# Tue Feb 07 17:24:26 2023 +0300
# Node ID 55553146bd984be7e9e3bbfa851c282feda82d93
# Parent cffaf3f2eec8fd33605c2a37814f5ffc30371989
Core: connect() error log message made more verbose

There was a major problem in logs: we could not identify to which servers
connect() has failed. Previously log produced:

ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno,
"connect() failed");

And now we'll have an address or unix socket in log:

ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno,
"connect() to %V failed", &peer->server.name);

Message format has chosen to be exact as it is used in ngx_event_connect.c:242
with similar error logging:

ngx_log_error(level, c->log, err, "connect() to %V failed",
pc->name);

So everywhere connect() could fail we'd get a uniform and verbose error message
in log.

diff -r cffaf3f2eec8 -r 55553146bd98 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Thu Feb 02 23:38:48 2023 +0300
+++ b/src/core/ngx_resolver.c Tue Feb 07 17:24:26 2023 +0300
@@ -4512,7 +4512,7 @@

if (rc == -1) {
ngx_log_error(NGX_LOG_CRIT, &rec->log, ngx_socket_errno,
- "connect() failed");
+ "connect() to %V failed", &rec->server);

goto failed;
}
diff -r cffaf3f2eec8 -r 55553146bd98 src/core/ngx_syslog.c
--- a/src/core/ngx_syslog.c Thu Feb 02 23:38:48 2023 +0300
+++ b/src/core/ngx_syslog.c Tue Feb 07 17:24:26 2023 +0300
@@ -337,7 +337,7 @@

if (connect(fd, peer->server.sockaddr, peer->server.socklen) == -1) {
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno,
- "connect() failed");
+ "connect() to %V failed", &peer->server.name);
goto failed;
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 1 of 2] Core: connect() error log message made more verbose

Safar Safarly via nginx-devel 644 February 08, 2023 10:56AM

[PATCH 2 of 2] Added config path when unknown variable error occurs

Safar Safarly via nginx-devel 110 February 08, 2023 10:56AM

Re: [PATCH 2 of 2] Added config path when unknown variable error occurs

Maxim Dounin 134 February 09, 2023 03:22AM

Re: [PATCH 1 of 2] Core: connect() error log message made more verbose

Maxim Dounin 129 February 09, 2023 03:12AM

Re: [PATCH 1 of 2] Core: connect() error log message made more verbose

Sergey Kandaurov 119 February 22, 2023 06:38AM

Re: [PATCH 1 of 2] Core: connect() error log message made more verbose

Maxim Dounin 120 February 22, 2023 02:56PM

Re: [PATCH 1 of 2] Core: connect() error log message made more verbose

Sergey Kandaurov 107 March 09, 2023 11:08AM

Re: [PATCH 1 of 2] Core: connect() error log message made more verbose

Maxim Dounin 128 March 09, 2023 11:54PM



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

Online Users

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