]> git.kaiwu.me - nginx.git/commitdiff
Stream: do not split datagrams when limiting proxy rate.
authorRoman Arutyunyan <arut@nginx.com>
Thu, 27 Dec 2018 16:37:34 +0000 (19:37 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Thu, 27 Dec 2018 16:37:34 +0000 (19:37 +0300)
Previously, when using proxy_upload_rate and proxy_download_rate, the buffer
size for reading from a socket could be reduced as a result of rate limiting.
For connection-oriented protocols this behavior is normal since unread data will
normally be read at the next iteration.  But for datagram-oriented protocols
this is not the case, and unread part of the datagram is lost.

Now buffer size is not limited for datagrams.  Rate limiting still works in this
case by delaying the next reading event.

src/stream/ngx_stream_proxy_module.c

index ccb54188b112806164892d1d148b64f4056a8e37..d7bdec270e23ec81ffc333112d00c775c00dab30 100644 (file)
@@ -1593,7 +1593,7 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
                     break;
                 }
 
-                if ((off_t) size > limit) {
+                if (c->type == SOCK_STREAM && (off_t) size > limit) {
                     size = (size_t) limit;
                 }
             }