[Tarantool-patches] [PATCH v2 2/2] lua: return getaddrinfo() errors

Alexander Turenko alexander.turenko at tarantool.org
Sun Mar 29 12:25:49 MSK 2020


> > diff --git a/src/lua/socket.lua b/src/lua/socket.lua
> > index a334ad45b..ce6dab301 100644
> > --- a/src/lua/socket.lua
> > +++ b/src/lua/socket.lua
> > @@ -1041,9 +1041,12 @@ local function tcp_connect(host, port, timeout)
> >      end
> >      local timeout = timeout or TIMEOUT_INFINITY
> >      local stop = fiber.clock() + timeout
> > -    local dns = getaddrinfo(host, port, timeout, { type = 'SOCK_STREAM',
> > +    local dns, err = getaddrinfo(host, port, timeout, { type = 'SOCK_STREAM',
> >          protocol = 'tcp' })
> > -    if dns == nil or #dns == 0 then
> > +    if dns == nil then
> > +        return nil, err
> You explicitly put error here...
> 
> > +    end
> > +    if #dns == 0 then
> >          boxerrno(boxerrno.EINVAL)
> >          return nil
> ... and not here. Why do you keep using two versions of error passing,
> not one? I would agree you need boxerrno for backward compatibility, but
> to start moving towards {res, err} you have to introduce it everywhere. 

Seems logical.

> > +-- gh-4138 Check getaddrinfo() error from socket:connect() only.
> > +-- Error code and error message returned by getaddrinfo() depends
> > +-- on system's gai_strerror().
> > +test_run:cmd("setopt delimiter ';'")
> > +function check_err(err)
> > +    if err == 'getaddrinfo: nodename nor servname provided, or not known' or
> > +       err == 'getaddrinfo: Servname not supported for ai_socktype' or
> > +       err == 'getaddrinfo: Name or service not known' or
> > +       err == 'getaddrinfo: hostname nor servname provided, or not known' or
> > +       err == 'getaddrinfo: Temporary failure in name resolution' or
> > +       err == 'getaddrinfo: Name could not be resolved at this time' then
> > +        return true
> > +    end
> > +    return false
> > +end;
> I really doubt that different error messages from the set above will appear 
> for the same error on different platforms. Could you please check for particular 
> output for each case you trigger below?

It is so. It varies even for the same system connected to different
networks.


More information about the Tarantool-patches mailing list