Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 6/6] android/gatt: Move not used devices to disconnected dev queue
Date: Thu, 10 Apr 2014 14:40:08 +0200	[thread overview]
Message-ID: <21498123.GVIzOAgyxH@uw000953> (raw)
In-Reply-To: <1397119381-13294-7-git-send-email-lukasz.rymanowski@tieto.com>

Hi Łukasz,

On Thursday 10 of April 2014 10:43:01 Lukasz Rymanowski wrote:
> With this patch, devices from conn_list and conn_wait_queue which are
> without a client e.g. because client has unregister without any
> cleaning, are move to the disconnected device queue.
> ---
>  android/gatt.c | 26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index d9c5773..4d7a3e4 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -295,6 +295,13 @@ static bool match_dev_by_conn_id(const void *data, const void *user_data)
>  	return dev->conn_id == conn_id;
>  }
>  
> +static bool match_dev_without_client(const void *data, const void *user_data)
> +{
> +	const struct gatt_device *dev = data;
> +
> +	return queue_isempty(dev->clients);
> +}
> +
>  static bool match_srvc_by_element_id(const void *data, const void *user_data)
>  {
>  	const struct element_id *exp_id = user_data;
> @@ -575,17 +582,32 @@ static void put_device_on_disc_list(struct gatt_device *dev)
>  	queue_push_tail(disc_dev_list, dev);
>  }
>  
> +static void park_not_used_devices(struct queue *q)
> +{
> +	struct gatt_device *dev;
> +
> +	/* Find device without client */
> +	dev = queue_remove_if(q, match_dev_without_client, NULL);
> +	while (dev) {
> +		/* Park device on disconnected device queue */
> +		put_device_on_disc_list(dev);
> +		dev = queue_remove_if(q, match_dev_without_client, NULL);
> +	};
> +}
> +
>  static void remove_client_from_devices(int32_t client_id)
>  {
>  	queue_foreach(conn_list, remove_cl_from_connected_dev_and_notify,
>  							INT_TO_PTR(client_id));
>  
> -	/*TODO: Check if there is any zombie device (connected no client)*/
> +	/*If there is any device without client, move it to disc list*/
> +	park_not_used_devices(conn_list);

Shouldn't those devices be disconnected as well? Also 'park' term is a bit
unusual, maybe just call it cleanup?

>  
>  	queue_foreach(conn_wait_queue, remove_cl_from_connecting_dev_and_notify,
>  							INT_TO_PTR(client_id));
>  
> -	/*TODO: Check if there is not zombie device plus stop scan */
> +	/*If there is any device without client, move it to disc list*/
> +	park_not_used_devices(conn_wait_queue);
>  }
>  
>  static void handle_client_unregister(const void *buf, uint16_t len)
> 

-- 
Best regards, 
Szymon Janc

      reply	other threads:[~2014-04-10 12:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-10  8:42 [PATCH 0/6] android/gatt: GATT client improvements Lukasz Rymanowski
2014-04-10  8:42 ` [PATCH 1/6] android/gatt: Add client listen support Lukasz Rymanowski
2014-04-10  8:59   ` Lukasz Rymanowski
2014-04-10 12:15   ` Szymon Janc
2014-04-10 13:40     ` Lukasz Rymanowski
2014-04-10  8:42 ` [PATCH 2/6] android/gatt: Refactor send_client_connect_notify Lukasz Rymanowski
2014-04-10 12:19   ` Szymon Janc
2014-04-10  8:42 ` [PATCH 3/6] android/gatt: Move functions up in the file Lukasz Rymanowski
2014-04-10  8:42 ` [PATCH 4/6] android/gatt: Fix handling client unregister Lukasz Rymanowski
2014-04-10  8:43 ` [PATCH 5/6] android/gatt: Move put_device_on_disc_list up in the file Lukasz Rymanowski
2014-04-10  8:43 ` [PATCH 6/6] android/gatt: Move not used devices to disconnected dev queue Lukasz Rymanowski
2014-04-10 12:40   ` Szymon Janc [this message]

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=21498123.GVIzOAgyxH@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=lukasz.rymanowski@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