Nginx源代码分析--基本数据结构--hash
来源:互联网 发布:天猫历年双11数据分析 编辑:程序博客网 时间:2024/05/22 13:54
Nginx的查找函数逻辑相对简单,即根据要查找的key-value的key,计算出其所在的桶,比较该key和桶中所有key-value对的key的长度是否一致,如果一致,则进行继续key的值的比较。如果key的值也一直,则获取该key对应value的指针。
具体函数如下:
void *
ngx_hash_find(ngx_hash_t *hash, ngx_uint_t key, u_char *name, size_t len)
{
ngx_uint_t i;
ngx_hash_elt_t *elt;
#if 0
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "hf:/"%*s/"", len, name);
#endif
elt = hash->buckets[key % hash->size];
if (elt == NULL) {
return NULL;
}
while (elt->value) {
if (len != (size_t) elt->len) {
goto next;
}
for (i = 0; i < len; i++) {
if (name[i] != elt->name[i]) {
goto next;
}
}
return elt->value;
next:
elt = (ngx_hash_elt_t *) ngx_align_ptr(&elt->name[0] + elt->len,
sizeof(void *));
continue;
}
return NULL;
}
- Nginx源代码分析--基本数据结构--hash
- Nginx源代码分析--基本数据结构--hash
- Nginx源代码分析--基本数据结构--hash
- Nginx源代码分析--基本数据结构--hash
- Nginx源代码分析--基本数据结构--hash
- Nginx源代码分析--基本数据结构--hash
- Nginx源代码分析--基本数据结构--hash
- nginx 基本hash的初始化 源码分析
- Nginx源码分析之基本数据结构
- 数据结构基本操作源代码
- nginx源代码分析
- nginx源代码分析
- nginx源代码分析
- Nginx 基本数据结构
- Nginx基本数据结构
- 【nginx】基本数据结构
- [nginx源码分析]server_name hash
- Nginx源码分析 - 基础数据结构篇 - hash表结构 ngx_hash.c
- Design Pattern: Mediator 模式
- Minix中fork函数的实现
- 对计算机综合的体会
- winform开机自动启动设置
- Android-kernel】Android 内核改动
- Nginx源代码分析--基本数据结构--hash
- Mysql 备份还原和一些常用操作语句
- JAVA高级01_03 String类学习 2011-4-20
- Firefox直接打开PDF
- android: MapView加载多个 overlay 内存溢出
- 在ubuntu10.10下我按照以下步骤配置tftp
- 转: 某个异常
- hibernate的helloworld
- tomcat6中的内存设置问题