Perl Fast CGI: Do you ever get out of the loop?

Consider the standard Perl fast CGI script:

#!/usr/bin/perl

use CGI::Fast;

# Init handler

while (my $cgi = CGI::Fast->new) 
{
# Handle request
}

# Do you ever get here?

Do I ever get out of the loop and get the opportunity to do some cleanup?

What happens when the server throws test.fpl script because the limit is exceeded?

+4
source share
1 answer

Usually, but it's possible.

CGI::Fast::new:

sub new {
    my ($self, $initializer, @param) = @_;

    if ( ! defined $initializer ) {
        $Ext_Request ||= _create_fcgi_request( $in_fh,$out_fh,$err_fh );
        return undef unless $Ext_Request->Accept >= 0;
    }
    CGI->_reset_globals;
    $self->_setup_symbols(@CGI::SAVED_SYMBOLS) if @CGI::SAVED_SYMBOLS;
    return $CGI::Q = $self->SUPER::new($initializer, @param);
}

As you can see, it can return false if $Ext_Request->Accept(where $Ext_Requestis the FGCI :: Request object) returns a negative number.

Drilling brings us to one of two C functions, called OS_Acceptone for unix and one for Windows. They are mainly wrappers for a system call accept.

accept , ( ). .

+3

Source: https://habr.com/ru/post/1686589/


All Articles