all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common 2/2] run fork with timeout: only special case timeout error in list context
Date: Wed, 30 Aug 2023 15:07:52 +0200	[thread overview]
Message-ID: <20230830130752.85746-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20230830130752.85746-1-f.ebner@proxmox.com>

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 | 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





  reply	other threads:[~2023-08-30 13:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 13:07 [pve-devel] [PATCH common 1/2] run with timeout: only special-case timeout error in list-context Fiona Ebner
2023-08-30 13:07 ` Fiona Ebner [this message]
2023-08-30 14:45 ` [pve-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230830130752.85746-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal