From 6494a8ca972710de70078e8c86112fa19bc82d11 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 22 Oct 2020 17:32:13 -0700 Subject: [PATCH] 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 --- fs_mgr/libsnapshot/snapuserd_client.cpp | 34 +++++++------------------ 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/fs_mgr/libsnapshot/snapuserd_client.cpp b/fs_mgr/libsnapshot/snapuserd_client.cpp index fcc41a7e7..35bb29b8b 100644 --- a/fs_mgr/libsnapshot/snapuserd_client.cpp +++ b/fs_mgr/libsnapshot/snapuserd_client.cpp @@ -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() {