Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e91698e1 authored by Nitin Srivastav's avatar Nitin Srivastav Committed by Zhihai Xu
Browse files

Bluetooth: retry recv in case of EINTR

 -  retry recv call in HAL, in case socket call
    fails with EINTR

Change-Id: I3ab27752b0ce0a68f6776cf5da340580e7d1f345
parent af8651f2
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -283,12 +283,27 @@ static int a2dp_command(struct a2dp_stream_out *out, char cmd)

    /* wait for ack byte */
    if (recv(out->ctrl_fd, &ack, 1, MSG_NOSIGNAL) < 0)
    {
        ERROR("ack failed (%s)", strerror(errno));
        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);