Klaus Demo nginx / c9fbbc8
Limit req: reduced number of parameters in the lookup function. No functional changes. Valentin Bartenev 5 years ago
1 changed file(s) with 7 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
5757
5858 static void ngx_http_limit_req_delay(ngx_http_request_t *r);
5959 static ngx_int_t ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit,
60 ngx_uint_t hash, u_char *data, size_t len, ngx_uint_t *ep,
61 ngx_uint_t account);
60 ngx_uint_t hash, ngx_str_t *key, ngx_uint_t *ep, ngx_uint_t account);
6261 static ngx_msec_t ngx_http_limit_req_account(ngx_http_limit_req_limit_t *limits,
6362 ngx_uint_t n, ngx_uint_t *ep, ngx_http_limit_req_limit_t **limit);
6463 static void ngx_http_limit_req_expire(ngx_http_limit_req_ctx_t *ctx,
206205
207206 ngx_shmtx_lock(&ctx->shpool->mutex);
208207
209 rc = ngx_http_limit_req_lookup(limit, hash, key.data, key.len, &excess,
208 rc = ngx_http_limit_req_lookup(limit, hash, &key, &excess,
210209 (n == lrcf->limits.nelts - 1));
211210
212211 ngx_shmtx_unlock(&ctx->shpool->mutex);
358357
359358 static ngx_int_t
360359 ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit, ngx_uint_t hash,
361 u_char *data, size_t len, ngx_uint_t *ep, ngx_uint_t account)
360 ngx_str_t *key, ngx_uint_t *ep, ngx_uint_t account)
362361 {
363362 size_t size;
364363 ngx_int_t rc, excess;
393392
394393 lr = (ngx_http_limit_req_node_t *) &node->color;
395394
396 rc = ngx_memn2cmp(data, lr->data, len, (size_t) lr->len);
395 rc = ngx_memn2cmp(key->data, lr->data, key->len, (size_t) lr->len);
397396
398397 if (rc == 0) {
399398 ngx_queue_remove(&lr->queue);
433432
434433 size = offsetof(ngx_rbtree_node_t, color)
435434 + offsetof(ngx_http_limit_req_node_t, data)
436 + len;
435 + key->len;
437436
438437 ngx_http_limit_req_expire(ctx, 1);
439438
454453
455454 lr = (ngx_http_limit_req_node_t *) &node->color;
456455
457 lr->len = (u_short) len;
456 lr->len = (u_short) key->len;
458457 lr->excess = 0;
459458
460 ngx_memcpy(lr->data, data, len);
459 ngx_memcpy(lr->data, key->data, key->len);
461460
462461 ngx_rbtree_insert(&ctx->sh->rbtree, node);
463462