Welcome! Log In Create A New Profile

Advanced

[nginx] Limit req: reduced number of parameters in the lookup fu...

Valentin Bartenev
September 24, 2014 01:58PM
details: http://hg.nginx.org/nginx/rev/102f85699420
branches:
changeset: 5863:102f85699420
user: Valentin Bartenev <vbart@nginx.com>
date: Wed Sep 24 21:55:19 2014 +0400
description:
Limit req: reduced number of parameters in the lookup function.

No functional changes.

diffstat:

src/http/modules/ngx_http_limit_req_module.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)

diffs (62 lines):

diff -r ecbb99aa0e12 -r 102f85699420 src/http/modules/ngx_http_limit_req_module.c
--- a/src/http/modules/ngx_http_limit_req_module.c Wed Sep 24 21:55:19 2014 +0400
+++ b/src/http/modules/ngx_http_limit_req_module.c Wed Sep 24 21:55:19 2014 +0400
@@ -58,8 +58,7 @@ typedef struct {

static void ngx_http_limit_req_delay(ngx_http_request_t *r);
static ngx_int_t ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit,
- ngx_uint_t hash, u_char *data, size_t len, ngx_uint_t *ep,
- ngx_uint_t account);
+ ngx_uint_t hash, ngx_str_t *key, ngx_uint_t *ep, ngx_uint_t account);
static ngx_msec_t ngx_http_limit_req_account(ngx_http_limit_req_limit_t *limits,
ngx_uint_t n, ngx_uint_t *ep, ngx_http_limit_req_limit_t **limit);
static void ngx_http_limit_req_expire(ngx_http_limit_req_ctx_t *ctx,
@@ -207,7 +206,7 @@ ngx_http_limit_req_handler(ngx_http_requ

ngx_shmtx_lock(&ctx->shpool->mutex);

- rc = ngx_http_limit_req_lookup(limit, hash, key.data, key.len, &excess,
+ rc = ngx_http_limit_req_lookup(limit, hash, &key, &excess,
(n == lrcf->limits.nelts - 1));

ngx_shmtx_unlock(&ctx->shpool->mutex);
@@ -359,7 +358,7 @@ ngx_http_limit_req_rbtree_insert_value(n

static ngx_int_t
ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit, ngx_uint_t hash,
- u_char *data, size_t len, ngx_uint_t *ep, ngx_uint_t account)
+ ngx_str_t *key, ngx_uint_t *ep, ngx_uint_t account)
{
size_t size;
ngx_int_t rc, excess;
@@ -394,7 +393,7 @@ ngx_http_limit_req_lookup(ngx_http_limit

lr = (ngx_http_limit_req_node_t *) &node->color;

- rc = ngx_memn2cmp(data, lr->data, len, (size_t) lr->len);
+ rc = ngx_memn2cmp(key->data, lr->data, key->len, (size_t) lr->len);

if (rc == 0) {
ngx_queue_remove(&lr->queue);
@@ -434,7 +433,7 @@ ngx_http_limit_req_lookup(ngx_http_limit

size = offsetof(ngx_rbtree_node_t, color)
+ offsetof(ngx_http_limit_req_node_t, data)
- + len;
+ + key->len;

ngx_http_limit_req_expire(ctx, 1);

@@ -455,10 +454,10 @@ ngx_http_limit_req_lookup(ngx_http_limit

lr = (ngx_http_limit_req_node_t *) &node->color;

- lr->len = (u_short) len;
+ lr->len = (u_short) key->len;
lr->excess = 0;

- ngx_memcpy(lr->data, data, len);
+ ngx_memcpy(lr->data, key->data, key->len);

ngx_rbtree_insert(&ctx->sh->rbtree, node);


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Limit req: reduced number of parameters in the lookup fu...

Valentin Bartenev 548 September 24, 2014 01:58PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 187
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready