xjdrew / levent Goto Github PK
View Code? Open in Web Editor NEWlua concurrency library based on libev, similar with gevent
License: MIT License
lua concurrency library based on libev, similar with gevent
License: MIT License
我去。看见blog写得5.2.3以上版本,特地下了5.3.0,想不用struct,报lua: error loading module 'levent.socket.c' from file './levent.so':
dlopen(./levent.so, 6): Symbol not found: _luaL_checkint
Referenced from: ./levent.so
Expected in: flat namespace
看文档luaL_checkint 已经删了呢,╮(╯▽╰)╭
ev.c:970:42: error: '_Noreturn' keyword must precede function declarator
我在cmake 生成出来的libev的Makefile 加上-std=c99 就ok了
macosx 10.11上默认是c11,不会cmake,所以没有提pr :)
function request(url)
local response, err = http.get(url)
if not response then
print(url, "error:", err)
else
print(url, response:get_code())
end
end
levent.spawn(request, "http://www.google.com")
levent.start(main)
--输出
http://www.google.com error: 110
打印110错误需要很长时间,请问如何设timeout超时?
另外,当我批量执行时,有些时候不能输出 110错误,表现为线程卡死
nice projet !
any reason why it isn't available on luarocks ?
test_socket.lua , 我的环境下测试,老是失败。最后发现client 连接成功也会返回错误码 56。看文档是 EISCONN。我的代码如下。 修改了IP和端口
function client()
local sock, errcode = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
assert(sock, errcode)
print("begin connect:", sock:fileno())
-- assert(sock:connect("127.0.0.1", 12345)
local ok, err = sock:connect("127.0.0.1", 12345)
print("connect", ok, err)
sock:sendall(test_data)
sock:close()
end
执行过程
~/Documents/workspace/levent$ lua tests/test_socket.lua
begin accept: 5
begin connect: 6
connect false 56
recv: hello
I can run lua tests/test_socket.lua
success, but failed of run lua examples/dns_mass_resolve.lua
error message below:
error: prepare: 0x12d1d38 ./levent/levent.lua:26: ./levent/dns.lua:104: attempt to call upvalue 'pack' (a nil value)
stack traceback:
[C]: in function 'assert'
./levent/levent.lua:26: in function 'func'
./levent/loop.lua:8: in function <./levent/loop.lua:7>
[C]: in function 'xpcall'
./levent/loop.lua:156: in function '_run_callback'
./levent/loop.lua:88: in function <./levent/loop.lua:87>
[C]: in function 'xpcall'
./levent/loop.lua:52: in function 'run_callback'
./levent/loop.lua:146: in function <./levent/loop.lua:144>
[C]: in function 'run'
./levent/loop.lua:95: in function 'run'
./levent/hub.lua:75: in function 'run'
./levent/levent.lua:60: in function 'start'
examples/dns_mass_resolve.lua:40: in main chunk
[C]: in ?
Severity Code Description Project File Line Suppression State
Error C2059 syntax error: 'type' levent ..\levent\deps\libev\ev.c 1946
static void * noinline ecb_cold
array_realloc (int elem, void *base, int *cur, int cnt)
改成
noinline static void * ecb_cold
array_realloc (int elem, void base, int cur, int cnt)
好像返回值是void的时候__declspec (noinline)必须在 void的前面
包括tests中的test_http_client.lua,返回的都是400,而不是期望的200,
http://example.com 400
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>400 - Bad Request</title>
</head>
<body>
<h1>400 - Bad Request</h1>
</body>
</html>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.