Klaus Demo nginx / 1602ae6
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. Roman Arutyunyan 4 years ago
1 changed file(s) with 6 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
16761676 u = s->upstream;
16771677 pc = u->peer.connection;
16781678
1679 if (u->upstream_out || u->upstream_busy || (pc && pc->buffered)) {
1679 if (pc && pc->buffered) {
16801680 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
1681 "pending buffers on next upstream");
1681 "buffered data on next upstream");
16821682 ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
16831683 return;
1684 }
1685
1686 if (s->connection->type == SOCK_DGRAM) {
1687 u->upstream_out = NULL;
16841688 }
16851689
16861690 if (u->peer.sockaddr) {