Mercurial > hg > nginx
comparison src/core/ngx_open_file_cache.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 | 47ece8818978 |
children | 6b479db5b52b |
comparison
equal
deleted
inserted
replaced
4496:be6c250b827b | 4497:95ab6658654a |
---|---|
1140 continue; | 1140 continue; |
1141 } | 1141 } |
1142 | 1142 |
1143 /* hash == node->key */ | 1143 /* hash == node->key */ |
1144 | 1144 |
1145 do { | 1145 file = (ngx_cached_open_file_t *) node; |
1146 file = (ngx_cached_open_file_t *) node; | 1146 |
1147 | 1147 rc = ngx_strcmp(name->data, file->name); |
1148 rc = ngx_strcmp(name->data, file->name); | 1148 |
1149 | 1149 if (rc == 0) { |
1150 if (rc == 0) { | 1150 return file; |
1151 return file; | 1151 } |
1152 } | 1152 |
1153 | 1153 node = (rc < 0) ? node->left : node->right; |
1154 node = (rc < 0) ? node->left : node->right; | |
1155 | |
1156 } while (node != sentinel && hash == node->key); | |
1157 | |
1158 break; | |
1159 } | 1154 } |
1160 | 1155 |
1161 return NULL; | 1156 return NULL; |
1162 } | 1157 } |
1163 | 1158 |