Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 364a94e

Browse files
committed
Upstream: reset local address in case of error.
After f10bc5a 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.
1 parent 42ca3a4 commit 364a94e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/http/ngx_http_upstream.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6898,6 +6898,7 @@ ngx_http_upstream_set_local(ngx_http_request_t *r, ngx_http_upstream_t *u,
68986898
}
68996899

69006900
if (val.len == 0) {
6901+
u->peer.local = NULL;
69016902
return NGX_OK;
69026903
}
69036904

@@ -6914,6 +6915,7 @@ ngx_http_upstream_set_local(ngx_http_request_t *r, ngx_http_upstream_t *u,
69146915
if (rc != NGX_OK) {
69156916
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
69166917
"invalid local address \"%V\"", &val);
6918+
u->peer.local = NULL;
69176919
return NGX_OK;
69186920
}
69196921

src/stream/ngx_stream_proxy_module.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ ngx_stream_proxy_set_local(ngx_stream_session_t *s, ngx_stream_upstream_t *u,
680680
}
681681

682682
if (val.len == 0) {
683+
u->peer.local = NULL;
683684
return NGX_OK;
684685
}
685686

@@ -696,6 +697,7 @@ ngx_stream_proxy_set_local(ngx_stream_session_t *s, ngx_stream_upstream_t *u,
696697
if (rc != NGX_OK) {
697698
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
698699
"invalid local address \"%V\"", &val);
700+
u->peer.local = NULL;
699701
return NGX_OK;
700702
}
701703

0 commit comments

Comments
 (0)