[pve-devel] [PATCH common 2/2] run fork with timeout: only special case timeout error in list context
Fiona Ebner
f.ebner at proxmox.com
Wed Aug 30 15:07:52 CEST 2023
run_with_timeout() will treat a timeout error differently when called
in list context and run_fork_with_timeout() should do the same. Ensure
this by calling run_with_timeout() in list context if and only if
run_fork_with_timeout() is called in list context too.
Fixes: a6aa0ae ("run with timeout: return if timeout happened in list context")
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/Tools.pm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 724fb69..2cfe93f 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -1017,10 +1017,16 @@ sub run_fork_with_timeout {
$res = $child_res->{result};
$error = $child_res->{error};
};
+
my $got_timeout = 0;
+ my $wantarray = wantarray; # so it can be queried inside eval
eval {
if (defined($timeout)) {
- (undef, $got_timeout) = run_with_timeout($timeout, $readvalues);
+ if ($wantarray) {
+ (undef, $got_timeout) = run_with_timeout($timeout, $readvalues);
+ } else {
+ run_with_timeout($timeout, $readvalues);
+ }
} else {
$readvalues->();
}
--
2.39.2
More information about the pve-devel
mailing list