Hello!
On Mon, Apr 7, 2014 at 11:51 PM, TruthTracer wrote:
> 最近我在用ngx_lua时发现 若某个socket上没有数据时,sock:receive(number)不会在设定的timeout后返回
> 具体代码如下:
> sock:settimeout(10)
> ngx.thread.spawn(thead_func, sock)
> local function thread_func(sock)
> while true do
> d, e, r = sock:receive(3) <======= block在这里,未在10ms后超时返回
> -- 处理业务逻辑
> end
> end
> 请问我的调用方法是否正确?
请提供一个最小化的完整用例,以便我可以在我本地复现你看到的问题。
ngx_lua 模块的测试集中专门针对此种情形的测试用例,在我这里是通过的:
https://github.com/chaoslawful/lua-nginx-module/blob/master/t/065-tcp-socket-timeout.t#L884
同时抄送给 openresty 中文邮件列表:https://groups.google.com/group/openresty
建议你也加入此列表并在那里讨论这样的问题,谢谢合作!
Regards,
-agentzh