1
0
mirror of https://github.com/apache/httpd.git synced 2026-01-06 09:01:14 +03:00
Files
apache/modules
Luca Toscano 17c16cc654 mod_ratelimit: fix behavior with proxied content
mod_ratelimit works by splitting data in "chunks"
to send to the client, sleeping a predefined amount
of time between them (200ms). So for example,
a rate-limit 40 value would correspond to a chunk size
of 8192 bytes, flushed to the client every 200ms.

The idea works fine when httpd directly serves the
content, since the filter will be called once with
a single bucket brigade. In the context of a proxied
content though the filter is likely to be called multiple
times, with a bucket brigade size that corresponds to
the maximum allowed buffer size. If this value is lower
or higher than the chunk size, the filter will not
properly rate limit the data going to the client.

This patch solves the problem with two fix:
1) do_sleep is now stored in the ctx context struct,
   so if the filter is invoked multiple times it
   will still sleep when needed. For example, say
   that the chunk_size is 8192 and the bucket brigate
   len is 10240: the filter will flush 8192 bytes
   on the first invocation, sleep 200ms, flush the
   remaining bytes and then finish. The next invocation
   will do the same, clearly not leading to the
   correct "sleeping pattern".
2) The example above highlights also another issue:
   mod_ratelimit should  flush only chunk_size bytes
   at the time (I am now excluding the burst calculation
   from the picture), and buffer between invocations
   unless the brigade contains EOS.

The change has been tested with various scenarios and
it looks working as expected, but of course more
feedback/testing is welcome.

The original patch was written by me and then Yann
refactored the code to be more precise and efficient,
basically transforming an axe in a wonderful Japanese
katana sword, so credits to him for this work.

PR: 62362




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1833875 13f79535-47bb-0310-9956-ffa450edef68
2018-06-19 22:28:24 +00:00
..
2018-02-26 18:36:15 +00:00
2014-07-19 22:02:53 +00:00
2018-02-17 14:35:53 +00:00
2014-10-10 19:53:02 +00:00
2018-06-12 17:14:23 +00:00
2018-05-24 20:59:44 +00:00
2018-03-24 20:05:19 +00:00
2018-06-15 14:35:31 +00:00
2018-06-15 14:35:31 +00:00

The directory structure for this level is as follows:

aaa/
  This directory contains modules dealing with authorization and
  authentication.

arch/

cache/
  This directory houses modules that implement file and data caching
  capability.

database/
  The apache DBD framework manages connections to SQL backends efficiently.

cluster/
  Modules for working with multiple servers.

dav/
  This directory houses modules that implement WebDAV functionality.

echo/

examples/
  This directory contains some sample code that should help you on your
  way to develop your own Apache modules.  

experimental/
  In this directory we've placed some modules which we think
  provide some pretty interesting functionality, but which
  are still in the early stages of development and could
  evolve radically in the future.  This code isn't supported
  officially.

filters/
  This directory houses modules that perform general inline data filtering.

generators/
  This directory houses modules that perform data generation functions.

http/
  This directory houses modules that basic HTTP protocol implementation.

http2/
  This directory houses modules that provide HTTP/2 protocol implementation.

loggers/
  This directory houses modules that handle logging functions.

mappers/
  This directory houses modules that handle URL mapping and
  rewriting.

metadata/
  This directory houses modules that deal with Header metadata.

proxy/
  This houses the code for the proxy module for Apache.

ssl/
  This directory houses code for OpenSSL functionality.

test/
  This directory houses modules which test various components 
  of Apache.  You should not compile these into a production
  server.