Merge of r4833: limit req: fix of rbtree node insertion.
Limit req: fix of rbtree node insertion on hash collisions.
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.
Maxim Dounin
9 years ago
443 | 443 | |
444 | 444 | node->key = hash; |
445 | 445 | |
446 | ngx_rbtree_insert(&ctx->sh->rbtree, node); | |
447 | ||
448 | 446 | lr = (ngx_http_limit_req_node_t *) &node->color; |
449 | ||
450 | ngx_queue_insert_head(&ctx->sh->queue, &lr->queue); | |
451 | 447 | |
452 | 448 | lr->len = (u_char) len; |
453 | 449 | lr->excess = 0; |
454 | 450 | |
455 | 451 | ngx_memcpy(lr->data, data, len); |
452 | ||
453 | ngx_rbtree_insert(&ctx->sh->rbtree, node); | |
454 | ||
455 | ngx_queue_insert_head(&ctx->sh->queue, &lr->queue); | |
456 | 456 | |
457 | 457 | if (account) { |
458 | 458 | lr->last = now; |