Tarantool development patches archive
 help / color / mirror / Atom feed
From: Roman Khabibov <roman.habibov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: alexander.turenko@tarantool.org
Subject: [tarantool-patches] [PATCH v2 2/2] say: take getaddrinfo() errors  into account
Date: Tue, 25 Jun 2019 16:38:27 +0300	[thread overview]
Message-ID: <3603f7507651b37ddd549a8c247709cc7ff43f44.1561469272.git.roman.habibov@tarantool.org> (raw)
In-Reply-To: <cover.1561469272.git.roman.habibov@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)

  reply	other threads:[~2019-06-25 13:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25 13:38 [tarantool-patches] [PATCH v2 0/2] " Roman Khabibov
2019-06-25 13:38 ` Roman Khabibov [this message]
2019-07-23 14:52   ` [tarantool-patches] Re: [PATCH v2 2/2] say: " Alexander Turenko
2019-08-05 13:32     ` Roman Khabibov
2019-08-28 21:34       ` Alexander Turenko
2019-08-29  0:51         ` Alexander Turenko
     [not found]         ` <8E98F721-601F-436D-8F0A-5E399D8F7CAB@tarantool.org>
2019-09-06 13:44           ` Alexander Turenko
2019-09-10 12:52             ` Roman Khabibov
2019-11-01 15:19               ` [Tarantool-patches] " Alexander Turenko
2019-11-21 17:28                 ` [Tarantool-patches] [tarantool-patches] " Roman Khabibov
2019-12-08 19:48                   ` Alexander Turenko
2019-12-10 16:25                     ` Roman Khabibov
2019-12-18 15:01                       ` Alexander Turenko
2019-12-21 17:50                         ` Roman Khabibov
2019-12-23 12:56                           ` Alexander Turenko
2019-12-23 13:38                             ` Alexander Turenko
2019-12-26 17:29                               ` Roman Khabibov
2019-12-26 21:05                                 ` Alexander Turenko
2019-12-27 13:01                                   ` Roman Khabibov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3603f7507651b37ddd549a8c247709cc7ff43f44.1561469272.git.roman.habibov@tarantool.org \
    --to=roman.habibov@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v2 2/2] say: take getaddrinfo() errors  into account' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox