summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2018-06-13 18:45:12 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2018-06-25 20:24:04 +0200
commit86befe0ac62022ab426940d0f8bfb462154b4518 (patch)
treecd3adfaf593c36d66ec4b70abd80b0a966d13f75 /apt-pkg
parent0abbb7c7a4bc745f28e5c8472e4c6ea8d481e030 (diff)
Fix lock counting in debSystem
debSystem uses a reference counted lock, so you can acquire it multiple times in your applications, possibly nested. Nesting locks causes a fd leak, though, as we only increment the lock count when we already have locked twice, rather than once, and hence when we call lock the second time, instead of increasing the lock count, we open another lock fd. This fixes the code to check if we have locked at all (> 0). There is no practical problem here aside from the fd leak, as closing the new fd releases the lock on the old one due to the weird semantics of fcntl locks. (cherry picked from commit 79f012bd09ae99d4c9d63dc0ac960376b5338b32) (cherry picked from commit 1edcb718293f24ad190703a345f8f868b6e3bcc4) LP: #1778547
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/debsystem.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 56ca8f4c6..7118b534b 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -79,7 +79,7 @@ debSystem::~debSystem()
bool debSystem::Lock()
{
// Disable file locking
- if (_config->FindB("Debug::NoLocking",false) == true || d->LockCount > 1)
+ if (_config->FindB("Debug::NoLocking",false) == true || d->LockCount > 0)
{
d->LockCount++;
return true;