From: Dominik Csapak Date: Thu, 16 Feb 2017 08:24:18 +0000 (+0100) Subject: (maybe) fixes #1229: fix port reservation X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=3c476ed580e5a934ce4d29a63612364c909fbd83 (maybe) fixes #1229: fix port reservation when reserving ports, we use lock_file to lock the reservation file, but then use file_set_content which writes a new file and renames it, making the lock invalid and different processes waiting for the lock get inconsistent data instead we use a designated lock file for the lock, so that we don't lose the lock when writing the reservation file this should fix the problem that sometimes multiple vms get the same vnc/spice port Signed-off-by: Dominik Csapak --- diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 82d598e..69c8730 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -799,7 +799,7 @@ sub next_unused_port { return $newport; }; - my $p = lock_file($filename, 10, $code); + my $p = lock_file('/var/lock/pve-ports.lck', 10, $code); die $@ if $@; die "unable to find free port (${range_start}-${range_end})\n" if !$p;