Diff between 3c7f2c94309a1a579b83d598c951104f3c1ed641 and 93c12a9281c5e39f88ad8f1de7c216d3972f52e6

Changed Files

File Additions Deletions Status
android/hal-ipc.c +7 -1 modified

Full Patch

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);