2014-07-15 08:04:31

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/2] android/hal-audio: Fix leaving open socket

From: Andrei Emeltchenko <[email protected]>

When getting out of the poll loop we shall close socket always.
---
android/hal-audio.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 1a3d3ae..d7a06fa 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -1377,14 +1377,12 @@ static void *ipc_handler(void *data)
/* Check if socket is still alive. Empty while loop.*/
while (poll(&pfd, 1, -1) < 0 && errno == EINTR);

- if (pfd.revents & (POLLHUP | POLLERR | POLLNVAL)) {
- info("Audio HAL: Socket closed");
+ info("Audio HAL: Socket closed");

- pthread_mutex_lock(&sk_mutex);
- close(audio_sk);
- audio_sk = -1;
- pthread_mutex_unlock(&sk_mutex);
- }
+ pthread_mutex_lock(&sk_mutex);
+ close(audio_sk);
+ audio_sk = -1;
+ pthread_mutex_unlock(&sk_mutex);
}

/* audio_sk is closed at this point, just cleanup endpoints states */
--
1.9.1



2014-07-15 08:04:32

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/2] android/hal-sco: Fix leaving open socket

From: Andrei Emeltchenko <[email protected]>

Close accepted socket always after poll loop.
---
android/hal-sco.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/android/hal-sco.c b/android/hal-sco.c
index d405b41..6a46e90 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -1252,14 +1252,12 @@ static void *ipc_handler(void *data)
/* Check if socket is still alive. Empty while loop.*/
while (poll(&pfd, 1, -1) < 0 && errno == EINTR);

- if (pfd.revents & (POLLHUP | POLLERR | POLLNVAL)) {
- info("SCO HAL: Socket closed");
+ info("SCO HAL: Socket closed");

- pthread_mutex_lock(&sk_mutex);
- close(ipc_sk);
- ipc_sk = -1;
- pthread_mutex_unlock(&sk_mutex);
- }
+ pthread_mutex_lock(&sk_mutex);
+ close(ipc_sk);
+ ipc_sk = -1;
+ pthread_mutex_unlock(&sk_mutex);
}

info("Closing SCO IPC thread");
--
1.9.1