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

Commit bd4bae49 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by Andre Eisenbach
Browse files

Improve poll(2) handling and log messages

 * Better error handling and log messages inside
   uipc_flush_ch_locked()
 * Add missing error check inside UIPC_Read()
 * Add missing OSI_NO_INTR() wrapper around poll()
   inside function btu_exec_tap_fd_read()

Bug: 28823662
Change-Id: I5f1c720861bea594d53ed6465a5ff327ba352598
parent c00e0337
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -787,7 +787,10 @@ static void btu_exec_tap_fd_read(void *p_param) {
        ufd.fd = fd;
        ufd.events = POLLIN;
        ufd.revents = 0;
        if (poll(&ufd, 1, 0) <= 0 || IS_EXCEPTION(ufd.revents))

        int ret;
        OSI_NO_INTR(ret = poll(&ufd, 1, 0));
        if (ret <= 0 || IS_EXCEPTION(ufd.revents))
            break;
    }

+15 −7
Original line number Diff line number Diff line
@@ -394,6 +394,16 @@ static void uipc_flush_ch_locked(tUIPC_CH_ID ch_id)
    {
        int ret;
        OSI_NO_INTR(ret = poll(&pfd, 1, 1));
        if (ret == 0) {
            BTIF_TRACE_VERBOSE("%s(): poll() timeout - nothing to do. Exiting",
                               __func__);
            return;
        }
        if (ret < 0) {
            BTIF_TRACE_WARNING("%s() - poll() failed: return %d errno %d (%s). Exiting",
                               __func__, ret, errno, strerror(errno));
            return;
        }
        BTIF_TRACE_VERBOSE("%s() - polling fd %d, revents: 0x%x, ret %d",
                __FUNCTION__, pfd.fd, pfd.revents, ret);
        if (pfd.revents & (POLLERR|POLLHUP))
@@ -402,13 +412,6 @@ static void uipc_flush_ch_locked(tUIPC_CH_ID ch_id)
            return;
        }

        if (ret <= 0)
        {
            BTIF_TRACE_WARNING("%s() - poll() failed (%s). Exiting",
                               __FUNCTION__, strerror(errno));
            return;
        }

        /* read sufficiently large buffer to ensure flush empties socket faster than
           it is getting refilled */
        read(pfd.fd, &buf, UIPC_FLUSH_BUFFER_SIZE);
@@ -747,6 +750,11 @@ UINT32 UIPC_Read(tUIPC_CH_ID ch_id, UINT16 *p_msg_evt, UINT8 *p_buf, UINT32 len)
            BTIF_TRACE_WARNING("poll timeout (%d ms)", uipc_main.ch[ch_id].read_poll_tmo_ms);
            break;
        }
        if (poll_ret < 0) {
            BTIF_TRACE_ERROR("%s(): poll() failed: return %d errno %d (%s)",
                           __func__, poll_ret, errno, strerror(errno));
            break;
        }

        //BTIF_TRACE_EVENT("poll revents %x", pfd.revents);