bugfix: wakeup sleep

This commit is contained in:
Cloud Wu
2017-05-08 11:45:50 +08:00
parent acb0c57844
commit 648504119e

View File

@@ -71,12 +71,16 @@ function sockethelper.connect(host, port, timeout)
local fd
if timeout then
local drop_fd
local co = coroutine.running()
-- asynchronous connect
skynet.fork(function()
fd = socket.open(host, port)
if drop_fd then
-- sockethelper.connect already return, and raise socket_error
socket.close(fd)
else
-- socket.open before sleep, wakeup.
skynet.wakeup(co)
end
end)
skynet.sleep(timeout)