Bluetooth: retry recv in case of EINTR
- retry recv call in HAL, in case socket call
fails with EINTR
Change-Id: I3ab27752b0ce0a68f6776cf5da340580e7d1f345
diff --git a/audio_a2dp_hw/audio_a2dp_hw.c b/audio_a2dp_hw/audio_a2dp_hw.c
index cd4cdb4..5f4c14c 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.c
+++ b/audio_a2dp_hw/audio_a2dp_hw.c
@@ -285,9 +285,24 @@
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);