Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] android/bluetooth: Don't set remote name to empty string
@ 2014-02-21 16:49 Szymon Janc
  2014-02-21 16:49 ` [PATCH 2/2] android/hal-ipc: Fix race condition when closing IPC Szymon Janc
  2014-02-24 19:36 ` [PATCH 1/2] android/bluetooth: Don't set remote name to empty string Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Szymon Janc @ 2014-02-21 16:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

If remote device has name but it is empty (0 bytes) just ignore it and
continue using address as name. This will avoid sending remote device
property notification with empty name.
---
 android/bluetooth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 31092e3..e225264 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1096,7 +1096,7 @@ static void update_new_device(struct device *dev, int8_t rssi,
 		ev->num_props++;
 	}
 
-	if (eir->name) {
+	if (eir->name && strlen(eir->name)) {
 		g_free(dev->name);
 		dev->name = g_strdup(eir->name);
 		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_NAME,
@@ -1136,7 +1136,7 @@ static void update_device(struct device *dev, int8_t rssi,
 		ev->num_props++;
 	}
 
-	if (eir->name && strcmp(dev->name, eir->name)) {
+	if (eir->name && strlen(eir->name) && strcmp(dev->name, eir->name)) {
 		g_free(dev->name);
 		dev->name = g_strdup(eir->name);
 		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_NAME,
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] android/hal-ipc: Fix race condition when closing IPC
  2014-02-21 16:49 [PATCH 1/2] android/bluetooth: Don't set remote name to empty string Szymon Janc
@ 2014-02-21 16:49 ` Szymon Janc
  2014-02-24 19:36 ` [PATCH 1/2] android/bluetooth: Don't set remote name to empty string Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-02-21 16:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Protect command socket cleanup with mutex to avoid bogus exit when
stopping notification thread.
---
 android/hal-ipc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 99ba38e..1ba03f5 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -159,8 +159,12 @@ static void *notification_handler(void *data)
 
 		/* socket was shutdown */
 		if (ret == 0) {
-			if (cmd_sk == -1)
+			pthread_mutex_lock(&cmd_sk_mutex);
+			if (cmd_sk == -1) {
+				pthread_mutex_unlock(&cmd_sk_mutex);
 				break;
+			}
+			pthread_mutex_unlock(&cmd_sk_mutex);
 
 			error("Notification socket closed, aborting");
 			exit(EXIT_FAILURE);
@@ -299,8 +303,10 @@ bool hal_ipc_init(void)
 
 void hal_ipc_cleanup(void)
 {
+	pthread_mutex_lock(&cmd_sk_mutex);
 	close(cmd_sk);
 	cmd_sk = -1;
+	pthread_mutex_unlock(&cmd_sk_mutex);
 
 	shutdown(notif_sk, SHUT_RD);
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] android/bluetooth: Don't set remote name to empty string
  2014-02-21 16:49 [PATCH 1/2] android/bluetooth: Don't set remote name to empty string Szymon Janc
  2014-02-21 16:49 ` [PATCH 2/2] android/hal-ipc: Fix race condition when closing IPC Szymon Janc
@ 2014-02-24 19:36 ` Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-02-24 19:36 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

On Friday 21 February 2014 17:49:52 Szymon Janc wrote:
> If remote device has name but it is empty (0 bytes) just ignore it and
> continue using address as name. This will avoid sending remote device
> property notification with empty name.
> ---
>  android/bluetooth.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 31092e3..e225264 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1096,7 +1096,7 @@ static void update_new_device(struct device *dev,
> int8_t rssi, ev->num_props++;
>  	}
> 
> -	if (eir->name) {
> +	if (eir->name && strlen(eir->name)) {
>  		g_free(dev->name);
>  		dev->name = g_strdup(eir->name);
>  		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_NAME,
> @@ -1136,7 +1136,7 @@ static void update_device(struct device *dev, int8_t
> rssi, ev->num_props++;
>  	}
> 
> -	if (eir->name && strcmp(dev->name, eir->name)) {
> +	if (eir->name && strlen(eir->name) && strcmp(dev->name, eir->name)) {
>  		g_free(dev->name);
>  		dev->name = g_strdup(eir->name);
>  		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_NAME,

Both patches are now pushed upstream.

-- 
Szymon K. Janc
szymon.janc@gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-24 19:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-21 16:49 [PATCH 1/2] android/bluetooth: Don't set remote name to empty string Szymon Janc
2014-02-21 16:49 ` [PATCH 2/2] android/hal-ipc: Fix race condition when closing IPC Szymon Janc
2014-02-24 19:36 ` [PATCH 1/2] android/bluetooth: Don't set remote name to empty string Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox