/usr/share/doc/libfcgi-perl/examples/threaded.pl is in libfcgi-perl 0.78-2build1.
This file is owned by root:root, with mode 0o755.
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 | #!/usr/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;
use FCGI qw[];
use IO::Handle qw[];
use constant THREAD_COUNT => 5;
my @count : shared = (0, (0) x THREAD_COUNT);
sub worker {
my $k = shift;
my %env;
my $in = IO::Handle->new;
my $out = IO::Handle->new;
my $err = IO::Handle->new;
my $request = FCGI::Request($in, $out, $err, \%env);
while ($request->Accept >= 0) {
print $out
"Content-type: text/html\r\n",
"\r\n",
"<title>FastCGI Hello! (multi-threaded perl, fcgiapp library)</title>",
"<h1>FastCGI Hello! (multi-threaded perl, fcgiapp library)</h1>",
"Request counts for ", THREAD_COUNT ," threads ",
"running on host <i>$env{SERVER_NAME}</i>";
{
lock(@count);
++$count[$k];
for(my $i = 1; $i <= THREAD_COUNT; $i++) {
print $out $count[$i];
print $out " ";
}
}
$request->Flush;
sleep(1);
}
}
$_->join for map { threads->create(\&worker, $_) } 1..THREAD_COUNT;
|