From f04c20801414abfae84b56e3aac45dc5321ab1d9 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Wed, 7 Feb 2024 11:26:27 +0100 Subject: [PATCH] - handle getting several locks --- server/Client.cc | 10 ++++++---- server/Client.h | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/Client.cc b/server/Client.cc index c50b8686..b7aa9eeb 100644 --- a/server/Client.cc +++ b/server/Client.cc @@ -1,6 +1,6 @@ /* * Copyright (c) [2012-2015] Novell, Inc. - * Copyright (c) [2016-2023] SUSE LLC + * Copyright (c) [2016-2024] SUSE LLC * * All Rights Reserved. * @@ -127,21 +127,23 @@ Client::delete_comparison(list::iterator it) void Client::add_lock(const string& config_name) { - locks.insert(config_name); + locks[config_name]++; } void Client::remove_lock(const string& config_name) { - locks.erase(config_name); + map::iterator it = locks.find(config_name); + if (it != locks.end() && --it->second == 0) + locks.erase(it); } bool Client::has_lock(const string& config_name) const { - return contains(locks, config_name); + return locks.find(config_name) != locks.end(); } diff --git a/server/Client.h b/server/Client.h index 5fee4a3d..4ab504bc 100644 --- a/server/Client.h +++ b/server/Client.h @@ -1,6 +1,6 @@ /* * Copyright (c) [2012-2015] Novell, Inc. - * Copyright (c) [2016-2023] SUSE LLC + * Copyright (c) [2016-2024] SUSE LLC * * All Rights Reserved. * @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include @@ -151,7 +151,7 @@ class Client : private boost::noncopyable list comparisons; - set locks; + map locks; map, unsigned int> mounts;