This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=bc1742b6cd533c7f14609891782aa51c3fe03f0f commit bc1742b6cd533c7f14609891782aa51c3fe03f0f Author: Guillem Jover <[email protected]> AuthorDate: Mon Aug 25 22:51:03 2025 +0200 Dpkg::Lock: Restructure file_lock code to make it easier to add fallback Move the code that expects the use eval to work immediately after it, and make it perform an early return, so that the next code can act as a fallback. --- scripts/Dpkg/Lock.pm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/Dpkg/Lock.pm b/scripts/Dpkg/Lock.pm index 44c9781e1..dab309a33 100644 --- a/scripts/Dpkg/Lock.pm +++ b/scripts/Dpkg/Lock.pm @@ -52,21 +52,23 @@ sub file_lock { eval q{ use File::FcntlLock; }; - if ($@) { - # On Linux systems the flock() locks get converted to file-range - # locks on NFS mounts. - if ($^O ne 'linux') { - warning(g_('File::FcntlLock not available; using flock which is not NFS-safe')); - } - flock($fh, LOCK_EX) - or syserr(g_('failed to get a write lock on %s'), $filename); - } else { + if (not $@) { eval q{ my $fs = File::FcntlLock->new(l_type => F_WRLCK); $fs->lock($fh, F_SETLKW) or syserr(g_('failed to get a write lock on %s'), $filename); - } + }; + return; } + + # On Linux systems the flock() locks get converted to file-range + # locks on NFS mounts. + if ($^O ne 'linux') { + warning(g_('File::FcntlLock not available; using flock which is not NFS-safe')); + } + flock $fh, LOCK_EX + or syserr(g_('failed to get a write lock on %s'), $filename); + return; } =head1 CHANGES -- Dpkg.Org's dpkg

