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
This commit is contained in:
David Anderson 2020-10-22 17:32:13 -07:00
parent 8e46846501
commit 6494a8ca97

View file

@ -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));
if (ret < 0) {
PLOG(ERROR) << "Snapuserd:client: recv failed";
} else if (ret == 0) {
LOG(DEBUG) << "Snapuserd:client disconnected";
} else {
msgStr.clear();
msgStr = msg;
}
ssize_t ret = TEMP_FAILURE_RETRY(recv(sockfd_, msg, sizeof(msg), 0));
if (ret < 0) {
PLOG(ERROR) << "Snapuserd:client: recv failed";
return {};
}
return msgStr;
if (ret == 0) {
LOG(DEBUG) << "Snapuserd:client disconnected";
return {};
}
return std::string(msg, ret);
}
bool SnapuserdClient::StopSnapuserd() {