public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: [pve-devel] [PATCH manager] vzdump: getlock: return lock file handle and let the caller close it
Date: Mon, 12 Apr 2021 10:47:31 +0200	[thread overview]
Message-ID: <20210412084731.27810-1-f.ebner@proxmox.com> (raw)

so it doesn't get out of scope too early.

Regression introduced by a06e0311de595e19f6312a12d07c6767365d7a2c as pointed
out by Fabian Grünbichler.

Reported in the community forum:
https://forum.proxmox.com/threads/limit-simultaneous-backup-jobs.87489

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/API2/VZDump.pm | 4 +++-
 PVE/VZDump.pm      | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm
index 44376106..94bb0605 100644
--- a/PVE/API2/VZDump.pm
+++ b/PVE/API2/VZDump.pm
@@ -106,7 +106,7 @@ __PACKAGE__->register_method ({
 	    $param->{vmids} = $local_vmids;
 	    my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist);
 
-	    eval {
+	    my $LOCK_FH = eval {
 		$vzdump->getlock($upid); # only one process allowed
 	    };
 	    if (my $err = $@) {
@@ -122,6 +122,8 @@ __PACKAGE__->register_method ({
 		}
 	    }
 	    $vzdump->exec_backup($rpcenv, $user);
+
+	    close($LOCK_FH);
 	};
 
 	open STDOUT, '>/dev/null' if $param->{quiet} && !$param->{stdout};
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index fb4c8bad..171d208e 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -621,6 +621,8 @@ sub getlock {
     }
 
     PVE::Tools::file_set_contents($pidfile, $upid);
+
+    return $SERVER_FLCK;
 }
 
 sub run_hook_script {
-- 
2.20.1





             reply	other threads:[~2021-04-12  8:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  8:47 Fabian Ebner [this message]
2021-04-12 12:36 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412084731.27810-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal