Upstream: reset local address in case of error.

After f10bc5a763 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.
This commit is contained in:
Roman Arutyunyan 2025-10-23 18:21:57 +04:00 committed by Roman Arutyunyan
parent 42ca3a4576
commit 364a94ecec
2 changed files with 4 additions and 0 deletions

View File

@ -6898,6 +6898,7 @@ ngx_http_upstream_set_local(ngx_http_request_t *r, ngx_http_upstream_t *u,
} }
if (val.len == 0) { if (val.len == 0) {
u->peer.local = NULL;
return NGX_OK; 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) { if (rc != NGX_OK) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"invalid local address \"%V\"", &val); "invalid local address \"%V\"", &val);
u->peer.local = NULL;
return NGX_OK; return NGX_OK;
} }

View File

@ -680,6 +680,7 @@ ngx_stream_proxy_set_local(ngx_stream_session_t *s, ngx_stream_upstream_t *u,
} }
if (val.len == 0) { if (val.len == 0) {
u->peer.local = NULL;
return NGX_OK; 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) { if (rc != NGX_OK) {
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
"invalid local address \"%V\"", &val); "invalid local address \"%V\"", &val);
u->peer.local = NULL;
return NGX_OK; return NGX_OK;
} }