Merge "libsnapshot: Wait for daemon to terminate after snapshot unamp" am: 1324002fbf
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2431652 Change-Id: Ieb696ff287c2209d6d9f9feca60712a0ed6d1217 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
9690d12f8b
2 changed files with 19 additions and 0 deletions
|
@ -47,6 +47,8 @@ class SnapuserdClient {
|
|||
bool ValidateConnection();
|
||||
std::string GetDaemonAliveIndicatorPath();
|
||||
|
||||
void WaitForServiceToTerminate(std::chrono::milliseconds timeout_ms);
|
||||
|
||||
public:
|
||||
explicit SnapuserdClient(android::base::unique_fd&& sockfd);
|
||||
SnapuserdClient(){};
|
||||
|
|
|
@ -94,6 +94,21 @@ std::unique_ptr<SnapuserdClient> SnapuserdClient::Connect(const std::string& soc
|
|||
return client;
|
||||
}
|
||||
|
||||
void SnapuserdClient::WaitForServiceToTerminate(std::chrono::milliseconds timeout_ms) {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
while (android::base::GetProperty("init.svc.snapuserd", "") == "running") {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
|
||||
if (elapsed >= timeout_ms) {
|
||||
LOG(ERROR) << "Timed out - Snapuserd service did not stop - Forcefully terminating the "
|
||||
"service";
|
||||
android::base::SetProperty("ctl.stop", "snapuserd");
|
||||
return;
|
||||
}
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
}
|
||||
|
||||
bool SnapuserdClient::ValidateConnection() {
|
||||
if (!Sendmsg("query")) {
|
||||
return false;
|
||||
|
@ -238,6 +253,8 @@ bool SnapuserdClient::DetachSnapuserd() {
|
|||
LOG(ERROR) << "Failed to detach snapuserd.";
|
||||
return false;
|
||||
}
|
||||
|
||||
WaitForServiceToTerminate(3s);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue