]> git.proxmox.com Git - pve-common.git/commitdiff
run fork with timeout: only special case timeout error in list context
authorFiona Ebner <f.ebner@proxmox.com>
Wed, 30 Aug 2023 13:07:52 +0000 (15:07 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 30 Aug 2023 14:44:40 +0000 (16:44 +0200)
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@proxmox.com>
src/PVE/Tools.pm

index 724fb696b2c7c78a7dd4168ca9914a4bf2573683..2cfe93f7f0f4cbe909a3c2df54aac3ec825d0e4a 100644 (file)
@@ -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->();
        }