From 0a3aee9d829c9672d81d9f6fcf333a72fe34f009 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 20 Feb 2019 22:18:13 +0100 Subject: [PATCH] storage/udisks2: move code to SetMountPoint() --- src/storage/plugins/UdisksStorage.cxx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/storage/plugins/UdisksStorage.cxx b/src/storage/plugins/UdisksStorage.cxx index df2e937ae..ece74cad4 100644 --- a/src/storage/plugins/UdisksStorage.cxx +++ b/src/storage/plugins/UdisksStorage.cxx @@ -120,6 +120,9 @@ public: const char *MapToRelativeUTF8(const char *uri_utf8) const noexcept override; private: + void SetMountPoint(const char *mount_point); + void LockSetMountPoint(const char *mount_point); + void OnListReply(ODBus::Message reply) noexcept; void MountWait(); @@ -131,6 +134,22 @@ private: void OnUnmountNotify(ODBus::Message reply) noexcept; }; +inline void +UdisksStorage::SetMountPoint(const char *mount_point) +{ + mounted_storage = CreateLocalStorage(Path::FromFS(mount_point)); + mount_error = {}; + want_mount = false; + cond.broadcast(); +} + +void +UdisksStorage::LockSetMountPoint(const char *mount_point) +{ + const std::lock_guard lock(mutex); + SetMountPoint(mount_point); +} + void UdisksStorage::OnListReply(ODBus::Message reply) noexcept { @@ -224,12 +243,7 @@ try { throw std::runtime_error("Malformed 'Mount' response"); const char *mount_path = i.GetString(); - - const std::lock_guard lock(mutex); - mounted_storage = CreateLocalStorage(Path::FromFS(mount_path)); - mount_error = {}; - want_mount = false; - cond.broadcast(); + LockSetMountPoint(mount_path); } catch (...) { const std::lock_guard lock(mutex); mount_error = std::current_exception();