[tarantool-patches] Re: [PATCH v2 1/2] lua: return getaddrinfo() errors

Alexander Turenko alexander.turenko at tarantool.org
Fri Jul 26 16:48:04 MSK 2019


On Tue, Jul 23, 2019 at 03:39:54PM +0300, Alexander Turenko wrote:
> Please, split Mac OS specific fix (I think both coio_task.c and say.c
> can be fixed in one commit) from OS independent Lua change (that just
> pass received error to a user).
> 
> Returning either `nil` or `nil, err` still look strange for me. Please,
> try to implement the following way: set an additional field in a socket
> object (we have '_errno', let's add another one: say, '_error') with a
> message from a diagnostics and return it from socket_error() if it
> exists. Don't forget to flush it when update any of those two fields (I
> guess an auxiliary function to set _errno and _error).
> 
> Don't sure how should we check whether a diag is set. Maybe flush it
> before a call to C and then check whether it was set afterwards.
> 
> There are places where strerror() is called directly to return `nil,
> err`. They should be replaced with socket_error().
> 
> I think it worth to introduce socket_clear_error() and
> socket_set_error() in a separate commit w/o any logic change.
> 
> CCed Vladimir, because we discussed possible approaches with him.
> 
> WBR, Alexander Turenko.

We look into the code with Roman together and now I understood that the
proposed way does not work: we have no a socket object in getaddrinfo()
Lua function to save _error into it.

We should return a text error message as retvals anyway.

There is the question about constructions like so:

local val, err = foo(<...>)
if val == nil then
    if err == nil then
        return boxerrno.strerror()
    else
        return err
    end
end

I think foo() should either always return `nil, string` at an error or
always set an errno. I propose to try to implement this way and compare
whther it will be simper.

WBR, Alexander Turenko.



More information about the Tarantool-patches mailing list