Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Marcin Kraglak <marcin.kraglak@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/5] android: Fix ipc cleanup
Date: Thu, 16 Jan 2014 09:41:16 +0100	[thread overview]
Message-ID: <8912359.omIpJ0S0ZX@uw000953> (raw)
In-Reply-To: <1389813150-16914-2-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wednesday 15 of January 2014 20:12:27 Marcin Kraglak wrote:
> Remove sources while cleanup. It will avoid receiving
> events after cleanup.
> ---
>  android/ipc.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/android/ipc.c b/android/ipc.c
> index ed3ef3c..4277bfe 100644
> --- a/android/ipc.c
> +++ b/android/ipc.c
> @@ -45,6 +45,9 @@ static struct service_handler services[HAL_SERVICE_ID_MAX + 1];
>  static GIOChannel *cmd_io = NULL;
>  static GIOChannel *notif_io = NULL;
>  
> +static guint cmd_id;
> +static guint notif_id;

Please name it cmd_watch and notif_watch. Also explicitly initialize them to 0 here.

> +
>  int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
>  						const void *buf, ssize_t len)
>  {
> @@ -192,11 +195,11 @@ static gboolean notif_connect_cb(GIOChannel *io, GIOCondition cond,
>  
>  	cond = G_IO_ERR | G_IO_HUP | G_IO_NVAL;
>  
> -	g_io_add_watch(io, cond, notif_watch_cb, NULL);
> +	notif_id = g_io_add_watch(io, cond, notif_watch_cb, NULL);
>  
>  	cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
>  
> -	g_io_add_watch(cmd_io, cond, cmd_watch_cb, NULL);
> +	cmd_id = g_io_add_watch(cmd_io, cond, cmd_watch_cb, NULL);
>  
>  	info("IPC: successfully connected");
>  
> @@ -232,12 +235,22 @@ void ipc_init(void)
>  
>  void ipc_cleanup(void)
>  {
> +	if (cmd_id) {
> +		g_source_remove(cmd_id);
> +		cmd_id = 0;
> +	}
> +
>  	if (cmd_io) {
>  		g_io_channel_shutdown(cmd_io, TRUE, NULL);
>  		g_io_channel_unref(cmd_io);
>  		cmd_io = NULL;
>  	}
>  
> +	if (notif_id) {
> +		g_source_remove(notif_id);
> +		notif_id = 0;
> +	}
> +
>  	if (notif_io) {
>  		g_io_channel_shutdown(notif_io, TRUE, NULL);
>  		g_io_channel_unref(notif_io);
> 

-- 
Best regards, 
Szymon Janc

  reply	other threads:[~2014-01-16  8:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15 19:12 [PATCH 1/5] android: Add android ipc tester Marcin Kraglak
2014-01-15 19:12 ` [PATCH 2/5] android: Fix ipc cleanup Marcin Kraglak
2014-01-16  8:41   ` Szymon Janc [this message]
2014-01-15 19:12 ` [PATCH 3/5] android/ipc-tester: Add test case to send cmd Marcin Kraglak
2014-01-15 19:12 ` [PATCH 4/5] android/ipc-tester: Add test case to send cmd to registered service Marcin Kraglak
2014-01-15 19:12 ` [PATCH 5/5] android/ipc-tester: Add next command test case Marcin Kraglak
2014-01-16  8:20 ` [PATCH 1/5] android: Add android ipc tester 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=8912359.omIpJ0S0ZX@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcin.kraglak@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