App-cdnget
view release on metacpan or search on metacpan
"GD" : "2.56",
"JavaScript::Minifier::XS" : "0.11",
"LWP::UserAgent" : "6.15",
"Lazy::Utils" : "1.08",
"Object::Base" : "1.11",
"SUPER" : "1.16",
"Thread::Semaphore" : "2.13",
"Time::HiRes" : "1.9740",
"forks" : "0.29",
"perl" : "5.014",
"threads" : "1.72",
"threads::shared" : "1.28"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"mailto" : "bug-App-cdnget@rt.cpan.org",
"web" : "https://github.com/orkunkaraduman/p5-cdnget/issues"
},
"homepage" : "https://metacpan.org/release/App-cdnget",
GD: '2.56'
JavaScript::Minifier::XS: '0.11'
LWP::UserAgent: '6.15'
Lazy::Utils: '1.08'
Object::Base: '1.11'
SUPER: '1.16'
Thread::Semaphore: '2.13'
Time::HiRes: '1.9740'
forks: '0.29'
perl: '5.014'
threads: '1.72'
threads::shared: '1.28'
resources:
bugtracker: https://github.com/orkunkaraduman/p5-cdnget/issues
homepage: https://metacpan.org/release/App-cdnget
license: https://www.gnu.org/licenses/gpl-3.0.html
repository: git://git@github.com:orkunkaraduman/p5-cdnget.git
version: '0.06'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Makefile.PL view on Meta::CPAN
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'App::cdnget',
VERSION_FROM => 'lib/App/cdnget.pm',
MIN_PERL_VERSION => '5.014',
PREREQ_PM => {
'threads' => '1.72',
'threads::shared' => '1.28',
'forks' => '0.29',
'SUPER' => '1.16',
'Thread::Semaphore' => '2.13',
'Time::HiRes' => '1.9740',
'DateTime' => '1.42',
'FCGI' => '0.78',
'Digest::MD5' => '2.55',
'LWP::UserAgent' => '6.15',
'GD' => '2.56',
'CSS::Minifier::XS' => '0.09',
make test
make install
from CPAN
cpan -i App::cdnget
DEPENDENCIES
This module requires these other modules and libraries:
* threads
* threads::shared
* forks
* SUPER
* Thread::Semaphore
* Time::HiRes
* DateTime
make install
from CPAN
cpan -i App::cdnget
# DEPENDENCIES
This module requires these other modules and libraries:
- threads
- threads::shared
- forks
- SUPER
- Thread::Semaphore
- Time::HiRes
- DateTime
- FCGI
- Digest::SHA
- LWP::UserAgent
- GD
- Lazy::Utils
lib/App/cdnget.pm view on Meta::CPAN
p5-cdnget is a FastCGI application that flexible pull-mode Content Delivery Network reverse proxy.
B<This is ALPHA version>
=cut
### TODO: css, js minifier.
BEGIN
{
require Config;
if ($Config::Config{'useithreads'})
{
require threads;
threads->import();
require threads::shared;
threads::shared->import();
} else
{
require forks;
forks->import();
require forks::shared;
forks::shared->import();
}
}
use strict;
use warnings;
lib/App/cdnget.pm view on Meta::CPAN
cpan -i App::cdnget
=head1 DEPENDENCIES
This module requires these other modules and libraries:
=over
=item *
threads
=item *
threads::shared
=item *
forks
=item *
SUPER
=item *
lib/App/cdnget/Downloader.pm view on Meta::CPAN
lock(%uids);
return if exists($uids{$uid});
my $self = $class->SUPER();
$self->uid = $uid;
$self->path = $path;
$self->url = $url;
$self->hook = $hook;
$self->tid = undef;
{
lock($self);
my $thr = threads->create(\&run, $self) or $self->throw($!);
cond_wait($self);
unless (defined($self->tid))
{
App::cdnget::Exception->throw($thr->join());
}
$thr->detach();
}
$uids{$uid} = $self;
return $self;
}
lib/App/cdnget/Downloader.pm view on Meta::CPAN
{
$self->throw("Unsupported hook");
}
}
return;
}
sub run
{
my $self = shift;
my $tid = threads->tid();
my $fh;
eval
{
$fh = FileHandle->new($self->path, ">") or $self->throw($!);
};
if ($@)
{
lock($self);
cond_signal($self);
lib/App/cdnget/Worker.pm view on Meta::CPAN
{
$spareSemaphore->up();
$workerSemaphore->up();
return;
}
my $self = $class->SUPER();
$self->tid = undef;
do
{
lock($self);
my $thr = threads->create(\&run, $self) or $self->throw($!);
cond_wait($self);
unless (defined($self->tid))
{
App::cdnget::Exception->throw($thr->join());
}
$thr->detach();
};
return $self;
}
lib/App/cdnget/Worker.pm view on Meta::CPAN
$fh->binmode(":bytes") or $self->throw($!);
do
{
local ($/, $\) = ("\r\n")x2;
my $line;
my $buf;
my $empty = 1;
while (not $self->terminating)
{
threads->yield();
my $downloaderTerminated = ! $downloader || $downloader->terminated;
$line = $fh->getline;
unless (defined($line))
{
$self->throw($!) if $fh->error;
return if $downloaderTerminated;
my $pos = $fh->tell;
usleep(1*1000);
$fh->seek($pos, 0) or $self->throw($!);
next;
lib/App/cdnget/Worker.pm view on Meta::CPAN
{
not $! or $!{EPIPE} or $!{ECONNRESET} or $!{EPROTOTYPE} or $self->throw($!);
return;
}
$empty = 0;
}
last unless $line;
}
while (not $self->terminating)
{
threads->yield();
my $downloaderTerminated = ! $downloader || $downloader->terminated;
my $len = $fh->read($buf, $App::cdnget::CHUNK_SIZE);
$self->throw($!) unless defined($len);
if ($len == 0)
{
return if $downloaderTerminated;
my $pos = $fh->tell;
usleep(1*1000);
$fh->seek($pos, 0) or $self->throw($!);
next;
lib/App/cdnget/Worker.pm view on Meta::CPAN
return;
}
}
};
return;
}
sub run
{
my $self = shift;
my $tid = threads->tid();
$self->tid = $tid;
do
{
lock($self);
cond_signal($self);
};
my $spare = 1;
my $accepting = 0;
lib/App/cdnget/Worker.pm view on Meta::CPAN
lock($accepterCount);
last wait_accept unless $accepterCount >= $spareCount;
};
}
$spareSemaphore->up();
$spare = 0;
accepter_loop:
while (not $self->terminating)
{
threads->yield();
$workerSemaphore->up();
$accepting = 1;
my $accept;
do
{
lock($accepterCount);
$accepterCount++;
};
eval { $accept = $req->Accept() };
do
( run in 0.914 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )