mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
bugfix: wakeup sleep
This commit is contained in:
@@ -71,12 +71,16 @@ function sockethelper.connect(host, port, timeout)
|
|||||||
local fd
|
local fd
|
||||||
if timeout then
|
if timeout then
|
||||||
local drop_fd
|
local drop_fd
|
||||||
|
local co = coroutine.running()
|
||||||
-- asynchronous connect
|
-- asynchronous connect
|
||||||
skynet.fork(function()
|
skynet.fork(function()
|
||||||
fd = socket.open(host, port)
|
fd = socket.open(host, port)
|
||||||
if drop_fd then
|
if drop_fd then
|
||||||
-- sockethelper.connect already return, and raise socket_error
|
-- sockethelper.connect already return, and raise socket_error
|
||||||
socket.close(fd)
|
socket.close(fd)
|
||||||
|
else
|
||||||
|
-- socket.open before sleep, wakeup.
|
||||||
|
skynet.wakeup(co)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
skynet.sleep(timeout)
|
skynet.sleep(timeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user