Skip to content
Snippets Groups Projects
Commit 10186f8c authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Follow up socket.tcp_connect() fixing

This patch fixes tcp_connect() for case when server sends
some data immediately after connect.
parent e2c72871
No related branches found
No related tags found
No related merge requests found
......@@ -891,11 +891,17 @@ local function tcp_connect_remote(remote, timeout)
box.errno(save_errno)
return nil
end
if s:wait(timeout) ~= 'W' then
-- When the connection completes succesfully, the descriptor becomes
-- writable. When the connection establishment encounters and error,
-- the descriptor becomes both readable and writable (Stevens UNP).
res = s:wait(timeout)
save_errno = s:errno()
-- When the connection completes succesfully, the descriptor becomes
-- writable. When the connection establishment encounters an error,
-- the descriptor becomes both readable and writable (Stevens UNP).
-- However, in real life if server sends some data immediately on connect,
-- descriptor can also become RW. For this case we also check SO_ERROR.
if res ~= nil and res ~= 'W' then
save_errno = s:getsockopt('SOL_SOCKET', 'SO_ERROR')
end
if save_errno ~= 0 then
s:close()
box.errno(save_errno)
return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment