comparison src/stream/ngx_stream_proxy_module.c @ 7142:b9d919b53593 stable-1.12

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.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 11 Sep 2017 15:32:31 +0300
parents ee3645078759
children
comparison
equal deleted inserted replaced
7141:dfa0250bf222 7142:b9d919b53593
1675 "stream proxy next upstream"); 1675 "stream proxy next upstream");
1676 1676
1677 u = s->upstream; 1677 u = s->upstream;
1678 pc = u->peer.connection; 1678 pc = u->peer.connection;
1679 1679
1680 if (u->upstream_out || u->upstream_busy || (pc && pc->buffered)) { 1680 if (pc && pc->buffered) {
1681 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, 1681 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
1682 "pending buffers on next upstream"); 1682 "buffered data on next upstream");
1683 ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); 1683 ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
1684 return; 1684 return;
1685 }
1686
1687 if (s->connection->type == SOCK_DGRAM) {
1688 u->upstream_out = NULL;
1685 } 1689 }
1686 1690
1687 if (u->peer.sockaddr) { 1691 if (u->peer.sockaddr) {
1688 u->peer.free(&u->peer, u->peer.data, NGX_PEER_FAILED); 1692 u->peer.free(&u->peer, u->peer.data, NGX_PEER_FAILED);
1689 u->peer.sockaddr = NULL; 1693 u->peer.sockaddr = NULL;