diff options
author | Akilesh Kailash <akailash@google.com> | 2021-04-06 18:02:52 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-04-06 18:02:52 +0000 |
commit | 591edca44d5da68e05eefdec2d694fd86366143f (patch) | |
tree | ed8ba2b59918831e2d7104b039b22f96258c46fc | |
parent | de2769dc1e4ab7194c1724fb0979ecd29291f253 (diff) | |
parent | e2883c1ea03e053f693b4ff87d2710eaead0cb2b (diff) |
Merge "libsnapshot:snapuserd: Terminate daemon after applying OTA."
-rw-r--r-- | fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h | 2 | ||||
-rw-r--r-- | fs_mgr/libsnapshot/snapshot.cpp | 11 | ||||
-rw-r--r-- | fs_mgr/libsnapshot/snapshot_test.cpp | 2 |
3 files changed, 15 insertions, 0 deletions
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h index 1dab361c1..280e85730 100644 --- a/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h +++ b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h @@ -69,6 +69,8 @@ class SnapuserdClient { // must ONLY be called if the control device has already been deleted. bool WaitForDeviceDelete(const std::string& control_device); + void CloseConnection() { sockfd_ = {}; } + // Detach snapuserd. This shuts down the listener socket, and will cause // snapuserd to gracefully exit once all handler threads have terminated. // This should only be used on first-stage instances of snapuserd. diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index 2c5bf754c..a0a1e4f5f 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -2297,6 +2297,17 @@ bool SnapshotManager::UnmapAllSnapshots(LockedFile* lock) { return false; } } + + // Terminate the daemon and release the snapuserd_client_ object. + // If we need to re-connect with the daemon, EnsureSnapuserdConnected() + // will re-create the object and establish the socket connection. + if (snapuserd_client_) { + LOG(INFO) << "Shutdown snapuserd daemon"; + snapuserd_client_->DetachSnapuserd(); + snapuserd_client_->CloseConnection(); + snapuserd_client_ = nullptr; + } + return true; } diff --git a/fs_mgr/libsnapshot/snapshot_test.cpp b/fs_mgr/libsnapshot/snapshot_test.cpp index 6ed012941..8fae00b75 100644 --- a/fs_mgr/libsnapshot/snapshot_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_test.cpp @@ -2019,6 +2019,8 @@ TEST_F(SnapshotUpdateTest, MapAllSnapshots) { // Read bytes back and verify they match the cache. ASSERT_TRUE(IsPartitionUnchanged("sys_b")); + + ASSERT_TRUE(sm->UnmapAllSnapshots()); } TEST_F(SnapshotUpdateTest, CancelOnTargetSlot) { |