http中connect可能会连接失败,不应当将错误的fd继续传递下去

This commit is contained in:
chengzhe
2017-10-17 17:50:54 +08:00
parent 460ed2e9e2
commit 37157273ff

View File

@@ -100,6 +100,10 @@ function httpc.request(method, host, url, recvheader, header, content)
hostname = dns.resolve(hostname)
end
local fd = socket.connect(hostname, port, timeout)
if not fd then
error(string.format("http connect error host:%s, port:%s, timeout:%s", hostname, port, timeout))
return
end
local finish
if timeout then
skynet.timeout(timeout, function()