From: Olga Arkhangelskaia <krishtal.olja@gmail.com> To: tarantool-patches@freelists.org Cc: Olga Arkhangelskaia <krishtal.olja@gmail.com> Subject: [tarantool-patches] [PATCH] Fix O_NONBLOCK flag loss Date: Tue, 7 Aug 2018 23:57:42 +0300 [thread overview] Message-ID: <20180807205742.52303-1-krishtal.olja@gmail.com> (raw) During syslog reconnect we lose nonblock flag. This leads to misbehavior while logging. Tarantool hangs forever Closes #3615 --- https://github.com/tarantool/tarantool/issues/3615 https://github.com/tarantool/tarantool/tree/OKriw/gh-3615-loss-nonblock-1.10 src/say.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/say.c b/src/say.c index 063e0295c..4bd47b1f2 100644 --- a/src/say.c +++ b/src/say.c @@ -238,6 +238,16 @@ write_to_file(struct log *log, int total); static void write_to_syslog(struct log *log, int total); +static void +set_nonblock(int fd) +{ + int flags; + if ( (flags = fcntl(fd, F_GETFL, 0)) < 0 || + fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) { + say_syserror("fcntl, fd=%i", fd); + } +} + /** * Rotate logs on SIGHUP */ @@ -262,13 +272,9 @@ log_rotate(struct log *log) dup2(fd, log->fd); close(fd); - if (log->nonblock) { - int flags; - if ( (flags = fcntl(log->fd, F_GETFL, 0)) < 0 || - fcntl(log->fd, F_SETFL, flags | O_NONBLOCK) < 0) { - say_syserror("fcntl, fd=%i", log->fd); - } - } + if (log->nonblock) + set_nonblock(log->fd); + /* We are in ev signal handler * so we don't have to be worry about async signal safety */ @@ -940,6 +946,8 @@ write_to_syslog(struct log *log, int total) close(log->fd); log->fd = log_syslog_connect(log); if (log->fd >= 0) { + if (log->nonblock) + set_nonblock(log->fd); /* * In a case or error the log message is * lost. We can not wait for connection - -- 2.14.3 (Apple Git-98)
next reply other threads:[~2018-08-07 20:58 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-07 20:57 Olga Arkhangelskaia [this message] 2018-08-08 10:28 ` Vladimir Davydov
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=20180807205742.52303-1-krishtal.olja@gmail.com \ --to=krishtal.olja@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH] Fix O_NONBLOCK flag loss' \ /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