aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2017-09-11 15:32:31 +0300
committerRoman Arutyunyan <arut@nginx.com>2017-09-11 15:32:31 +0300
commit15f81e0bbf42d8bc6e70a06800720eb9d927efdd (patch)
tree4292debebf6b66d87021aba615734d42fb705aa1
parent13e29a65f6ae5895a9d3ec5c110149c553fc634a (diff)
downloadnginx-15f81e0bbf42d8bc6e70a06800720eb9d927efdd.tar.gz
nginx-15f81e0bbf42d8bc6e70a06800720eb9d927efdd.zip
Stream: relaxed next upstream condition (ticket #1317).
When switching to a next upstream, some buffers could be stuck in the middle of the filter chain. A condition existed that raised an error when this happened. As it turned out, this condition prevented switching to a next upstream if ssl preread was used with the TCP protocol (see the ticket). In fact, the condition does not make sense for TCP, since after successful connection to an upstream switching to another upstream never happens. As for UDP, the issue with stuck buffers is unlikely to happen, but is still possible. Specifically, if a filter delays sending data to upstream. The condition can be relaxed to only check the "buffered" bitmask of the upstream connection. The new condition is simpler and fixes the ticket issue as well. Additionally, the upstream_out chain is now reset for UDP prior to connecting to a new upstream to prevent repeating the client data twice.
-rw-r--r--src/stream/ngx_stream_proxy_module.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c
index 0afde1c40..395e0f650 100644
--- a/src/stream/ngx_stream_proxy_module.c
+++ b/src/stream/ngx_stream_proxy_module.c
@@ -1665,13 +1665,17 @@ ngx_stream_proxy_next_upstream(ngx_stream_session_t *s)
u = s->upstream;
pc = u->peer.connection;
- if (u->upstream_out || u->upstream_busy || (pc && pc->buffered)) {
+ if (pc && pc->buffered) {
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
- "pending buffers on next upstream");
+ "buffered data on next upstream");
ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
return;
}
+ if (s->connection->type == SOCK_DGRAM) {
+ u->upstream_out = NULL;
+ }
+
if (u->peer.sockaddr) {
u->peer.free(&u->peer, u->peer.data, NGX_PEER_FAILED);
u->peer.sockaddr = NULL;