report connect failed reason

This commit is contained in:
Cloud Wu
2015-10-28 16:12:01 +08:00
parent 13d920e185
commit 935863f434
3 changed files with 20 additions and 9 deletions

View File

@@ -112,8 +112,10 @@ socket_message[5] = function(id, _, err)
skynet.error("socket: error on unknown", id, err)
return
end
if s.connected or s.connecting then
if s.connected then
skynet.error("socket: error on", id, err)
elseif s.connecting then
s.connecting = err
end
s.connected = false
driver.close(id)
@@ -179,11 +181,13 @@ local function connect(id, func)
}
socket_pool[id] = s
suspend(s)
local err = s.connecting
s.connecting = nil
if s.connected then
return id
else
socket_pool[id] = nil
return nil, err
end
end