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 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html