From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp5.mail.ru (smtp5.mail.ru [94.100.179.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A1A73442BB7 for ; Sun, 29 Mar 2020 12:25:45 +0300 (MSK) Date: Sun, 29 Mar 2020 12:25:49 +0300 From: Alexander Turenko Message-ID: <20200329092549.pbxzho57kn3hdn47@tkn_work_nb> References: <20200312102434.97300-1-roman.habibov@tarantool.org> <20200312102434.97300-3-roman.habibov@tarantool.org> <20200329090718.GD328@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200329090718.GD328@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v2 2/2] lua: return getaddrinfo() errors List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org > > 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.