libsnapuserd: Handle empty response from server

If server disconnects, then handle the empty response.

Bug: 377068272
Test: Full OTA
Change-Id: Ic48204c457ef924ba9a3c1ae84a3317fb1ccda04
Signed-off-by: Akilesh Kailash <akailash@google.com>
This commit is contained in:
Akilesh Kailash 2024-11-02 23:43:22 -07:00
parent a5560db8cc
commit 454167f5bd

View file

@ -311,6 +311,11 @@ double SnapuserdClient::GetMergePercent() {
}
std::string response = Receivemsg();
// If server socket disconnects most likely because of device reboot,
// then we just return 0.
if (response.empty()) {
return 0.0;
}
return std::stod(response);
}