From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp59.i.mail.ru (smtp59.i.mail.ru [217.69.128.39]) (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 5862146971A for ; Sun, 8 Dec 2019 22:48:28 +0300 (MSK) Date: Sun, 8 Dec 2019 22:48:24 +0300 From: Alexander Turenko Message-ID: <20191208194823.krw4hc4lm7bhxqrk@tkn_work_nb> References: <3603f7507651b37ddd549a8c247709cc7ff43f44.1561469272.git.roman.habibov@tarantool.org> <20190723145249.5xwc2td6omphwwzw@tkn_work_nb> <20190828213431.3yd4kwcahe2oizgs@tkn_work_nb> <8E98F721-601F-436D-8F0A-5E399D8F7CAB@tarantool.org> <20190906134443.kc5anat2t3q26l3o@tkn_work_nb> <20191101151939.lewxpitqxzyn6dz6@tkn_work_nb> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [tarantool-patches] [PATCH v2 2/2] say: take getaddrinfo() errors into account List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roman Khabibov Cc: tarantool-patches@dev.tarantool.org > @@ -72,14 +72,28 @@ static void > test_getaddrinfo(void) > { > header(); > - plan(1); > + plan(3); > const char *host = "127.0.0.1"; > const char *port = "3333"; > struct addrinfo *i; > /* NULL hints should work. It is a standard. */ > int rc = coio_getaddrinfo(host, port, NULL, &i, 1); > is(rc, 0, "getaddrinfo"); > - freeaddrinfo(i); Why do you remove freeing of the previous result? It will lead to a leak and so will require extra work to run unit tests under ASAN or Valgrind. > + > + /* gh-4138: Check getaddrinfo() retval. */ Nit: retval and diagnostics area. You changed the code and the comment becomes inaccurate. > + rc = coio_getaddrinfo("non_exists_hostname", port, NULL, &i, > + 15768000000); > + isnt(rc, 0, "getaddrinfo retval"); > + const char *errmsg = diag_get()->last->errmsg; > + const char *exp_errmsg_1 = "getaddrinfo: nodename nor servname provided" > + ", or not known"; > + const char *exp_errmsg_2 = "getaddrinfo: Servname not supported for " > + "ai_socktype"; > + const char *exp_errmsg_3 = "getaddrinfo: Name or service not known"; > + bool is_match_with_exp = strcmp(errmsg, exp_errmsg_1) == 0 || > + strcmp(errmsg, exp_errmsg_2) == 0 || > + strcmp(errmsg, exp_errmsg_3) == 0; > + is(is_match_with_exp, true, "getaddrinfo error message"); > > /* > * gh-4209: 0 timeout should not be a special value and > > > The patch looks okay other then this. > > commit d9c23fde4c7c1fa2979954be83c1a2f6f8407347 > Author: Roman Khabibov > Date: Tue Jul 30 15:39:21 2019 +0300 > > coio/say: fix getaddrinfo error handling on macOS > > Before this patch, branch when getaddrinfo() returns error codes > couldn't be reached on macOS, because they are greater than 0 on > macOS (assumption "rc < 0" in commit ea1da04 is incorrect for > macOS). > > Note: diag_log() in say.c was added, because otherwise it will be > hid by the following diagnostic and then say that it should > be handler in a better way after #1148. Also, two diag_set() in 'and then say' -- looks as copy-paste from review notes. Typo: handler -> handled. > syslog_connect_unix() was added to avoid asserts in this > diag_log(). > > Need for #4138