From e79a3989ebb4cb9456200233e1e6a76ccbf80bf5 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 16 Jul 2021 16:43:55 -0400 Subject: [PATCH] fix(cgi-bin): repair wait until job is complete before responding --- cgi-bin/manage_vnc_pipes | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cgi-bin/manage_vnc_pipes b/cgi-bin/manage_vnc_pipes index acbace3f..08dd149d 100755 --- a/cgi-bin/manage_vnc_pipes +++ b/cgi-bin/manage_vnc_pipes @@ -48,6 +48,25 @@ AND return $vnc_pipe_info; } +sub is_job_incomplete +{ + my $parameters = shift; + my $job_uuid = $parameters->{job_uuid}; + + my $query = " +SELECT + job_progress +FROM + public.jobs +WHERE + job_uuid = ".$anvil->Database->quote($job_uuid)." +;"; + + my $job_progress = $anvil->Database->query({ query => $query, source => $THIS_FILE, line => __LINE__ })->[0]->[0]; + + return $job_progress == 100 ? 0 : 1; +} + $anvil->Get->switches; $anvil->Database->connect; @@ -115,7 +134,7 @@ if ($server_uuid) }); # Wait until the job is complete before continuing. - while($anvil->Job->get_job_details({ job_uuid => $job_uuid })) + while(is_job_incomplete({ job_uuid => $job_uuid })) { sleep(2); }