This file is indexed.

/usr/share/perl5/AnyEvent/FCGI.pm is in libanyevent-fcgi-perl 0.04-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package AnyEvent::FCGI;

=head1 NAME

AnyEvent::FCGI - non-blocking FastCGI server

=head1 SYNOPSIS

    use AnyEvent;
    use AnyEvent::FCGI;

    my $fcgi = new AnyEvent::FCGI(
        port => 9000,
        on_request => sub {
            my $request = shift;
            $request->respond(
                'OH HAI! QUERY_STRING is ' . $request->param('QUERY_STRING'),
                'Content-Type' => 'text/plain',
            );
        }
    );

    my $timer = AnyEvent->timer(
        after => 10,
        interval => 0,
        cb => sub {
            # shut down server after 10 seconds
            $fcgi = undef;
        }
    );

    AnyEvent->loop;

=head1 DESCRIPTION

This module implements non-blocking FastCGI server for event based applications.

=cut

use strict;
use warnings;

our $VERSION = '0.04';

use Scalar::Util qw/weaken refaddr/;

use AnyEvent;
use AnyEvent::Socket;
use AnyEvent::Handle;
use AnyEvent::FCGI::Connection;

use constant FCGI_VERSION_1 => 1;

use constant FCGI_BEGIN_REQUEST => 1;
use constant FCGI_ABORT_REQUEST => 2;
use constant FCGI_END_REQUEST => 3;
use constant FCGI_PARAMS => 4;
use constant FCGI_STDIN => 5;
use constant FCGI_STDOUT => 6;
use constant FCGI_STDERR => 7;

use constant FCGI_RESPONDER => 1;

use constant FCGI_KEEP_CONN => 1;

use constant FCGI_REQUEST_COMPLETE => 0;
use constant FCGI_OVERLOADED => 2;
use constant FCGI_UNKNOWN_ROLE => 3;

=head1 METHODS

=head2 new

This function creates a new FastCGI server and returns a new instance of a C<AnyEvent::FCGI> object.
To shut down the server just remove all references to this object.

=head3 PARAMETERS

=over 4

=item port => $port

The TCP port the FastCGI server will listen on.

=item host => $host

The TCP address of the FastCGI server will listen on.
If undefined 0.0.0.0 will be used.

=item socket => $path

Path to UNIX domain socket to listen. If specified, C<host> and C<port> parameters ignored.

=item on_request => sub { }

Reference to a handler to call when a new FastCGI request is received.
It will be invoked as

    $on_request->($request)

where C<$request> will be a new L<AnyEvent::FCGI::Request> object.

=item backlog => $backlog

Optional. Integer number of socket backlog (listen queue)

=back

=cut

sub new {
    my ($class, %params) = @_;

    my $self = bless {
        connections => {},
        on_request_cb => $params{on_request},
    }, $class;

    my $fcgi = $self;
    weaken($fcgi);

    $params{socket} ||= $params{unix};

    $self->{server} = tcp_server(
        $params{socket} ? 'unix/' : $params{host},
        $params{socket} || $params{port},
        sub {$fcgi->_on_accept(shift)},
        $params{backlog} ? sub {$params{backlog}} : undef
    );

    return $self;
}

sub _on_accept {
    my ($self, $fh) = @_;

    if ($fh) {
        my $connection = new AnyEvent::FCGI::Connection(fcgi => $self, fh => $fh);

        $self->{connections}->{refaddr($connection)} = $connection;
    }
}

sub _request_ready {
    my ($self, $request) = @_;

    $self->{on_request_cb}->($request);
}

sub DESTROY {
    my ($self) = @_;

    if ($self) {
        $self->{connections} = {};
    }
}

=head1 SEE ALSO

L<AnyEvent>, L<AnyEvent::FCGI::Request>

This module based on L<FCGI::Async> and L<FCGI::EV>.

=head1 LICENSE

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.

=head1 AUTHOR

Vitaly Kramskikh, E<lt>vkramskih@cpan.orgE<gt>

=cut

1;