comparison src/core/ngx_resolver.c @ 4497:95ab6658654a

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, 27 Feb 2012 22:15:39 +0000
parents be6c250b827b
children 1bddc91e78d6
comparison
equal deleted inserted replaced
4496:be6c250b827b 4497:95ab6658654a
1687 continue; 1687 continue;
1688 } 1688 }
1689 1689
1690 /* hash == node->key */ 1690 /* hash == node->key */
1691 1691
1692 do { 1692 rn = (ngx_resolver_node_t *) node;
1693 rn = (ngx_resolver_node_t *) node; 1693
1694 1694 rc = ngx_memn2cmp(name->data, rn->name, name->len, rn->nlen);
1695 rc = ngx_memn2cmp(name->data, rn->name, name->len, rn->nlen); 1695
1696 1696 if (rc == 0) {
1697 if (rc == 0) { 1697 return rn;
1698 return rn; 1698 }
1699 } 1699
1700 1700 node = (rc < 0) ? node->left : node->right;
1701 node = (rc < 0) ? node->left : node->right;
1702
1703 } while (node != sentinel && hash == node->key);
1704
1705 break;
1706 } 1701 }
1707 1702
1708 /* not found */ 1703 /* not found */
1709 1704
1710 return NULL; 1705 return NULL;