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

Commit 6494a8ca authored by David Anderson's avatar David Anderson
Browse files

libsnapshot: Remove the timeout on client recv().

Two seconds is a bit aggressive - considering this is analagous to a
synchronous binder call, let's drop the timeout entirely.

Bug: 168554689
Test: vts_libsnapshot_test
Change-Id: I2b3f5b33f79575d72b15ed314dbcc0ad20ebd9a8
parent 8e468465
Loading
Loading
Loading
Loading
+9 −25
Original line number Diff line number Diff line
@@ -138,33 +138,17 @@ bool SnapuserdClient::WaitForDeviceDelete(const std::string& control_device) {
}

std::string SnapuserdClient::Receivemsg() {
    int ret;
    struct timeval tv;
    fd_set set;
    char msg[PACKET_SIZE];
    std::string msgStr("fail");

    tv.tv_sec = 2;
    tv.tv_usec = 0;
    FD_ZERO(&set);
    FD_SET(sockfd_, &set);
    ret = select(sockfd_ + 1, &set, NULL, NULL, &tv);
    if (ret == -1) {  // select failed
        LOG(ERROR) << "Snapuserd:client: Select call failed";
    } else if (ret == 0) {  // timeout
        LOG(ERROR) << "Snapuserd:client: Select call timeout";
    } else {
        ret = TEMP_FAILURE_RETRY(recv(sockfd_, msg, PACKET_SIZE, 0));
    ssize_t ret = TEMP_FAILURE_RETRY(recv(sockfd_, msg, sizeof(msg), 0));
    if (ret < 0) {
        PLOG(ERROR) << "Snapuserd:client: recv failed";
        } else if (ret == 0) {
            LOG(DEBUG) << "Snapuserd:client disconnected";
        } else {
            msgStr.clear();
            msgStr = msg;
        return {};
    }
    if (ret == 0) {
        LOG(DEBUG) << "Snapuserd:client disconnected";
        return {};
    }
    return msgStr;
    return std::string(msg, ret);
}

bool SnapuserdClient::StopSnapuserd() {