public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common] fix #4615: RESTEnvironment: correctly detect AnyEvent in SIGCHLD handler
Date: Mon, 27 Mar 2023 10:26:32 +0200	[thread overview]
Message-ID: <20230327082632.1295960-1-d.csapak@proxmox.com> (raw)

we assumed that the 'priv' and 'pub' RESTEnvironment types always
contained an AnyEvent eventloop, but this is actually not the case
in pvestatd and pvescheduler.

When we wrongly determined that, it depended on the used model that AnyEvent
used (and autodetected) if it worked or not. With AnyEvent::Impl::Perl it did
not make problems (and seemingly worked by accident), but when using
AnyEvent::Impl::EV (which is autodetected and used when libev-perl is installed)
it interfered with our SIG_CHLD handlers and only ever called them once.
(Not clear why this happens, maybe because AnyEvent is not setup correctly).

This patch uses $AnyEvent::MODEL as a detection instead since this
is `undef` until the first AnyEvent watcher is created, which should
be only the case where we really use AnyEvent, such as pveproxy and
pvedaemon.

Fixes: 6870afa ("RESTEnvironment: better SIGCHLD handling in AnyEvent event loop")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PVE/RESTEnvironment.pm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
index c258b1e..89def38 100644
--- a/src/PVE/RESTEnvironment.pm
+++ b/src/PVE/RESTEnvironment.pm
@@ -112,12 +112,10 @@ sub init {
     die "unknown environment type"
 	if !$type || $type !~ m/^(cli|pub|priv|ha)$/;
 
-    my $has_anyevent = $type eq 'pub' || $type eq 'priv';
-
     $SIG{CHLD} = sub {
-	# when we're in an api server, we have to postpone the call to worker_reaper, otherwise it
+	# when we're using AnyEvent, we have to postpone the call to worker_reaper, otherwise it
 	# might interfere with running api calls
-	if ($has_anyevent) {
+	if (defined($AnyEvent::MODEL)) {
 	    AnyEvent::postpone { $worker_reaper->() };
 	} else {
 	    $worker_reaper->();
-- 
2.30.2





             reply	other threads:[~2023-03-27  8:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  8:26 Dominik Csapak [this message]
2023-03-27  8:37 ` [pve-devel] applied: " 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=20230327082632.1295960-1-d.csapak@proxmox.com \
    --to=d.csapak@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal