pakfire.cgi: Implement logic to lock the page until pakfire has been fully launched.
Message ID | 20211018190958.3752-1-stefan.schantl@ipfire.org |
---|---|
State | Accepted |
Commit | 7f7f546e4ae25d75738d6c326149476d7def615a |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4HY5zm0104z3wcq for <patchwork@web04.haj.ipfire.org>; Mon, 18 Oct 2021 19:10:11 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4HY5zk4Nd7z16B; Mon, 18 Oct 2021 19:10:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4HY5zk1Fn7z2xy0; Mon, 18 Oct 2021 19:10:10 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4HY5zh2P5Tz2xLr for <development@lists.ipfire.org>; Mon, 18 Oct 2021 19:10:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4HY5zg3fn7zNh; Mon, 18 Oct 2021 19:10:07 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1634584207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ThzQCo8Ixbr/IWSoQFv5zsiuRZYGfucU+UQ7RGKx/PI=; b=tStTREZKwtz1BZ6js4hMGJaWxPBHJptpDnGPtugYpS8u1k68kur5KK/IyyMl0gtYFQvn8O FN4ckL+Oye/3URBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1634584207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ThzQCo8Ixbr/IWSoQFv5zsiuRZYGfucU+UQ7RGKx/PI=; b=FmwWOf0A0S9VlQ5eLEC8GWskGO4Ta9giMi1y8qT4aQFgG8ZqYHgVBcrPj+PxF5pRRPcpwE RKLBSyM1W8oChuDNJYDbEJVbv0eu+5AUPjCO23/p8IAl1YTM1KLtqArmgyvwNHgzFOyvj+ ZeWTuLP0B8IBJIzYZDX/PV9cFHwy2/kIyQVrPu81b1V3KFIJyl1dZXeRmsjo1Qju5FrZf6 eCqdMgPloKNPa6omexIuS7scZl3tsL0fPgE52pFzW6USrRnFU03plAHwpneFCx1TfOS4SE B1/wFimIK4n/s9aEYNNT65GE3jdcD1fPe5PRUpB2pFAm/O7rJOwnle+oMKRCYA== From: Stefan Schantl <stefan.schantl@ipfire.org> To: development@lists.ipfire.org Subject: [PATCH] pakfire.cgi: Implement logic to lock the page until pakfire has been fully launched. Date: Mon, 18 Oct 2021 21:09:58 +0200 Message-Id: <20211018190958.3752-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> List-Unsubscribe: <https://lists.ipfire.org/mailman/options/development>, <mailto:development-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/development/> List-Post: <mailto:development@lists.ipfire.org> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Subscribe: <https://lists.ipfire.org/mailman/listinfo/development>, <mailto:development-request@lists.ipfire.org?subject=subscribe> Errors-To: development-bounces@lists.ipfire.org Sender: "Development" <development-bounces@lists.ipfire.org> |
Series |
pakfire.cgi: Implement logic to lock the page until pakfire has been fully launched.
|
|
Commit Message
Stefan Schantl
Oct. 18, 2021, 7:09 p.m. UTC
When performing any action which requires pakfire, the page gets locked
with an message informing the user that pakfire is working. The page
will be reloaded when pakfire has been launched and is doing the
requested operation - showing the well known log output. This also
happens when pakfire has been launched via any kind of terminal or SSH
session and the CGI gets accessed.
Internally before pakfire gets started a variable called page_lock will
be set to lock the page. An while loop will keep the page locked until
pakfire is launched fully and has written it's lock_file.
This approach will prevent us from any kind of required time intervall
or race conditions.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
html/cgi-bin/pakfire.cgi | 49 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
Comments
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org> The locking is functioning. But the excerpt of /var/log/messages isn't displayed. Am 18.10.2021 um 21:09 schrieb Stefan Schantl: > When performing any action which requires pakfire, the page gets locked > with an message informing the user that pakfire is working. The page > will be reloaded when pakfire has been launched and is doing the > requested operation - showing the well known log output. This also > happens when pakfire has been launched via any kind of terminal or SSH > session and the CGI gets accessed. > > Internally before pakfire gets started a variable called page_lock will > be set to lock the page. An while loop will keep the page locked until > pakfire is launched fully and has written it's lock_file. > > This approach will prevent us from any kind of required time intervall > or race conditions. > > Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org> > --- > html/cgi-bin/pakfire.cgi | 49 ++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 47 insertions(+), 2 deletions(-) > > diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi > index 0cf522ba1..f2381f031 100644 > --- a/html/cgi-bin/pakfire.cgi > +++ b/html/cgi-bin/pakfire.cgi > @@ -44,6 +44,8 @@ $cgiparams{'VALID'} = ''; > $cgiparams{'INSPAKS'} = ''; > $cgiparams{'DELPAKS'} = ''; > > +my $page_lock; > + > sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} > > &Header::getcgihash(\%cgiparams); > @@ -57,8 +59,9 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont > if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) { > my @pkgs = split(/\|/, $cgiparams{'INSPAKS'}); > if ("$cgiparams{'FORCE'}" eq "on") { > + # Lock the page. > + $page_lock = "1"; > &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs); > - sleep(2); > } else { > &Header::openbox("100%", "center", $Lang::tr{'request'}); > my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); > @@ -95,8 +98,9 @@ END > } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) { > my @pkgs = split(/\|/, $cgiparams{'DELPAKS'}); > if ("$cgiparams{'FORCE'}" eq "on") { > + # Lock the page. > + $page_lock = "1"; > &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs); > - sleep(2); > } else { > &Header::openbox("100%", "center", $Lang::tr{'request'}); > my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); > @@ -132,8 +136,12 @@ END > } > > } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) { > + # Set variable to lock the page. > + $page_lock = "1"; > &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); > } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) { > + # Lock the page. > + $page_lock = "1"; > &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors"); > } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") { > $pakfiresettings{"TREE"} = $cgiparams{"TREE"}; > @@ -169,6 +177,43 @@ if ($errormessage) { > &Header::closebox(); > } > > +# Check if a page lock is required. > +if ($page_lock) { > + &Header::openbox('Waiting', 1, ,); > + print <<END; > + <table> > + <tr> > + <td> > + <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}'> > + </td> > + > + <td> > + $Lang::tr{'pakfire working'} > + </td> > + </tr> > + </table> > +END > + &Header::closebox(); > + > + # Infinite loop to lock the page until pakfire lockfile is present. > + while($page_lock) { > + unless (-e $Pakfire::lockfile) { > + sleep(1); > + } else { > + # Release page lock. > + undef($page_lock); > + > + # Break loop. > + last; > + } > + } > + > + # Perform page reload. > + print "<meta http-equiv='refresh' content='1;'>\n"; > + exit; > +} > + > +# Check if pakfire is already running. In this case a lockfile is present. > if (-e $Pakfire::lockfile) { > &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" ); > print <<END; >
In Core Update 161 (testing): Same issue. I see the spin and Pakfire is working . . . but no messages. IPFire 2.27 (x86_64) - Core Update 161 Development Build: master/191347cc Jon > On Oct 21, 2021, at 5:17 AM, Bernhard Bitsch <bbitsch@ipfire.org> wrote: > > Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org> > > The locking is functioning. > But the excerpt of /var/log/messages isn't displayed. > > Am 18.10.2021 um 21:09 schrieb Stefan Schantl: >> When performing any action which requires pakfire, the page gets locked >> with an message informing the user that pakfire is working. The page >> will be reloaded when pakfire has been launched and is doing the >> requested operation - showing the well known log output. This also >> happens when pakfire has been launched via any kind of terminal or SSH >> session and the CGI gets accessed. >> Internally before pakfire gets started a variable called page_lock will >> be set to lock the page. An while loop will keep the page locked until >> pakfire is launched fully and has written it's lock_file. >> This approach will prevent us from any kind of required time intervall >> or race conditions. >> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org> >> --- >> html/cgi-bin/pakfire.cgi | 49 ++++++++++++++++++++++++++++++++++++++-- >> 1 file changed, 47 insertions(+), 2 deletions(-) >> diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi >> index 0cf522ba1..f2381f031 100644 >> --- a/html/cgi-bin/pakfire.cgi >> +++ b/html/cgi-bin/pakfire.cgi >> @@ -44,6 +44,8 @@ $cgiparams{'VALID'} = ''; >> $cgiparams{'INSPAKS'} = ''; >> $cgiparams{'DELPAKS'} = ''; >> +my $page_lock; >> + >> sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} >> &Header::getcgihash(\%cgiparams); >> @@ -57,8 +59,9 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont >> if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) { >> my @pkgs = split(/\|/, $cgiparams{'INSPAKS'}); >> if ("$cgiparams{'FORCE'}" eq "on") { >> + # Lock the page. >> + $page_lock = "1"; >> &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs); >> - sleep(2); >> } else { >> &Header::openbox("100%", "center", $Lang::tr{'request'}); >> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >> @@ -95,8 +98,9 @@ END >> } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) { >> my @pkgs = split(/\|/, $cgiparams{'DELPAKS'}); >> if ("$cgiparams{'FORCE'}" eq "on") { >> + # Lock the page. >> + $page_lock = "1"; >> &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs); >> - sleep(2); >> } else { >> &Header::openbox("100%", "center", $Lang::tr{'request'}); >> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >> @@ -132,8 +136,12 @@ END >> } >> } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) { >> + # Set variable to lock the page. >> + $page_lock = "1"; >> &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); >> } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) { >> + # Lock the page. >> + $page_lock = "1"; >> &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors"); >> } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") { >> $pakfiresettings{"TREE"} = $cgiparams{"TREE"}; >> @@ -169,6 +177,43 @@ if ($errormessage) { >> &Header::closebox(); >> } >> +# Check if a page lock is required. >> +if ($page_lock) { >> + &Header::openbox('Waiting', 1, ,); >> + print <<END; >> + <table> >> + <tr> >> + <td> >> + <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}'> >> + </td> >> + >> + <td> >> + $Lang::tr{'pakfire working'} >> + </td> >> + </tr> >> + </table> >> +END >> + &Header::closebox(); >> + >> + # Infinite loop to lock the page until pakfire lockfile is present. >> + while($page_lock) { >> + unless (-e $Pakfire::lockfile) { >> + sleep(1); >> + } else { >> + # Release page lock. >> + undef($page_lock); >> + >> + # Break loop. >> + last; >> + } >> + } >> + >> + # Perform page reload. >> + print "<meta http-equiv='refresh' content='1;'>\n"; >> + exit; >> +} >> + >> +# Check if pakfire is already running. In this case a lockfile is present. >> if (-e $Pakfire::lockfile) { >> &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" ); >> print <<END;
Hello, I had a brief phone call with Stefan yesterday where he said that he was going to have a look at this again. In the meantime he said that the patch can be shipped because it does not break anything, although it doesn’t solve the problem it was meant to solve either. Can everybody confirm this? -Michael > On 5 Nov 2021, at 19:10, Jon Murphy <jcmurphy26@gmail.com> wrote: > > In Core Update 161 (testing): Same issue. I see the spin and Pakfire is working . . . but no messages. > > IPFire 2.27 (x86_64) - Core Update 161 Development Build: master/191347cc > > Jon > > >> On Oct 21, 2021, at 5:17 AM, Bernhard Bitsch <bbitsch@ipfire.org> wrote: >> >> Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org> >> >> The locking is functioning. >> But the excerpt of /var/log/messages isn't displayed. >> >> Am 18.10.2021 um 21:09 schrieb Stefan Schantl: >>> When performing any action which requires pakfire, the page gets locked >>> with an message informing the user that pakfire is working. The page >>> will be reloaded when pakfire has been launched and is doing the >>> requested operation - showing the well known log output. This also >>> happens when pakfire has been launched via any kind of terminal or SSH >>> session and the CGI gets accessed. >>> Internally before pakfire gets started a variable called page_lock will >>> be set to lock the page. An while loop will keep the page locked until >>> pakfire is launched fully and has written it's lock_file. >>> This approach will prevent us from any kind of required time intervall >>> or race conditions. >>> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org> >>> --- >>> html/cgi-bin/pakfire.cgi | 49 ++++++++++++++++++++++++++++++++++++++-- >>> 1 file changed, 47 insertions(+), 2 deletions(-) >>> diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi >>> index 0cf522ba1..f2381f031 100644 >>> --- a/html/cgi-bin/pakfire.cgi >>> +++ b/html/cgi-bin/pakfire.cgi >>> @@ -44,6 +44,8 @@ $cgiparams{'VALID'} = ''; >>> $cgiparams{'INSPAKS'} = ''; >>> $cgiparams{'DELPAKS'} = ''; >>> +my $page_lock; >>> + >>> sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} >>> &Header::getcgihash(\%cgiparams); >>> @@ -57,8 +59,9 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont >>> if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) { >>> my @pkgs = split(/\|/, $cgiparams{'INSPAKS'}); >>> if ("$cgiparams{'FORCE'}" eq "on") { >>> + # Lock the page. >>> + $page_lock = "1"; >>> &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs); >>> - sleep(2); >>> } else { >>> &Header::openbox("100%", "center", $Lang::tr{'request'}); >>> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >>> @@ -95,8 +98,9 @@ END >>> } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) { >>> my @pkgs = split(/\|/, $cgiparams{'DELPAKS'}); >>> if ("$cgiparams{'FORCE'}" eq "on") { >>> + # Lock the page. >>> + $page_lock = "1"; >>> &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs); >>> - sleep(2); >>> } else { >>> &Header::openbox("100%", "center", $Lang::tr{'request'}); >>> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >>> @@ -132,8 +136,12 @@ END >>> } >>> } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) { >>> + # Set variable to lock the page. >>> + $page_lock = "1"; >>> &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); >>> } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) { >>> + # Lock the page. >>> + $page_lock = "1"; >>> &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors"); >>> } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") { >>> $pakfiresettings{"TREE"} = $cgiparams{"TREE"}; >>> @@ -169,6 +177,43 @@ if ($errormessage) { >>> &Header::closebox(); >>> } >>> +# Check if a page lock is required. >>> +if ($page_lock) { >>> + &Header::openbox('Waiting', 1, ,); >>> + print <<END; >>> + <table> >>> + <tr> >>> + <td> >>> + <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}'> >>> + </td> >>> + >>> + <td> >>> + $Lang::tr{'pakfire working'} >>> + </td> >>> + </tr> >>> + </table> >>> +END >>> + &Header::closebox(); >>> + >>> + # Infinite loop to lock the page until pakfire lockfile is present. >>> + while($page_lock) { >>> + unless (-e $Pakfire::lockfile) { >>> + sleep(1); >>> + } else { >>> + # Release page lock. >>> + undef($page_lock); >>> + >>> + # Break loop. >>> + last; >>> + } >>> + } >>> + >>> + # Perform page reload. >>> + print "<meta http-equiv='refresh' content='1;'>\n"; >>> + exit; >>> +} >>> + >>> +# Check if pakfire is already running. In this case a lockfile is present. >>> if (-e $Pakfire::lockfile) { >>> &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" ); >>> print <<END; >
Hi Michael, On 10/11/2021 09:56, Michael Tremer wrote: > Hello, > > I had a brief phone call with Stefan yesterday where he said that he was going to have a look at this again. > > In the meantime he said that the patch can be shipped because it does not break anything, although it doesn’t solve the problem it was meant to solve either. > > Can everybody confirm this? I believe I can confirm that. There was no window showing the log messages but the pointer had a spinning circle on it and when that had stopped spinning I had an updated system ready to reboot. After reboot it was fine. Regards, Adolf. > -Michael > >> On 5 Nov 2021, at 19:10, Jon Murphy <jcmurphy26@gmail.com> wrote: >> >> In Core Update 161 (testing): Same issue. I see the spin and Pakfire is working . . . but no messages. >> >> IPFire 2.27 (x86_64) - Core Update 161 Development Build: master/191347cc >> >> Jon >> >> >>> On Oct 21, 2021, at 5:17 AM, Bernhard Bitsch <bbitsch@ipfire.org> wrote: >>> >>> Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org> >>> >>> The locking is functioning. >>> But the excerpt of /var/log/messages isn't displayed. >>> >>> Am 18.10.2021 um 21:09 schrieb Stefan Schantl: >>>> When performing any action which requires pakfire, the page gets locked >>>> with an message informing the user that pakfire is working. The page >>>> will be reloaded when pakfire has been launched and is doing the >>>> requested operation - showing the well known log output. This also >>>> happens when pakfire has been launched via any kind of terminal or SSH >>>> session and the CGI gets accessed. >>>> Internally before pakfire gets started a variable called page_lock will >>>> be set to lock the page. An while loop will keep the page locked until >>>> pakfire is launched fully and has written it's lock_file. >>>> This approach will prevent us from any kind of required time intervall >>>> or race conditions. >>>> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org> >>>> --- >>>> html/cgi-bin/pakfire.cgi | 49 ++++++++++++++++++++++++++++++++++++++-- >>>> 1 file changed, 47 insertions(+), 2 deletions(-) >>>> diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi >>>> index 0cf522ba1..f2381f031 100644 >>>> --- a/html/cgi-bin/pakfire.cgi >>>> +++ b/html/cgi-bin/pakfire.cgi >>>> @@ -44,6 +44,8 @@ $cgiparams{'VALID'} = ''; >>>> $cgiparams{'INSPAKS'} = ''; >>>> $cgiparams{'DELPAKS'} = ''; >>>> +my $page_lock; >>>> + >>>> sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} >>>> &Header::getcgihash(\%cgiparams); >>>> @@ -57,8 +59,9 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont >>>> if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) { >>>> my @pkgs = split(/\|/, $cgiparams{'INSPAKS'}); >>>> if ("$cgiparams{'FORCE'}" eq "on") { >>>> + # Lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs); >>>> - sleep(2); >>>> } else { >>>> &Header::openbox("100%", "center", $Lang::tr{'request'}); >>>> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >>>> @@ -95,8 +98,9 @@ END >>>> } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) { >>>> my @pkgs = split(/\|/, $cgiparams{'DELPAKS'}); >>>> if ("$cgiparams{'FORCE'}" eq "on") { >>>> + # Lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs); >>>> - sleep(2); >>>> } else { >>>> &Header::openbox("100%", "center", $Lang::tr{'request'}); >>>> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >>>> @@ -132,8 +136,12 @@ END >>>> } >>>> } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) { >>>> + # Set variable to lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); >>>> } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) { >>>> + # Lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors"); >>>> } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") { >>>> $pakfiresettings{"TREE"} = $cgiparams{"TREE"}; >>>> @@ -169,6 +177,43 @@ if ($errormessage) { >>>> &Header::closebox(); >>>> } >>>> +# Check if a page lock is required. >>>> +if ($page_lock) { >>>> + &Header::openbox('Waiting', 1, ,); >>>> + print <<END; >>>> + <table> >>>> + <tr> >>>> + <td> >>>> + <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}'> >>>> + </td> >>>> + >>>> + <td> >>>> + $Lang::tr{'pakfire working'} >>>> + </td> >>>> + </tr> >>>> + </table> >>>> +END >>>> + &Header::closebox(); >>>> + >>>> + # Infinite loop to lock the page until pakfire lockfile is present. >>>> + while($page_lock) { >>>> + unless (-e $Pakfire::lockfile) { >>>> + sleep(1); >>>> + } else { >>>> + # Release page lock. >>>> + undef($page_lock); >>>> + >>>> + # Break loop. >>>> + last; >>>> + } >>>> + } >>>> + >>>> + # Perform page reload. >>>> + print "<meta http-equiv='refresh' content='1;'>\n"; >>>> + exit; >>>> +} >>>> + >>>> +# Check if pakfire is already running. In this case a lockfile is present. >>>> if (-e $Pakfire::lockfile) { >>>> &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" ); >>>> print <<END;
Hello, I can confirm this. Knowing about the issue allows to answer questions concerning it in the community. -Bernhard Am 10.11.2021 um 09:56 schrieb Michael Tremer: > Hello, > > I had a brief phone call with Stefan yesterday where he said that he was going to have a look at this again. > > In the meantime he said that the patch can be shipped because it does not break anything, although it doesn’t solve the problem it was meant to solve either. > > Can everybody confirm this? > > -Michael > >> On 5 Nov 2021, at 19:10, Jon Murphy <jcmurphy26@gmail.com> wrote: >> >> In Core Update 161 (testing): Same issue. I see the spin and Pakfire is working . . . but no messages. >> >> IPFire 2.27 (x86_64) - Core Update 161 Development Build: master/191347cc >> >> Jon >> >> >>> On Oct 21, 2021, at 5:17 AM, Bernhard Bitsch <bbitsch@ipfire.org> wrote: >>> >>> Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org> >>> >>> The locking is functioning. >>> But the excerpt of /var/log/messages isn't displayed. >>> >>> Am 18.10.2021 um 21:09 schrieb Stefan Schantl: >>>> When performing any action which requires pakfire, the page gets locked >>>> with an message informing the user that pakfire is working. The page >>>> will be reloaded when pakfire has been launched and is doing the >>>> requested operation - showing the well known log output. This also >>>> happens when pakfire has been launched via any kind of terminal or SSH >>>> session and the CGI gets accessed. >>>> Internally before pakfire gets started a variable called page_lock will >>>> be set to lock the page. An while loop will keep the page locked until >>>> pakfire is launched fully and has written it's lock_file. >>>> This approach will prevent us from any kind of required time intervall >>>> or race conditions. >>>> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org> >>>> --- >>>> html/cgi-bin/pakfire.cgi | 49 ++++++++++++++++++++++++++++++++++++++-- >>>> 1 file changed, 47 insertions(+), 2 deletions(-) >>>> diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi >>>> index 0cf522ba1..f2381f031 100644 >>>> --- a/html/cgi-bin/pakfire.cgi >>>> +++ b/html/cgi-bin/pakfire.cgi >>>> @@ -44,6 +44,8 @@ $cgiparams{'VALID'} = ''; >>>> $cgiparams{'INSPAKS'} = ''; >>>> $cgiparams{'DELPAKS'} = ''; >>>> +my $page_lock; >>>> + >>>> sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} >>>> &Header::getcgihash(\%cgiparams); >>>> @@ -57,8 +59,9 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont >>>> if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) { >>>> my @pkgs = split(/\|/, $cgiparams{'INSPAKS'}); >>>> if ("$cgiparams{'FORCE'}" eq "on") { >>>> + # Lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs); >>>> - sleep(2); >>>> } else { >>>> &Header::openbox("100%", "center", $Lang::tr{'request'}); >>>> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >>>> @@ -95,8 +98,9 @@ END >>>> } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) { >>>> my @pkgs = split(/\|/, $cgiparams{'DELPAKS'}); >>>> if ("$cgiparams{'FORCE'}" eq "on") { >>>> + # Lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs); >>>> - sleep(2); >>>> } else { >>>> &Header::openbox("100%", "center", $Lang::tr{'request'}); >>>> my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); >>>> @@ -132,8 +136,12 @@ END >>>> } >>>> } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) { >>>> + # Set variable to lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); >>>> } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) { >>>> + # Lock the page. >>>> + $page_lock = "1"; >>>> &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors"); >>>> } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") { >>>> $pakfiresettings{"TREE"} = $cgiparams{"TREE"}; >>>> @@ -169,6 +177,43 @@ if ($errormessage) { >>>> &Header::closebox(); >>>> } >>>> +# Check if a page lock is required. >>>> +if ($page_lock) { >>>> + &Header::openbox('Waiting', 1, ,); >>>> + print <<END; >>>> + <table> >>>> + <tr> >>>> + <td> >>>> + <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}'> >>>> + </td> >>>> + >>>> + <td> >>>> + $Lang::tr{'pakfire working'} >>>> + </td> >>>> + </tr> >>>> + </table> >>>> +END >>>> + &Header::closebox(); >>>> + >>>> + # Infinite loop to lock the page until pakfire lockfile is present. >>>> + while($page_lock) { >>>> + unless (-e $Pakfire::lockfile) { >>>> + sleep(1); >>>> + } else { >>>> + # Release page lock. >>>> + undef($page_lock); >>>> + >>>> + # Break loop. >>>> + last; >>>> + } >>>> + } >>>> + >>>> + # Perform page reload. >>>> + print "<meta http-equiv='refresh' content='1;'>\n"; >>>> + exit; >>>> +} >>>> + >>>> +# Check if pakfire is already running. In this case a lockfile is present. >>>> if (-e $Pakfire::lockfile) { >>>> &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" ); >>>> print <<END; >> >
diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index 0cf522ba1..f2381f031 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -44,6 +44,8 @@ $cgiparams{'VALID'} = ''; $cgiparams{'INSPAKS'} = ''; $cgiparams{'DELPAKS'} = ''; +my $page_lock; + sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} &Header::getcgihash(\%cgiparams); @@ -57,8 +59,9 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) { my @pkgs = split(/\|/, $cgiparams{'INSPAKS'}); if ("$cgiparams{'FORCE'}" eq "on") { + # Lock the page. + $page_lock = "1"; &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs); - sleep(2); } else { &Header::openbox("100%", "center", $Lang::tr{'request'}); my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); @@ -95,8 +98,9 @@ END } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) { my @pkgs = split(/\|/, $cgiparams{'DELPAKS'}); if ("$cgiparams{'FORCE'}" eq "on") { + # Lock the page. + $page_lock = "1"; &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs); - sleep(2); } else { &Header::openbox("100%", "center", $Lang::tr{'request'}); my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs); @@ -132,8 +136,12 @@ END } } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) { + # Set variable to lock the page. + $page_lock = "1"; &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) { + # Lock the page. + $page_lock = "1"; &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors"); } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") { $pakfiresettings{"TREE"} = $cgiparams{"TREE"}; @@ -169,6 +177,43 @@ if ($errormessage) { &Header::closebox(); } +# Check if a page lock is required. +if ($page_lock) { + &Header::openbox('Waiting', 1, ,); + print <<END; + <table> + <tr> + <td> + <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}'> + </td> + + <td> + $Lang::tr{'pakfire working'} + </td> + </tr> + </table> +END + &Header::closebox(); + + # Infinite loop to lock the page until pakfire lockfile is present. + while($page_lock) { + unless (-e $Pakfire::lockfile) { + sleep(1); + } else { + # Release page lock. + undef($page_lock); + + # Break loop. + last; + } + } + + # Perform page reload. + print "<meta http-equiv='refresh' content='1;'>\n"; + exit; +} + +# Check if pakfire is already running. In this case a lockfile is present. if (-e $Pakfire::lockfile) { &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" ); print <<END;