comparison src/http/modules/ngx_http_limit_req_module.c @ 4858:5e789d8b009d stable-1.2

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 24 Sep 2012 19:11:45 +0000
parents 9be0b6b749ae
children 00e4459739ed
comparison
equal deleted inserted replaced
4857:880dedfa4008 4858:5e789d8b009d
442 } 442 }
443 } 443 }
444 444
445 node->key = hash; 445 node->key = hash;
446 446
447 ngx_rbtree_insert(&ctx->sh->rbtree, node);
448
449 lr = (ngx_http_limit_req_node_t *) &node->color; 447 lr = (ngx_http_limit_req_node_t *) &node->color;
450
451 ngx_queue_insert_head(&ctx->sh->queue, &lr->queue);
452 448
453 lr->len = (u_char) len; 449 lr->len = (u_char) len;
454 lr->excess = 0; 450 lr->excess = 0;
455 451
456 ngx_memcpy(lr->data, data, len); 452 ngx_memcpy(lr->data, data, len);
453
454 ngx_rbtree_insert(&ctx->sh->rbtree, node);
455
456 ngx_queue_insert_head(&ctx->sh->queue, &lr->queue);
457 457
458 if (account) { 458 if (account) {
459 lr->last = now; 459 lr->last = now;
460 lr->count = 0; 460 lr->count = 0;
461 return NGX_OK; 461 return NGX_OK;