AE.run do
# A socket that will be in connecting state for long...
tcp = AE::TCPSocket.new "1.2.3.4", 9999
# Close the socket after 2 seconds:
AE.add_timer(2) { puts tcp.close }
# We expect that uv_connect_cb(status=error) should happen right now, but NOT !!!
# It will happen in next event of the loop (if there are...), so for example:
AE.add_timer(5) { puts "now TCP on_connect_cb() is called with error !!!" }
end
Not serious... it happens that the timer(2 seconds) closes the connecting TCP socket (uv_close()) so the uv_connect_cb(status=error) should be called. But it is not, and instead, the TCP socket UV close callback is called when a new event occurs (in this case then the second timer(5 seconds) fires), so we get the uv_connect_cb(status=error) after 5 seconds !!!
Not serious... it happens that the timer(2 seconds) closes the connecting TCP socket (
uv_close()
) so theuv_connect_cb(status=error)
should be called. But it is not, and instead, the TCP socket UV close callback is called when a new event occurs (in this case then the second timer(5 seconds) fires), so we get theuv_connect_cb(status=error)
after 5 seconds !!!Reported in libuv: https://github.com/joyent/libuv/issues/448