iRy*_*ell 6 lua nginx luasocket luajit luarocks
当我使用以下脚本时:
local smtp = require("socket.smtp")
local from = "from@host"
local rcpt = "rcpt@host"
local msg = {
headers = {
to = rcpt,
subject = "Hi"
},
body = "Hello"
}
smtp.send{from = from,rcpt = rcpt,source = smtp.message(msg)}
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息:lua entry thread aborted: runtime error: attempt to yield across C-call boundary.
我正在使用Lua 5.1 的最新luasocket安装,luarocks使用与LuaJIT 2.1编译的nginx.是什么导致此错误消息,我该如何解决?
smtp.send使用LuaSocket的socket.protect函数来处理内部错误。此函数是用 C 实现的,并且不允许在当前版本中生成(git HEAD 中的版本现在允许在 Lua 5.2+ 上生成,请参阅此处的讨论)。显然有人试图从其中屈服。在etc/dispatch.luaLuaSocket 包中(最好使用 git HEAD 版本)有一个替换函数,socket.protect它应该允许在所有 Lua 版本上进行屈服(以额外的临时协程为代价)。您可以尝试用 Lua 函数替换 C 函数,如下所示:
local socket = require("socket")
local base = _G
-- paste modified socket.protect function here
-- continue with your own code:
local smtp = require("socket.smtp")
-- ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2554 次 |
| 最近记录: |