mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
close fd when write failed
This commit is contained in:
@@ -19,6 +19,7 @@ end
|
||||
function socket.connect(addr)
|
||||
local ip, port = string.match(addr,"([^:]+):(.+)")
|
||||
port = tonumber(port)
|
||||
socket.close()
|
||||
fd = c.open(ip,port)
|
||||
if fd == nil then
|
||||
return true
|
||||
@@ -54,6 +55,7 @@ end
|
||||
function socket.write(...)
|
||||
local str = c.write(fd, ...)
|
||||
if str then
|
||||
socket.close()
|
||||
table.insert(data, str)
|
||||
end
|
||||
end
|
||||
@@ -61,6 +63,7 @@ end
|
||||
function socket.writeblock(...)
|
||||
local str = c.write(fd, ...)
|
||||
if str then
|
||||
socket.close()
|
||||
table.insert(data, str)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user