summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/ngx_http_limit_req_module.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-10-08Limit req: unlocking of nodes on complex value errors.Maxim Dounin1-15/+27
Previously, if there were multiple limits configured, errors in ngx_http_complex_value() during processing of a non-first limit resulted in reference count leak in shared memory nodes of already processed limits. Fix is to explicity unlock relevant nodes, much like we do when rejecting requests.
2019-11-06Limit req: $limit_req_status variable.Roman Arutyunyan1-4/+75
The variable takes one of the values: PASSED, DELAYED, REJECTED, DELAYED_DRY_RUN or REJECTED_DRY_RUN.
2019-06-05Limit req: limit_req_dry_run directive.Roman Arutyunyan1-4/+25
A new directive limit_req_dry_run allows enabling the dry run mode. In this mode requests are neither rejected nor delayed, but reject/delay status is logged as usual.
2018-11-21Limit req: "delay=" parameter.Maxim Dounin1-10/+22
This parameter specifies an additional "soft" burst limit at which requests become delayed (but not yet rejected as it happens if "burst=" limit is exceeded). Defaults to 0, i.e., all excess requests are delayed. Originally inspired by Vladislav Shabanov (http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008126.html). Further improved based on a patch by Peter Shchuchkin (http://mailman.nginx.org/pipermail/nginx-devel/2018-October/011522.html).
2018-11-21Limit req: fixed error message wording.Maxim Dounin1-1/+1
2018-05-30Limit req: improved handling of negative times.Maxim Dounin1-4/+25
Negative times can appear since workers only update time on an event loop iteration start. If a worker was blocked for a long time during an event loop iteration, it is possible that another worker already updated the time stored in the node. As such, time since last update of the node (ms) will be negative. Previous code used ngx_abs(ms) in the calculations. That is, negative times were effectively treated as positive ones. As a result, it was not possible to maintain high request rates, where the same node can be updated multiple times from during an event loop iteration. In particular, this affected setups with many SSL handshakes, see http://mailman.nginx.org/pipermail/nginx/2018-May/056291.html. Fix is to only update the last update time stored in the node if the new time is larger than previously stored one. If a future time is stored in the node, we preserve this time as is. To prevent breaking things on platforms without monotonic time available if system time is updated backwards, a safety limit of 60 seconds is used. If the time stored in the node is more than 60 seconds in the future, we assume that the time was changed backwards and update lr->last to the current time.
2017-04-02Moved handling of wev->delayed to the connection event handler.Maxim Dounin1-4/+1
With post_action or subrequests, it is possible that the timer set for wev->delayed will expire while the active subrequest write event handler is not ready to handle this. This results in request hangs as observed with limit_rate / sendfile_max_chunk and post_action (ticket #776) or subrequests (ticket #1228). Moving the handling to the connection event handler fixes the hangs observed, and also slightly simplifies the code.
2017-04-02Limit req: fixed delaying subrequests.Maxim Dounin1-1/+4
Since limit_req uses connection's write event to delay request processing, it can conflict with timers in other subrequests. In particular, even if applied to an active subrequest, it can break things if wev->delayed is already set (due to limit_rate or sendfile_max_chunk), since after limit_req finishes the wev->delayed flag will be set and no timer will be active. Fix is to use the wev->delayed flag in limit_req as well. This ensures that wev->delayed won't be set after limit_req finishes, and also ensures that limit_req's timers will be properly handled by other subrequests if the one delayed by limit_req is not active.
2016-08-08Simplified extraction of current time.Ruslan Ermilov1-11/+3
2015-04-20Limit req: removed check for unknown limit_req_zone.Sergey Kandaurov1-7/+0
With 48b3d5ddfb03, it's possible to specify limit_req_zone after limit_req.
2014-09-24Limit req: reduced number of parameters in the lookup function.Valentin Bartenev1-8/+7
No functional changes.
2014-09-24Limit req: use complex value in limit_req_zone.Valentin Bartenev1-60/+47
One intentional side effect of this change is that key is allowed only in the first position. Previously, it was possible to specify the key variable at any position, but that was never documented, and is contrary with nginx configuration practice for positional parameters.
2014-09-16Limit req: don't truncate key value to 255 bytes.Valentin Bartenev1-1/+1
While the module allows to use values up to 65535 bytes as a key, that actually never worked properly.
2014-03-31Core: slab log_nomem flag.Maxim Dounin1-0/+4
The flag allows to suppress "ngx_slab_alloc() failed: no memory" messages from a slab allocator, e.g., if an LRU expiration is used by a consumer and allocation failures aren't fatal. The flag is now used in the SSL session cache code, and in the limit_req module.
2013-10-02Limit req: fixed "nodelay" parsing.Maxim Dounin1-1/+1
Previously arguments starting with "nodelay" were considered valid, e.g. "limit_req ... nodelayFOO;".
2013-04-03Limit req: rate should be non-zero.Valentin Bartenev1-1/+1
Specifying zero rate caused division by zero when calculating delays.
2013-03-18The limit_req_status and limit_conn_status directives.Maxim Dounin1-1/+18
Patch by Nick Marden, with minor changes.
2012-09-03Limit req: fix of rbtree node insertion on hash collisions.Valentin Bartenev1-4/+4
The rbtree used in ngx_http_limit_req_module has two level of keys, the top is hash, and the next is the value string itself. However, when inserting a new node, only hash has been set, while the value string has been left empty. The bug was introduced in r4419 (1.1.14). Found by Charles Chen.
2012-08-08Added three missing checks for NULL after ngx_array_push() calls.Valentin Bartenev1-0/+3
Found by Coverity.
2012-02-28Fixed spelling in single-line comments.Ruslan Ermilov1-2/+2
2012-02-27Fix of rbtree lookup on hash collisions.Maxim Dounin1-29/+24
Previous code incorrectly assumed that nodes with identical keys are linked together. This might not be true after tree rebalance. Patch by Lanshun Zhou.
2012-01-30Limit req: unbreak compilation with MSVC.Maxim Dounin1-0/+4
2012-01-30Limit req: support for multiple "limit_req" limits.Valentin Bartenev1-78/+229
2012-01-30Limit req: number of cleanup calls reduced.Valentin Bartenev1-2/+2
Doing a cleanup before every lookup seems to be too aggressive. It can lead to premature removal of the nodes still usable, which increases the amount of work under a mutex lock and therefore decreases performance. In order to improve cleanup behavior, cleanup function call has been moved right before the allocation of a new node.
2012-01-30Limit req: allocation and initialization of a new node moved to the lookupValentin Bartenev1-52/+45
function. No functional changes.
2012-01-30Limit req: improved error handling when parsing "zone" parameter ofValentin Bartenev1-15/+23
"limit_req_zone" directive; minimum size of zone is increased. Previously an unsigned variable was used to keep the return value of ngx_parse_size() function, which led to an incorrect zone size if NGX_ERROR was returned. The new code has been taken from the "limit_conn_zone" directive.
2012-01-30Limit req: error messages fixed.Valentin Bartenev1-4/+4
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2012-01-11Fixed limit_req burst/nodelay inheritance (ticket #76).Maxim Dounin1-0/+2
The problem was introduced in r4381 (1.1.12).
2011-12-25Fixed limit_conn_log_level/limit_req_log_level inheritance.Valentin Bartenev1-1/+1
The directives did not work if there were no limit_conn/limit_req specified on the same level.
2010-10-14change order of limit_req lookup result processingIgor Sysoev1-51/+48
2010-10-13an excess was logged as 0.000 if requests were limited without delay:Igor Sysoev1-18/+8
*) use a real excess value instead of non-updated limit_req rbtree node field, *) move inactivity queue handling inside ngx_http_limit_req_lookup() since the node is not required outside the lookup function; the bug has been introduced in r3184
2010-05-24fix delay in limit_reqIgor Sysoev1-1/+2
2009-10-06fix r3184Igor Sysoev1-4/+4
2009-10-06limit_req_log_levelIgor Sysoev1-3/+30
2009-10-06make limit_req to conform to the leaky bucket algorithmIgor Sysoev1-4/+5
2009-07-09style fixIgor Sysoev1-2/+2
2009-07-09fix client write event handling in ngx_http_limit_req_moduleIgor Sysoev1-0/+15
2009-06-02return NULL instead of NGX_CONF_ERROR on a create conf failureIgor Sysoev1-1/+1
2009-04-18support attaching to an existent Win32 shared memoryIgor Sysoev1-39/+44
2009-04-16move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memoryIgor Sysoev1-6/+8
2009-03-27delete duplicate error loggingIgor Sysoev1-5/+0
2009-03-27improve ngx_slab_alloc() error loggingIgor Sysoev1-0/+11
2008-12-08*) add zone name while logging 503 error reasonIgor Sysoev1-4/+9
*) log allocation error as 503 error reason
2008-12-08update commentIgor Sysoev1-1/+1
2008-12-08rename "lz" to "lr" in variable namesIgor Sysoev1-50/+50
2008-11-14use integer instead of floatIgor Sysoev1-22/+25
2008-11-14change rate to an excessIgor Sysoev1-17/+17
2008-11-11*) correct leaky bucket implementationIgor Sysoev1-58/+23
*) now burst is not per second *) remove delay= parameter *) add nodelay parameter
2008-11-10ngx_http_limit_req_moduleIgor Sysoev1-0/+794