An official read-only mirror of http://hg.nginx.org/nginx/ which is updated hourly. Pull requests on GitHub cannot be accepted and will be automatically closed. The proper way to submit changes to nginx is via the nginx development mailing list, see http://nginx.org/en/docs/contributing_changes.html
Go to file
Aleksei Bavshin d7994be445 Stream: don't flush empty buffers created for read errors.
When we generate the last_buf buffer for an UDP upstream recv error, it does
not contain any data from the wire. ngx_stream_write_filter attempts to forward
it anyways, which is incorrect (e.g., UDP upstream ECONNREFUSED will be
translated to an empty packet).

This happens because we mark the buffer as both 'flush' and 'last_buf', and
ngx_stream_write_filter has special handling for flush with certain types of
connections (see d127837c714f, 32b0ba4855a6).  The flags are meant to be
mutually exclusive, so the fix is to ensure that flush and last_buf are not set
at the same time.

Reproduction:

stream {
    upstream unreachable {
        server     127.0.0.1:8880;
    }
    server {
        listen     127.0.0.1:8998 udp;
        proxy_pass unreachable;
    }
}

1 0.000000000    127.0.0.1 → 127.0.0.1    UDP 47 45588 → 8998 Len=5
2 0.000166300    127.0.0.1 → 127.0.0.1    UDP 47 51149 → 8880 Len=5
3 0.000172600    127.0.0.1 → 127.0.0.1    ICMP 75 Destination unreachable (Port
unreachable)
4 0.000202400    127.0.0.1 → 127.0.0.1    UDP 42 8998 → 45588 Len=0

Fixes d127837c714f.
2022-05-23 11:29:44 -07:00
auto Configure: recognize arm64 machine name as a synonym for aarch64. 2022-04-29 17:38:01 +04:00
conf MIME: added image/avif type. 2021-10-25 20:49:15 +03:00
contrib Contrib: vim syntax adjusted to save cpoptions (ticket #2276). 2022-01-22 00:28:51 +03:00
docs Year 2022. 2022-02-04 13:29:31 +03:00
misc Updated OpenSSL and zlib used for win32 builds. 2022-05-24 02:51:49 +03:00
src Stream: don't flush empty buffers created for read errors. 2022-05-23 11:29:44 -07:00
.hgtags release-1.21.6 tag 2022-01-25 18:03:52 +03:00