From 03a92190703390cf482742817ac42b791fae265a Mon Sep 17 00:00:00 2001 From: Marius Kittler Date: Mon, 13 Jan 2025 18:32:51 +0100 Subject: [PATCH] Avoid calling `is_running` unnecessarily in `kill` The `stop` function does the same check internally so it isn't required. Related ticket: https://progress.opensuse.org/issues/170209 --- lib/OpenQA/Worker/Job.pm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/OpenQA/Worker/Job.pm b/lib/OpenQA/Worker/Job.pm index c73965dcd1b..48aa70c9276 100644 --- a/lib/OpenQA/Worker/Job.pm +++ b/lib/OpenQA/Worker/Job.pm @@ -315,14 +315,9 @@ sub _handle_engine_startup ($self, $engine, $max_job_time) { $self->_set_status(running => {}); } -sub kill { - my ($self) = @_; - - my $engine = $self->engine; - return unless $engine; - - my $child = $engine->{child}; - $child->stop if $child && $child->is_running; +sub kill ($self) { + return undef unless my $engine = $self->engine; + if (my $child = $engine->{child}) { $child->stop } } sub skip {