Hello!
2014-11-28 0:00 GMT-08:00 Chan WingChung:
> 2014/11/28 15:57:21 [error] 2719#0: *2 lua entry thread aborted: runtime
> error: attempt to yield across C-call boundary
引用一下官方文档中的说明:
https://github.com/openresty/lua-nginx-module#lua-coroutine-yieldingresuming
"Because Lua's dofile and require builtins are currently implemented
as C functions in both Lua 5.1 and LuaJIT 2.0/2.1, if the Lua file
being loaded by dofile or require invokesngx.location.capture*,
ngx.exec, ngx.exit, or other API functions requiring yielding in the
top-levelscope of the Lua file, then the Lua error "attempt to yield
across C-call boundary" will be raised. To avoid this, put these calls
requiring yielding into your own Lua functions in the Lua file instead
of the top-level scope of the file."
对于你这里的情况,建议尽量把你的需要 yield 的操作封装在你自己的 Lua 函数中,然后在加载你的 Lua module 文件之后,再进行调用,例如
local foo = require "foo"
foo.go() -- this may use nonblocking I/O and other things
requiring yielding
Regards,
-agentzh