* [pve-devel] [PATCH common] fix #4615: RESTEnvironment: correctly detect AnyEvent in SIGCHLD handler
@ 2023-03-27 8:26 Dominik Csapak
2023-03-27 8:37 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2023-03-27 8:26 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH common] fix #4615: RESTEnvironment: correctly detect AnyEvent in SIGCHLD handler
2023-03-27 8:26 [pve-devel] [PATCH common] fix #4615: RESTEnvironment: correctly detect AnyEvent in SIGCHLD handler Dominik Csapak
@ 2023-03-27 8:37 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-03-27 8:37 UTC (permalink / raw)
To: Proxmox VE development discussion, Dominik Csapak
Am 27/03/2023 um 10:26 schrieb Dominik Csapak:
> we assumed that the 'priv' and 'pub' RESTEnvironment types always
We might push it a bit here ;-)
https://lists.proxmox.com/pipermail/pve-devel/2023-March/056057.html
> 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(-)
>
>
applied, with commit subject/message touch up, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-27 8:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 8:26 [pve-devel] [PATCH common] fix #4615: RESTEnvironment: correctly detect AnyEvent in SIGCHLD handler Dominik Csapak
2023-03-27 8:37 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox