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
diff --git a/fs_mgr/libsnapshot/snapuserd_client.cpp b/fs_mgr/libsnapshot/snapuserd_client.cpp
index fcc41a7..35bb29b 100644
--- a/fs_mgr/libsnapshot/snapuserd_client.cpp
+++ b/fs_mgr/libsnapshot/snapuserd_client.cpp
@@ -138,33 +138,17 @@
}
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() {