comparison src/core/ngx_resolver.c @ 4515:8bb695c05870 stable-1.0

Merge of r4498: Fix of rbtree lookup on hash collisions. Previous code incorrectly assumed that nodes with identical keys are linked together. This might not be true after tree rebalance. Patch by Lanshun Zhou.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 05 Mar 2012 13:17:56 +0000
parents 79142134d616
children
comparison
equal deleted inserted replaced
4514:79142134d616 4515:8bb695c05870
1624 continue; 1624 continue;
1625 } 1625 }
1626 1626
1627 /* hash == node->key */ 1627 /* hash == node->key */
1628 1628
1629 do { 1629 rn = (ngx_resolver_node_t *) node;
1630 rn = (ngx_resolver_node_t *) node; 1630
1631 1631 rc = ngx_memn2cmp(name->data, rn->name, name->len, rn->nlen);
1632 rc = ngx_memn2cmp(name->data, rn->name, name->len, rn->nlen); 1632
1633 1633 if (rc == 0) {
1634 if (rc == 0) { 1634 return rn;
1635 return rn; 1635 }
1636 } 1636
1637 1637 node = (rc < 0) ? node->left : node->right;
1638 node = (rc < 0) ? node->left : node->right;
1639
1640 } while (node != sentinel && hash == node->key);
1641
1642 break;
1643 } 1638 }
1644 1639
1645 /* not found */ 1640 /* not found */
1646 1641
1647 return NULL; 1642 return NULL;