moonbridge

changeset 102:51ff6ad11677

Added missing freeaddrinfo() call to moonbridge_io.tcpconnect(...) function; Updated documentation regarding blocking DNS lookups of tcpconnect(...)
author jbe
date Wed Apr 08 05:26:15 2015 +0200 (2015-04-08)
parents baa30bfec659
children 4f9e4c6109f4
files moonbridge_io.c reference.txt
line diff
     1.1 --- a/moonbridge_io.c	Wed Apr 08 05:12:19 2015 +0200
     1.2 +++ b/moonbridge_io.c	Wed Apr 08 05:26:15 2015 +0200
     1.3 @@ -497,6 +497,7 @@
     1.4    hints.ai_flags = AI_ADDRCONFIG;
     1.5    errcode = getaddrinfo(host, port, &hints, &res);
     1.6    if (errcode) {
     1.7 +    freeaddrinfo(res);
     1.8      if (errcode == EAI_SYSTEM) {
     1.9        moonbr_io_errmsg();
    1.10        lua_pushnil(L);
    1.11 @@ -520,6 +521,7 @@
    1.12      addrinfo->ai_socktype | SOCK_CLOEXEC | (nonblocking ? SOCK_NONBLOCK : 0),
    1.13      addrinfo->ai_protocol
    1.14    );
    1.15 +  freeaddrinfo(res);
    1.16    if (sock < 0) {
    1.17      moonbr_io_errmsg();
    1.18      lua_pushnil(L);
     2.1 --- a/reference.txt	Wed Apr 08 05:12:19 2015 +0200
     2.2 +++ b/reference.txt	Wed Apr 08 05:26:15 2015 +0200
     2.3 @@ -248,6 +248,9 @@
     2.4  Same as moonbridge_io.tcpconnect(hostname, port), except that this function
     2.5  does not block and immediately returns a socket object.
     2.6  
     2.7 +Note: The current implementation still blocks during the DNS lookup. Use a
     2.8 +numeric IP address as hostname to be truly nonblocking.
     2.9 +
    2.10  In case of an I/O error, nil (as first return value) plus an error message (as
    2.11  second result value) may be returned. However, connection errors may also be
    2.12  reported on first read or write on the socket.

Impressum / About Us