-
Notifications
You must be signed in to change notification settings - Fork 310
Description
Describe the bug
I'm pasting here what @julsemaan described regarding that issue:
The code we have that sets an alarm:
packetfence/html/captive-portal/lib/captiveportal.pm
Lines 52 to 73 in dcad596
around 'handle_request' => sub { my ($orig, $self, @args) = @_; my @res; # Request timeout handling eval { local $SIG{ALRM} = sub { my ($pkg, $file, $line) = caller(0); (undef, undef, undef, my $func) = caller(2); die "Timeout reached at package:$pkg, file:$file, line:$line func:$func"; }; alarm $Config{captive_portal}{request_timeout}; eval { @res = $self->$orig(@args); }; alarm 0; die $@ if($@); }; alarm 0; die $@ if($@); return @res; };
This line is problematic: https://github.com/inverse-inc/packetfence/blob/devel/conf/httpd.conf.d/httpd.portal.tt.example#L111
After 5 seconds, the request can timeout in Apache mod_perl but the alarm is still setup in Catalyst. 10 seconds after, the alarm is fired in Catalyst but the code to catch it isn't active anymore (killed after the 5 seconds) and the alarm bubbles up to the parent processWe need to make the Apache timeout a value of captive_portal.request_timeout + 5 seconds so that the Catalyst code always has a chance to run before Apache kills the process
Additional context
This is what I see in httpd.portal-error when this issue occured:
Jun 20 16:32:54 packetfence httpd_portal_err: [Mon Jun 20 16:32:54.446558 2022] [perl:error] [pid 22162] [client 127.0.0.1:55382] Apache2::RequestIO::read: (70007) The timeout specified has expired at (eval 4288) line 5
Jun 20 16:32:54 packetfence httpd_portal_err: [Mon Jun 20 16:32:54.509008 2022] [perl:error] [pid 21225] [client 127.0.0.1:55384] Apache2::RequestIO::read: (70007) The timeout specified has expired at (eval 4678) line 5
Jun 20 16:32:54 packetfence httpd_portal_err: [Mon Jun 20 16:32:54.612337 2022] [perl:error] [pid 21759] [client 127.0.0.1:55386] Apache2::RequestIO::read: (70007) The timeout specified has expired at (eval 5046) line 5
[..]
Jun 20 16:33:05 packetfence httpd_portal_err: [Mon Jun 20 16:33:05.375322 2022] [core:notice] [pid 10615] AH00052: child pid 22162 exit signal Alarm clock (14)
Results: httpd.portal is not working anymore and need to be restarted.