From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A26161FF176 for ; Fri, 7 Mar 2025 09:28:55 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 134A914E68; Fri, 7 Mar 2025 09:28:49 +0100 (CET) Date: Fri, 7 Mar 2025 09:28:42 +0100 From: Wolfgang Bumiller To: Maximiliano Sandoval Message-ID: <7ufqj34mboo72vox467xdfgkmhgfeq4xczorxgkl56gnmpejtf@iuvjawkkv7dl> References: <20250307081414.57671-1-m.sandoval@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250307081414.57671-1-m.sandoval@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.082 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] applied: [PATCH pve-common v2] systemd: disconnect signals X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: pve-devel@lists.proxmox.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" applied, with a minor cleanup On Fri, Mar 07, 2025 at 09:14:14AM +0100, Maximiliano Sandoval wrote: > Dbus has a limit of 512 connections by default and signals should be > disconnected as soon as they are not needed anymore. > > This should alleviate https://bugzilla.proxmox.com/show_bug.cgi?id=5876. > > Signed-off-by: Maximiliano Sandoval > --- > > Differences from v1: > - remove two guards on finish_callback > > src/PVE/Systemd.pm | 30 ++++++++++++++++++++++++------ > 1 file changed, 24 insertions(+), 6 deletions(-) > > diff --git a/src/PVE/Systemd.pm b/src/PVE/Systemd.pm > index 07c912e3..14038e0c 100644 > --- a/src/PVE/Systemd.pm > +++ b/src/PVE/Systemd.pm > @@ -44,6 +44,7 @@ sub unescape_unit { > # main loop is being used as we need to wait signals. > sub systemd_call($;$) { > my ($code, $timeout) = @_; > + my $signal_info; ^ moved this down to the rest of the vars shared with the callback > > my $bus = Net::DBus->system(); > my $reactor = Net::DBus::Reactor->main(); > @@ -64,13 +65,18 @@ sub systemd_call($;$) { > $timer = undef; > } > > + if (defined($signal_info)) { > + $if->disconnect_from_signal($signal_info->{name}, $signal_info->{handle}); > + $signal_info = undef; > + } > + > if (defined($reactor)) { > $reactor->shutdown(); > $reactor = undef; > } > }; > > - my $result = $code->($if, $reactor, $finish_callback); > + (my $result, $signal_info) = $code->($if, $reactor, $finish_callback); > # Are we done immediately? > return $result if defined $result; > > @@ -124,7 +130,8 @@ sub enter_systemd_scope { > > my $job; > > - $if->connect_to_signal('JobRemoved', sub { > + my $signal_name = 'JobRemoved'; > + my $signal_handle = $if->connect_to_signal($signal_name, sub { > my ($id, $removed_job, $signaled_unit, $result) = @_; > return if $signaled_unit ne $unit || $removed_job ne $job; > if ($result ne 'done') { > @@ -139,7 +146,12 @@ sub enter_systemd_scope { > > $job = $if->StartTransientUnit($unit, 'fail', $properties, []); > > - return undef; > + my $signal_info = { > + name => $signal_name, > + handle => $signal_handle, > + }; > + > + return (undef, $signal_info); > }, $timeout); > } > > @@ -152,18 +164,24 @@ sub wait_for_unit_removed($;$) { > my $unit_obj = eval { $if->GetUnit($unit) }; > return 1 if !$unit_obj; > > - $if->connect_to_signal('UnitRemoved', sub { > + my $signal_name = 'UnitRemoved'; > + my $signal_handle = $if->connect_to_signal($signal_name, sub { > my ($id, $removed_unit) = @_; > $finish_cb->(1) if $removed_unit eq $unit_obj; > }); > > + my $signal_info = { > + name => $signal_name, > + handle => $signal_handle, > + }; > + > # Deal with what we lost between GetUnit() and connecting to UnitRemoved: > my $unit_obj_new = eval { $if->GetUnit($unit) }; > if (!$unit_obj_new) { > - return 1; > + return (1, $signal_info); > } > > - return undef; > + return (undef, $signal_info); > }, $timeout); > } > > -- > 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel