]> git.feebdaed.xyz Git - 0xmirror/nginx.git/commitdiff
Upstream: reset local address in case of error.
authorRoman Arutyunyan <arut@nginx.com>
Thu, 23 Oct 2025 14:21:57 +0000 (18:21 +0400)
committerRoman Arutyunyan <arutyunyan.roman@gmail.com>
Fri, 24 Oct 2025 13:49:04 +0000 (17:49 +0400)
After f10bc5a763bb the address was set to NULL only when local address was
not specified at all.  In case complex value evaluated to an empty or
invalid string, local address remained unchanged.  Currenrly this is not
a problem since the value is only set once.  This change is a preparation
for being able to change the local address after initial setting.

src/http/ngx_http_upstream.c
src/stream/ngx_stream_proxy_module.c

index 07e51a96608f6a757b4934f0d2f3153eaa063bf7..66163548afdb14cb3b6f31a4a5407ef3992663e1 100644 (file)
@@ -6898,6 +6898,7 @@ ngx_http_upstream_set_local(ngx_http_request_t *r, ngx_http_upstream_t *u,
     }
 
     if (val.len == 0) {
+        u->peer.local = NULL;
         return NGX_OK;
     }
 
@@ -6914,6 +6915,7 @@ ngx_http_upstream_set_local(ngx_http_request_t *r, ngx_http_upstream_t *u,
     if (rc != NGX_OK) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "invalid local address \"%V\"", &val);
+        u->peer.local = NULL;
         return NGX_OK;
     }
 
index 6e51585f6e1f8bb0d66e5224f7cd241a3830b8f4..300bdf681878a81620e57e3bcf7a4c562e6274ea 100644 (file)
@@ -680,6 +680,7 @@ ngx_stream_proxy_set_local(ngx_stream_session_t *s, ngx_stream_upstream_t *u,
     }
 
     if (val.len == 0) {
+        u->peer.local = NULL;
         return NGX_OK;
     }
 
@@ -696,6 +697,7 @@ ngx_stream_proxy_set_local(ngx_stream_session_t *s, ngx_stream_upstream_t *u,
     if (rc != NGX_OK) {
         ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
                       "invalid local address \"%V\"", &val);
+        u->peer.local = NULL;
         return NGX_OK;
     }