From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id EEF9631235 for ; Tue, 25 Jun 2019 09:38:30 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SefkZLPFM9k9 for ; Tue, 25 Jun 2019 09:38:30 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 454D331167 for ; Tue, 25 Jun 2019 09:38:30 -0400 (EDT) From: Roman Khabibov Subject: [tarantool-patches] [PATCH v2 2/2] say: take getaddrinfo() errors into account Date: Tue, 25 Jun 2019 16:38:27 +0300 Message-Id: <3603f7507651b37ddd549a8c247709cc7ff43f44.1561469272.git.roman.habibov@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: alexander.turenko@tarantool.org Before this patch, branch when getaddrinfo() returns error codes couldn't be reached on Mac OS, because they are greater than 0 on Mac OS (checking for errors was rc < 0). Part of #4138 --- src/lib/core/say.c | 3 ++- test/box-tap/cfg.test.lua | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/lib/core/say.c b/src/lib/core/say.c index 0b2cf2c34..c927f9fc0 100644 --- a/src/lib/core/say.c +++ b/src/lib/core/say.c @@ -506,7 +506,7 @@ syslog_connect_remote(const char *server_address) hints.ai_protocol = IPPROTO_UDP; ret = getaddrinfo(remote, portnum, &hints, &inf); - if (ret < 0) { + if (ret != 0) { errno = EIO; diag_set(SystemError, "getaddrinfo: %s", gai_strerror(ret)); @@ -594,6 +594,7 @@ log_syslog_init(struct log *log, const char *init_str) log->fd = log_syslog_connect(log); if (log->fd < 0) { /* syslog indent is freed in atexit(). */ + diag_log(); diag_set(SystemError, "syslog logger: %s", strerror(errno)); return -1; } diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua index 55de5e41c..d92e9140d 100755 --- a/test/box-tap/cfg.test.lua +++ b/test/box-tap/cfg.test.lua @@ -6,7 +6,7 @@ local socket = require('socket') local fio = require('fio') local uuid = require('uuid') local msgpack = require('msgpack') -test:plan(104) +test:plan(105) -------------------------------------------------------------------------------- -- Invalid values @@ -566,6 +566,23 @@ os.exit(0) ]] test:is(run_script(code), 0, "log_nonblock") +-- +-- gh-4138: check getaddrinfo() error and panic after that. +-- +code=[[ +local socket = require('socket') +local log = require('log') +local fio = require('fio') + +path = fio.pathjoin(fio.cwd(), 'log_unix_socket_test.sock') +unix_socket = socket('AF_UNIX', 'SOCK_DGRAM', 0) +unix_socket:bind('unix/', path) + +opt = string.format("syslog:server=non_exists_hostname:%s,identity=tarantool", path) +box.cfg{log = opt, log_nonblock=true} +]] +test:is(run_script(code), PANIC, "log_nonblock") + -- -- Crash (instead of panic) when trying to recover a huge tuple. -- -- 2.20.1 (Apple Git-117)