Skip to content

Commit 6ca3853

Browse files
authored
Merge pull request #6578 from AdamWill/worker-dbus-quota-fix
worker: disconnect dbus from NameOwnerChanged signal (POO #183833)
2 parents 371ad64 + 7c71f3f commit 6ca3853

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/OpenQA/Worker.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,12 @@ sub is_qemu_running ($self) {
611611
sub is_ovs_dbus_service_running ($self) {
612612
try { defined &Net::DBus::system or require Net::DBus }
613613
catch ($e) { return 0 }
614-
my $bus = ($self->{_system_dbus} //= Net::DBus->system(nomainloop => 1));
615-
try { return defined $bus->get_service('org.opensuse.os_autoinst.switch') }
614+
unless (defined $self->{_system_dbus}) {
615+
$self->{_system_dbus} = Net::DBus->system(nomainloop => 1);
616+
# this avoids piling up signals we never do anything with - POO #183833
617+
$self->{_system_dbus}->get_bus_object->disconnect_from_signal('NameOwnerChanged', 1);
618+
}
619+
try { return defined $self->{_system_dbus}->get_service('org.opensuse.os_autoinst.switch') }
616620
catch ($e) { return 0 }
617621
}
618622

t/24-worker-overall.t

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ my $guard = scope_guard sub { chdir $FindBin::Bin };
8080
use Mojo::Base -base;
8181
has availability_error => 'Cache service info error: Connection refused';
8282
}
83+
{
84+
package Test::FakeDBusObject;
85+
use Mojo::Base -base, -signatures;
86+
sub disconnect_from_signal ($self, $signal, $id) { }
87+
}
8388
{
8489
package Test::FakeDBus; # uncoverable statement count:2
8590
use Mojo::Base -base, -signatures;
8691
has mock_service_value => 1;
8792
sub get_service ($self, $service_name) { $self->mock_service_value }
93+
sub get_bus_object ($self) { Test::FakeDBusObject->new }
8894
}
8995

9096
my $dbus_mock = Test::MockModule->new('Net::DBus', no_auto => 1);

0 commit comments

Comments
 (0)