luajit下编译luasocket模块出错

352 views
Skip to first unread message

XinQi Yang

unread,
Oct 5, 2013, 11:35:41 AM10/5/13
to open...@googlegroups.com
章哥,玉哥求助下.

最近在做 lua 下的请求转发用到了 https://github.com/catwell/lua-multipart-post 
这个multipart-post的模块,模块依赖于 https://github.com/fire/luasocket 这个,在 centos 6.2 下编译后生成 mime.so 和 socket.so 

然后在执行逻辑的时候出错了

error loading module 'mime' from file '/usr/local/lualib/mime.so':
/usr/local/lualib/mime.so: undefined symbol: luaopen_mime,


看了下这里依赖于 socket.core 模块,貌似luajit下没有这个模块,但是lua 5.1 是有的. 现在在openresty 下跑不起来.

我想问的是   luasocket 模块有什么替代么,我看 lua-resty-http 里面用了 local sock = tcp() 这个tcp 的socket 这个可以替代么?



--
xinqiyang

Yichun Zhang (agentzh)

unread,
Oct 5, 2013, 1:54:54 PM10/5/13
to openresty
Hello!

2013/10/5 XinQi Yang:
>
> 最近在做 lua 下的请求转发用到了 https://github.com/catwell/lua-multipart-post
> 这个multipart-post的模块,模块依赖于 https://github.com/fire/luasocket 这个,在 centos 6.2

这个 luasocket 必会阻塞 nginx worker 进程,让你的 nginx 服务器瞬间退化成和 Apache httpd 和
php-fpm 一样弱 :) 绝对不要在生产环境使用它!

>
> 看了下这里依赖于 socket.core 模块,貌似luajit下没有这个模块,但是lua 5.1 是有的. 现在在openresty 下跑不起来.
>

标准 Lua 5.1 解释器的官方源码发布包中绝对不会有 socket.core 这种东西 :)

> 我想问的是 luasocket 模块有什么替代么,我看 lua-resty-http 里面用了 local sock = tcp() 这个tcp
> 的socket 这个可以替代么?
>

ngx_lua 提供的 cosocket API 是非阻塞的,而且这个 API 故意设计成和 LuaSocket 库基本兼容,所以你把
Lua 社区里那些基于 LuaSocket 的 Lua 库移植到 ngx_lua 环境中,也不会很费劲。

Regards,
-agentzh

XinQi Yang

unread,
Oct 6, 2013, 8:04:42 PM10/6/13
to open...@googlegroups.com
感谢章哥回复,我先看看cosocket api 感谢...


2013/10/6 Yichun Zhang (agentzh) <age...@gmail.com>

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html



--
xinqiyang
Reply all
Reply to author
Forward
0 new messages