5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00
Commit Graph

4 Commits

Author SHA1 Message Date
Fiona Ebner
903d285751 test: have lock file test use run_fork() helper
There are differences for error handling in the old and new helper, in
particular when the child is signaled. But the test here does not
explicitly check for specific error conditions or messages and is
therefore still correct with the new helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-14 20:44:53 +01:00
Fiona Ebner
de6ffbdebf test: lock file: get rid of END block that made test always pass
The exit code of the test would be the exit code of the 'rm' system
call, no matter if the test itself failed or not. Use an eval block
instead of the END block and propagate the error correctly.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-14 20:44:53 +01:00
Wolfgang Bumiller
3feb2c7661 tests: remove acquire-lock newline termination
Not needed anymore.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-11-10 11:29:54 +01:00
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