OSDN Git Service

android/hal-audio: Fix leaving open socket
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Fri, 18 Jul 2014 09:48:17 +0000 (12:48 +0300)
committerSzymon Janc <szymon.janc@tieto.com>
Fri, 18 Jul 2014 11:41:22 +0000 (13:41 +0200)
When getting out of the poll loop we shall close socket always.

android/hal-audio.c

index 1a3d3ae..d7a06fa 100644 (file)
@@ -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 */