5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-08 01:17:37 +03:00
pve-common/test
Wolfgang Bumiller d9f86d0d87 Tools: make file-locking aware of external exception sources
Previously an external exception (eg. caused by a SIGARLM in a code
which is already inside a run_with_timeout() call) could happen in
various places where we did not properly this situation.
For instance after calling $lock_func() but before reaching the cleanup
code. In this case a lock was leaked.
Additionally the code was broken in that it used perl's automatic hash
creation side effect ($a->{x}->{y} implicitly initializing $a->{x} with
an empty hash when it did not exist). The effect was that if our own
time out was triggered after the initial check for an existing file
handle inside $lock_func() happened (extremely rare since perl would have
to be running insanely slow), the cleanup did:

    if (my $fh = $lock_handles->{$$}->{$filename}->{fh}) {

This recreated $lock_handles->{$$}->{$filename} as an empty hash.
A subsequent call to lock_file_full() will think a file descriptor
already exists because the check simply used:

    if (!$lock_handles->{$$}->{$filename}) {

While this could have been a one-line fix for this one particular case,
we'd still not be taking external timeouts into account causing the
first issue described above.
2017-05-12 11:40:26 +02:00
..
etc_network_interfaces runtest.pl: use lib '.' - because newer perl does not have that by default 2017-01-24 11:12:53 +01:00
lock_file.pl Tools: make file-locking aware of external exception sources 2017-05-12 11:40:26 +02:00
Makefile Tools: make file-locking aware of external exception sources 2017-05-12 11:40:26 +02:00