From 3d136a54de1f7171371e1bf09e88797c20782001 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 23 May 2017 19:37:58 +0100 Subject: [PATCH] only resolve fqdn once --- lib/App/Netdisco/JobQueue/PostgreSQL.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/App/Netdisco/JobQueue/PostgreSQL.pm b/lib/App/Netdisco/JobQueue/PostgreSQL.pm index 1429ce7a..b6c0fb1f 100644 --- a/lib/App/Netdisco/JobQueue/PostgreSQL.pm +++ b/lib/App/Netdisco/JobQueue/PostgreSQL.pm @@ -30,14 +30,15 @@ our @EXPORT_OK = qw/ /; our %EXPORT_TAGS = ( all => \@EXPORT_OK ); +# this can take a few seconds - only do it once +our $fqdn = hostfqdn || 'localhost'; + sub _getsome { my ($num_slots, $where) = @_; return () if ((!defined $num_slots) or ($num_slots < 1)); return () if ((!defined $where) or (ref {} ne ref $where)); - my $fqdn = hostfqdn || 'localhost'; my $jobs = schema('netdisco')->resultset('Admin'); - my $rs = $jobs->search({ status => 'queued', device => { '-not_in' => $jobs->skipped->columns('device')->as_query }, @@ -69,7 +70,6 @@ sub jq_getsomep { } sub jq_locked { - my $fqdn = hostfqdn || 'localhost'; my @returned = (); my $rs = schema('netdisco')->resultset('Admin') @@ -110,7 +110,6 @@ sub _get_denied_actions { } sub jq_prime_skiplist { - my $fqdn = hostfqdn || 'localhost'; my @devices = schema('netdisco')->resultset('Device')->all; my $rs = schema('netdisco')->resultset('DeviceSkip'); my %actionset = (); @@ -134,7 +133,6 @@ sub jq_prime_skiplist { sub jq_lock { my $job = shift; - my $fqdn = hostfqdn || 'localhost'; my $happy = false; # need to handle device discovered since backend daemon started @@ -183,7 +181,6 @@ sub jq_lock { sub jq_defer { my $job = shift; - my $fqdn = hostfqdn || 'localhost'; my $happy = false; # note this taints all actions on the device. for example if both