THRIFT-5282: Add IPv6 client support to Lua library
Client: lua
Patch: Jeffrey Han
This closes #2243
diff --git a/lib/lua/src/luasocket.c b/lib/lua/src/luasocket.c
index d483510..6f63d3d 100644
--- a/lib/lua/src/luasocket.c
+++ b/lib/lua/src/luasocket.c
@@ -344,22 +344,18 @@
// Create and connect loop for timeout milliseconds
end = __gettime() + timeout/1000;
do {
- // Create the socket
- err = tcp_create(&sock);
- if (!err) {
- // Connect
- err = tcp_connect(&sock, host, port, timeout);
- if (err) {
- tcp_destroy(&sock);
- usleep(100000); // sleep for 100ms
- } else {
- p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
- settype(L, -2, SOCKET_CLIENT);
- socket_setnonblocking(&sock);
- tcp->sock = sock;
- tcp->timeout = timeout;
- return 1; // Return userdata
- }
+ // Create and connect the socket
+ err = tcp_create_and_connect(&sock, host, port, timeout);
+ if (err) {
+ tcp_destroy(&sock);
+ usleep(100000); // sleep for 100ms
+ } else {
+ p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
+ settype(L, -2, SOCKET_CLIENT);
+ socket_setnonblocking(&sock);
+ tcp->sock = sock;
+ tcp->timeout = timeout;
+ return 1; // Return userdata
}
} while (err && __gettime() < end);