From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Gal Ben Haim <gbenhaim@augury.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH BlueZ] core: Ignore SIGPIPE
Date: Fri, 16 Nov 2018 21:30:21 +0200 [thread overview]
Message-ID: <CABBYNZJFTNMvXE5p0t4XrhF8KaJf3RKRdbD1Hv6Jwp+x+6shGQ@mail.gmail.com> (raw)
In-Reply-To: <20181116191452.17377-1-gbenhaim@augury.com>
Hi Gal,
On Fri, Nov 16, 2018 at 9:17 PM Gal Ben-Haim <gbenhaim@augury.com> wrote:
>
> bluetoothd receives a SIGPIPE and terminates if writing to a pipe that
> was acquired by AcquireNotify and there are no readers. it can be
> reproduced by terminating the reader process without closing the reader
> end of the pipe.
>
> Ignoring the SIGPIPE will cause the write operation to return an
> error which will be logged as "io_send: Broken pipe".
Ive been suggesting using MSG_NOSIGNAL, do you have anything against it?
MSG_NOSIGNAL (since Linux 2.2)Requests not to send SIGPIPE on errors
on stream oriented sockets when the other end breaks the connection.
The EPIPE error is still returned.
(https://linux.die.net/man/2/send)
> ---
> src/main.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/main.c b/src/main.c
> index 4716f5388..c62886593 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -691,7 +691,7 @@ int main(int argc, char *argv[])
> uint16_t sdp_mtu = 0;
> uint32_t sdp_flags = 0;
> int gdbus_flags = 0;
> - guint signal, watchdog;
> + guint signal_source, watchdog;
> const char *watchdog_usec;
>
> init_defaults();
> @@ -721,7 +721,11 @@ int main(int argc, char *argv[])
>
> event_loop = g_main_loop_new(NULL, FALSE);
>
> - signal = setup_signalfd();
> + signal_source = setup_signalfd();
> +
> + /* Ignore SIGPIPE, a broken pipe error will be returned from write
> + * attempts to a pipe with no readers */
> + signal(SIGPIPE, SIG_IGN);
>
> __btd_log_init(option_debug, option_detach);
>
> @@ -809,7 +813,7 @@ int main(int argc, char *argv[])
>
> sd_notify(0, "STATUS=Quitting");
>
> - g_source_remove(signal);
> + g_source_remove(signal_source);
>
> plugin_cleanup();
>
> --
> 2.19.1
>
--
Luiz Augusto von Dentz
next prev parent reply other threads:[~2018-11-16 19:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-16 19:14 [PATCH BlueZ] core: Ignore SIGPIPE Gal Ben-Haim
2018-11-16 19:30 ` Luiz Augusto von Dentz [this message]
2018-11-16 19:54 ` Gal Ben Haim
2018-11-16 20:01 ` Marcel Holtmann
2018-11-16 20:11 ` Gal Ben Haim
2018-11-16 23:45 ` Gal Ben Haim
2018-11-17 9:29 ` Luiz Augusto von Dentz
2018-11-17 15:04 ` Gal Ben Haim
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=CABBYNZJFTNMvXE5p0t4XrhF8KaJf3RKRdbD1Hv6Jwp+x+6shGQ@mail.gmail.com \
--to=luiz.dentz@gmail.com \
--cc=gbenhaim@augury.com \
--cc=linux-bluetooth@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).