Skip to content

Commit

Permalink
- handle getting several locks
Browse files Browse the repository at this point in the history
  • Loading branch information
aschnell committed Feb 7, 2024
1 parent c23da18 commit f04c208
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions server/Client.cc
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -127,21 +127,23 @@ Client::delete_comparison(list<Comparison*>::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<string, unsigned int>::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();
}


Expand Down
6 changes: 3 additions & 3 deletions server/Client.h
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -28,7 +28,7 @@
#include <string>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <boost/thread.hpp>

#include <snapper/Snapper.h>
Expand Down Expand Up @@ -151,7 +151,7 @@ class Client : private boost::noncopyable

list<Comparison*> comparisons;

set<string> locks;
map<string, unsigned int> locks;

map<pair<string, unsigned int>, unsigned int> mounts;

Expand Down

0 comments on commit f04c208

Please sign in to comment.