主要是这一段:
ngx_shmtx_lock(&ctx->shpool->mutex);
lua_newtable(L);
int i = 1;
for (q = ngx_queue_head(&ctx->sh->queue);
q != ngx_queue_sentinel(&ctx->sh->queue);
q = ngx_queue_next(q)) {
sd = ngx_queue_data(q, ngx_http_lua_shdict_node_t,
queue);
lua_pushlstring(L, (char
*) sd->data, sd->key_len);
lua_rawseti(L, -2, i++);
}
ngx_shmtx_unlock(&ctx->shpool->mutex);
毕竟对整个TREE,其他线程都阻塞了。
我想实现一个类似切换DUMP的功能,dump那一刻,切换入口到新的tree上,新tree是老的tree的复制,从入口开始遍历全部NODE即可。
铁轮
---------------------------------
一淘--广告技术
发件人:
铁轮
发送时间: 2012年10月20日 14:40
收件人: 'smallfish'; openresty@googlegroups.com
主题: 答复: [openresty] Re: ngx.shared.DICT遍历操作
Hi
smallfish
验证了你的实现,可以通过。不过我有一个问题在于,做keys操作的时候,锁会不会阻塞整个worker?如果时间长了,其他的写入会不会受到影响。
铁轮
---------------------------------
一淘--广告技术
发件人: smallfish [mailto:small...@gmail.com]
发送时间: 2012年10月20日 9:05
收件人: openresty@googlegroups.com
抄送: 铁轮
主题: Re: [openresty] Re: ngx.shared.DICT遍历操作
我之前也写过所有keys的一个补丁,章老师看看?呵呵。https://gist.github.com/74439ea9fac084e43932
--