Comments (5)
I found only problem in client
handle:write
have to have callback. client:write('quit', function() end)
I already thinking about to make it optional.
But there no unexpected crashes.
from lua-lluv.
Sure, I means that should generate lua error, because inner check callable, but invalid pointer report when I debug in visual studio, I think memory or stack somewhere wrong.
I found only problem in client
handle:write have to have callback. client:write('quit', function() end)
I already thinking about to make it optional.But there no unexpected crashes.
from lua-lluv.
- I just push version with optional callbak.
- You mean client get corruption?
from lua-lluv.
I can not reproduce it.
I little cleanup code
local uv = require'lluv'
local host = arg[1] or '127.0.0.1'
local port = arg[2] and tonumber(arg[2]) or 8080
local server = uv.tcp()
local count = 0
local cli_count = 0
local function dec_cli_count() cli_count = cli_count - 1 end
local function setInterval(fn, ms)
return uv.timer()
:start(ms, ms, function(timer) fn() end)
end
setInterval(function()
print(os.date(), count .. "/" .. cli_count)
collectgarbage()
end, 1000)
server:bind(host, port):listen(function(server, err)
if err then
print("LISTEN: ", err)
return server:close()
end
local cli, err = server:accept()
if not cli then
print("ACCEPT: ", err)
return
end
count = count + 1
cli_count = cli_count + 1
cli:start_read(function(cli, err, data)
if err then
print("READ: ", err)
return cli:close(dec_cli_count)
end
if data == 'quit' then
cli:close(dec_cli_count)
end
end)
end)
uv.run()
print("done")
local uv = require'lluv'
local host = arg[1] or '127.0.0.1'
local port = arg[2] and tonumber(arg[2]) or 8080
local step = arg[3] and tonumber(arg[3]) or 1
local count = 0
local keep = true
local function setInterval(fn, ms)
return uv.timer()
:start(ms, ms, function(timer) fn() end)
end
function newconnection()
return uv.tcp():connect(host, port, function(client, err)
if err then
print('Connect', err and err or 'OK')
return client:close()
end
client:start_read(function(cli, err, data)
if err then
if err:no() ~= uv.EOF then
print("READ: ", err)
end
return cli:close()
end
if(data=='quit') then
cli:close()
end
end)
client:write('quit')
end)
end
setInterval(function()
print(os.date(),count)
--collectgarbage()
if count < 16000 then
for i=1,step do
newconnection()
end
end
end, 1000)
print(pcall(uv.run()))
print("done")
from lua-lluv.
after update a76b175 code, works ok.
from lua-lluv.
Related Issues (20)
- API_CHECK fail with luajit HOT 1
- Do not clone table for write operation
- Context argument for stream write operation
- Missing libs with lua 5.3 and windows x64 HOT 6
- Support syncronus DNS requests.
- "recursive" flag in fs_event:start doesn't work HOT 3
- Support uv_os_homedir HOT 1
- Add. Support uv_tcp_init_ex/uv_udp_init_ex
- Timers never called with uv.run(uv.RUN_ONCE) HOT 2
- Cannot install for Lua 5.2 on 32-bit ubuntu HOT 4
- not compat with libuv 1.x HOT 1
- libuv real path HOT 1
- Installing with luarocks does not work
- Assertion `"Some one use invalid callback handler" && (lua_gettop(L) == 0)' failed. HOT 6
- Warning when build on ubuntu
- bad argument #1 to 'start' (number expected, got nil) HOT 2
- memory leaks, howto solve HOT 2
- has plan to imp syslog with lluv? HOT 6
- memory leak in timer ? HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-lluv.