Upstream: pass the correct state when freeing the last peer #959
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
peer.freeis called fromngx_http_upstream_next1, thestateargument is correctly passed. But for the last attempt that doesn't
finally enter
ngx_http_upstream_next,peer.freeis called fromngx_http_upstream_finalize_request2 with thestatebeing 0, in thiscase the last attempt is always considered successful. But in fact it
may be unsuccessful. Therefore the status should also be checked there
in order to pass the correct
state.This PR checks status against
u->conf->next_upstreamand if it should beconsidered unsuccessful, the
stateis set toNGX_PEER_FAILEDbeforepeer.freeis called.Proposed changes
Describe the use case and detail of the change.
If this pull request addresses an issue on GitHub, make sure to reference that
issue using one of the
supported keywords.
Before creating a pull request, make sure to comply with the
Contributing Guidelines.