From: Marcel Holtmann <marcel@holtmann.org>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: "bluez mailin list (linux-bluetooth@vger.kernel.org)"
<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH 4/6] shared: Add support for shutdown to IO
Date: Tue, 11 Feb 2014 09:02:15 -0800 [thread overview]
Message-ID: <301FB290-56A1-404A-9A79-62F360D9DA9A@holtmann.org> (raw)
In-Reply-To: <1392137346-26272-4-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
> This allows to locally shutdown IO.
> ---
> src/shared/io-glib.c | 9 +++++++++
> src/shared/io-mainloop.c | 9 +++++++++
> src/shared/io.h | 2 ++
> 3 files changed, 20 insertions(+)
>
> diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c
> index a4f982d..8290745 100644
> --- a/src/shared/io-glib.c
> +++ b/src/shared/io-glib.c
> @@ -320,3 +320,12 @@ done:
>
> return true;
> }
> +
> +bool io_shutdown(struct io *io)
> +{
> + if (!io || !io->channel)
> + return false;
> +
> + return g_io_channel_shutdown(io->channel, TRUE, NULL)
> + == G_IO_STATUS_NORMAL;
> +}
> diff --git a/src/shared/io-mainloop.c b/src/shared/io-mainloop.c
> index 14ab128..f1e3b3b 100644
> --- a/src/shared/io-mainloop.c
> +++ b/src/shared/io-mainloop.c
> @@ -26,6 +26,7 @@
> #endif
>
> #include <unistd.h>
> +#include <sys/socket.h>
>
> #include "monitor/mainloop.h"
> #include "src/shared/util.h"
> @@ -294,3 +295,11 @@ bool io_set_disconnect_handler(struct io *io, io_callback_func_t callback,
>
> return true;
> }
> +
> +bool io_shutdown(struct io *io)
> +{
> + if (!io || io->fd < 0)
> + return false;
> +
> + return shutdown(io->fd, SHUT_RDWR) == 0;
> +}
I have no problem doing this, but why is this actually needed? Is not closing the socket good enough? Or would be better also add a shutdown_on_unref option?
Regards
Marcel
next prev parent reply other threads:[~2014-02-11 17:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-11 16:49 [PATCH 1/6] shared: Add support for disonnect handler to GLib based IO handling Szymon Janc
2014-02-11 16:49 ` [PATCH 2/6] shared: Add support for disonnect handler to mainloop " Szymon Janc
2014-02-11 16:49 ` [PATCH 3/6] shared: Add support for disconnect handler in HFP Szymon Janc
2014-02-11 17:00 ` Marcel Holtmann
2014-02-12 18:40 ` Szymon Janc
2014-02-12 18:47 ` Marcel Holtmann
2014-02-11 16:49 ` [PATCH 4/6] shared: Add support for shutdown to IO Szymon Janc
2014-02-11 17:02 ` Marcel Holtmann [this message]
2014-02-12 18:38 ` Szymon Janc
2014-02-12 18:45 ` Marcel Holtmann
2014-02-11 16:49 ` [PATCH 5/6] shared: Add support for local disconnect to HFP Szymon Janc
2014-02-11 16:49 ` [PATCH 6/6] android/handsfree: Use HFP code for connection handling Szymon Janc
2014-02-11 16:57 ` [PATCH 1/6] shared: Add support for disonnect handler to GLib based IO handling Marcel Holtmann
2014-02-12 18:42 ` Szymon Janc
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=301FB290-56A1-404A-9A79-62F360D9DA9A@holtmann.org \
--to=marcel@holtmann.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon.janc@tieto.com \
/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