From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 26 Jul 2019 16:48:04 +0300 From: Alexander Turenko Subject: Re: [tarantool-patches] Re: [PATCH v2 1/2] lua: return getaddrinfo() errors Message-ID: <20190726134803.45ocugh3ukupyyis@tkn_work_nb> References: <20190615165829.11888-1-roman.habibov@tarantool.org> <20190623203141.snnjgyqrntr6okp4@tkn_work_nb> <8C0820C4-7F5E-40A9-A634-E449E700D816@tarantool.org> <20190709080407.sv5quzrxpbnijwp4@tkn_work_nb> <20190723123954.dgtfsetqlmjhued3@tkn_work_nb> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190723123954.dgtfsetqlmjhued3@tkn_work_nb> To: Roman Khabibov Cc: tarantool-patches@freelists.org, Vladimir Davydov List-ID: 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.