# HG changeset patch # User jbe # Date 1428463575 -7200 # Node ID 51ff6ad11677d342361b88df6914231fd0f179e5 # Parent baa30bfec659d7ed5721e4ba1b89b8252fdfee89 Added missing freeaddrinfo() call to moonbridge_io.tcpconnect(...) function; Updated documentation regarding blocking DNS lookups of tcpconnect(...) diff -r baa30bfec659 -r 51ff6ad11677 moonbridge_io.c --- a/moonbridge_io.c Wed Apr 08 05:12:19 2015 +0200 +++ b/moonbridge_io.c Wed Apr 08 05:26:15 2015 +0200 @@ -497,6 +497,7 @@ hints.ai_flags = AI_ADDRCONFIG; errcode = getaddrinfo(host, port, &hints, &res); if (errcode) { + freeaddrinfo(res); if (errcode == EAI_SYSTEM) { moonbr_io_errmsg(); lua_pushnil(L); @@ -520,6 +521,7 @@ addrinfo->ai_socktype | SOCK_CLOEXEC | (nonblocking ? SOCK_NONBLOCK : 0), addrinfo->ai_protocol ); + freeaddrinfo(res); if (sock < 0) { moonbr_io_errmsg(); lua_pushnil(L); diff -r baa30bfec659 -r 51ff6ad11677 reference.txt --- a/reference.txt Wed Apr 08 05:12:19 2015 +0200 +++ b/reference.txt Wed Apr 08 05:26:15 2015 +0200 @@ -248,6 +248,9 @@ Same as moonbridge_io.tcpconnect(hostname, port), except that this function does not block and immediately returns a socket object. +Note: The current implementation still blocks during the DNS lookup. Use a +numeric IP address as hostname to be truly nonblocking. + In case of an I/O error, nil (as first return value) plus an error message (as second result value) may be returned. However, connection errors may also be reported on first read or write on the socket.