OSDN Git Service

Bluetooth: retry recv in case of EINTR
authorNitin Srivastav <nitinsr@codeaurora.org>
Fri, 21 Feb 2014 13:03:14 +0000 (18:33 +0530)
committerMatthew Xie <mattx@google.com>
Tue, 6 May 2014 08:14:24 +0000 (01:14 -0700)
 -  retry recv call in HAL, in case socket call
    fails with EINTR

Change-Id: I3ab27752b0ce0a68f6776cf5da340580e7d1f345

audio_a2dp_hw/audio_a2dp_hw.c

index a361499..10432f1 100644 (file)
@@ -286,9 +286,24 @@ static int a2dp_command(struct a2dp_stream_out *out, char cmd)
     if (recv(out->ctrl_fd, &ack, 1, MSG_NOSIGNAL) < 0)
     {
         ERROR("ack failed (%s)", strerror(errno));
-        skt_disconnect(out->ctrl_fd);
-        out->ctrl_fd = AUDIO_SKT_DISCONNECTED;
-        return -1;
+        if (errno == EINTR)
+        {
+            /* retry again */
+            if (recv(out->ctrl_fd, &ack, 1, MSG_NOSIGNAL) < 0)
+            {
+               ERROR("ack failed (%s)", strerror(errno));
+               skt_disconnect(out->ctrl_fd);
+               out->ctrl_fd = AUDIO_SKT_DISCONNECTED;
+               return -1;
+            }
+        }
+        else
+        {
+               skt_disconnect(out->ctrl_fd);
+               out->ctrl_fd = AUDIO_SKT_DISCONNECTED;
+               return -1;
+
+        }
     }
 
     DEBUG("A2DP COMMAND %s DONE STATUS %d", dump_a2dp_ctrl_event(cmd), ack);