感谢您的回复
系统信息:
gcc version 4.4.7
CentOS release 6.4 i386 GNU/Linux
软件版本:
ngx_openresty-1.4.3.6
编译过程:
yum install readline-devel pcre-devel openssl-devel
./configure --with-luajit
make && make install
简化了问题重现的步骤:
一、nginx.conf:
user www;
worker_processes 1;
daemon on;
events {
worker_connections 1024;
}
http {
root /usr/local/webserver/www;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
server {
listen 80 so_keepalive=2s:2s:8;
server_name localhost;
lua_code_cache off;
lua_check_client_abort on;
error_log /usr/local/webserver/wwwroot/comet/error.log;
location /test {
content_by_lua_file /usr/local/webserver/wwwroot/comet/test.lua;
}
}
}
二、test.lua
ngx.on_abort(function ()
ngx.log(ngx.ERR, "cleanup\n")
end)
ngx.log(ngx.ERR, "startup\n")
ngx.say("hello")
ngx.sleep(10)
三、日志信息
2014/03/20 08:12:18 [error] 2192#0: *4 [lua] test.lua:5: startup , client: 192.168.1.104, server: localhost, request: "GET /test HTTP/1.1", host: "localhost"
从error.log文件来看,总是只能看到startup,却看不到cleanup。
在 2014-03-21 02:54:39,"Yichun Zhang (agentzh)" <age...@gmail.com> 写道:
>Hello!
>
>2014-03-20 5:54 GMT-07:00 晋勇:
>> 在使用Ngx + Lua + Redis做comet,为了检测客户端异常断开,开启了lua_check_client_abort
>> on,并设置了ngx.on_abort回调。
>> 在5秒钟左右客户端立刻断开,ngx.on_abort可以正常执行,但之后就没有任何反应。
>
>你提供的信息是如此之少,以至于我并不能作出任何有价值的判断。你需要至少提供下面这些信息:
>
>1. 你使用的相关软件的版本(包括 nginx, ngx_lua, lua-resty-redis, OS 等等)。如果你使用的是
>openresty 软件包,请提供 openresty 软件包的版本号。
>
>2. 请提供一个完整的最小化的例子,以及复现问题所需的具体步骤。尽量去掉不相关的细节和外部依赖项,以便我们能在自己的环境里复现你看到的问题。
>
>3. 如果你无法得到一个最小化的例子,请提供你的关键部分的 Lua 代码片段。毕竟 Lua 是一种很灵活的语言,同一个接口有 N
>种不同的玩法。另外,提供问题请求对应的 nginx 调试日志也可能会很有帮助,见
>http://nginx.org/en/docs/debugging_log.html
>
>> 在google查了很久原因,找到了一篇:
>> https://groups.google.com/forum/#!msg/openresty/NjpEuRA-N0s/hPKtZHrNGVsJ,和我
>> 遇到的问题同样,看讨论的结果是这个Bug是提早GC引起的
>
>你提供的信息并不足以确认是同一个问题,甚至不足以确认是 ngx_lua 的 bug. 请不要过于草率地下结论,以免浪费时间。
>
>另外,建议加入 openresty 中文邮件列表并在那里讨论这样的问题,谢谢合作!见
>https://groups.google.com/group/openresty
>
>同时抄送给 openresty 邮件列表。
>
>Regards,
>-agentzh