Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37767990
en ru br
ALT Linux repositórios
S:2.0.11-alt3
5.0: 2.0.4-alt1
4.1: 2.0.3-alt5
4.0: 2.0.3-alt5

Group :: Sistema/Servidores
RPM: apache2-mod_perl

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Apache-Reload/000075500000000000000000000000001222434245500134445ustar00rootroot00000000000000Apache-Reload/Changes000064400000000000000000000024601222434245500147410ustar00rootroot00000000000000=head1 NAME

Changes - Apache::Reload change logfile

=head1 CHANGES

=over 1

=item 0.12 March 31, 2012

Set the -apxs argument correctly when building from mod_perl.
[Steve Hay]

Doc spelling fix
[Nicholas Bamber]

Add Apache-Test 1.34 dependency.
[Phred]

=item 0.11 August 21, 2010

Ignore require-hooks which exist in %INC
[Ryan Gies <ryan@livesite.net>]

Reloads by file, not module name
[Ryan Gies <ryan@livesite.net>]

Add a no Apache::Reload directive which skips reloading for modules
that have it included (useful for Moose compatibility).
[Graham Barr, <gbarr@pobox.com>]

Add Empty NOTICE file
http://rt.cpan.org/Ticket/Display.html?id=34786
[Niko Tyni (Debian Perl Group) <ntyni@debian.org>]

=item 0.10 February 25, 2008

Add make disttest procedure to RELEASE document - fred

Check for Apache::Test version 1.30, needed to run tests - fred

Apache::Reload and Apache2::Reload bundled for CPAN release
This release incorporates unreleased changes in 0.08 and 0.09
[Fred Moyer <fred@redhotpenguin.com>]

=item 0.09

Apache2::Reload was part of mod_perl2 core in this version

=item 0.08

Remove modified modules before reloading them
[Javier Ureuen Val]

Imported from v0.07 into ASF SVN
[Philip M. Gollucci <pgollucci@p6m7g8.com>]

Matt Sergeant <matt@sergeant.org> has donated Apache-Reload
to the ASF.

=back

Apache-Reload/LICENSE000064400000000000000000000261361222434245500144610ustar00rootroot00000000000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache-Reload/MANIFEST000064400000000000000000000003031222434245500145710ustar00rootroot00000000000000MANIFEST
Makefile.PL
README
LICENSE
lib/Apache/Reload.pm
lib/Apache2/Reload.pm
t/conf/extra.last.conf.in
t/all.t
t/reload.t
t/lib/Apache/TestReload.pm
t/lib/Apache2/TestReload.pm
RELEASE
Changes
Apache-Reload/Makefile.PL000064400000000000000000000153471222434245500154300ustar00rootroot00000000000000use strict;

use Config;

my %prereqs = ();
my %mp2 = ( mod_perl2 => 1.99022 );
my %mp1 = ( mod_perl => 0 );
my $at_min_ver = 1.34;

my $mp_gen;
# MOD_PERL_2_BUILD is set from building from mod_perl Makefile.PL which should
# also set MP_APXS
if ($ENV{MOD_PERL_2_BUILD}) {
push @ARGV, "-apxs", $ENV{MP_APXS};
my $mp_gen = satisfy_mp_generation(2);
}
else {
$mp_gen = satisfy_mp_generation();
}

%prereqs = ($mp_gen == 1 ? %mp1 : %mp2);

my $HAS_APACHE_TEST = check_for_apache_test();

my %common_opts = (
PREREQ_PM => \%prereqs,
clean => { FILES => 't/TEST' },
);

if ($mp_gen == 1) {
require ExtUtils::MakeMaker;
ExtUtils::MakeMaker::WriteMakefile(
%common_opts,
VERSION_FROM => "lib/Apache/Reload.pm",
NAME => "Apache::Reload",
ABSTRACT_FROM => 'lib/Apache/Reload.pm',
);

}
else {
require ModPerl::MM;
ModPerl::MM::WriteMakefile(
%common_opts,
VERSION_FROM => "lib/Apache2/Reload.pm",
NAME => "Apache2::Reload",
ABSTRACT_FROM => 'lib/Apache2/Reload.pm',
);
}

sub check_for_apache_test {
return unless eval {
require Apache::Test;
if ($Apache::Test::VERSION < $at_min_ver) {
die "Apache::Test version is " . $Apache::Test::VERSION .
", minimum version required is $at_min_ver" .
", tests will be skipped\n";
}
require Apache::TestMM;
require Apache::TestRunPerl;
1;
};

Apache::TestMM::filter_args();

my %args = @Apache::TestMM::Argv;

Apache::TestRunPerl->generate_script();

return 1;
}

# If a specific generation was passed as an argument,
# if satisfied
# return the same generation
# else
# die
# else @ARGV and %ENV will be checked for specific orders
# if the specification will be found
# if satisfied
# return the specified generation
# else
# die
# else if any mp generation is found
# return it
# else
# die

sub satisfy_mp_generation {
my $wanted = shift || wanted_mp_generation();

unless ($wanted == 1 || $wanted == 2) {
die "don't know anything about mod_perl generation: $wanted\n" .
"currently supporting only generations 1 and 2";
}

my $selected = 0;

if ($wanted == 1) {
require_mod_perl();
if ($mod_perl::VERSION >= 1.99) {
# so we don't pick 2.0 version if 1.0 is wanted
die "You don't seem to have mod_perl 1.0 installed";
}
$selected = 1;
}
elsif ($wanted == 2) {
#warn "Looking for mod_perl 2.0";
require_mod_perl();
if ($mod_perl::VERSION < 2.0) {
die "You don't seem to have mod_perl 2.0 installed";
}
$selected = 2;
}
else {
require_mod_perl();
$selected = $mod_perl::VERSION >= 1.99 ? 2 : 1;
warn "Using $mod_perl::VERSION\n";
}

return $selected;
}

sub require_mod_perl {
eval { require mod_perl };
eval { require mod_perl2 } if ($@);
die "Can't find mod_perl installed\nThe error was: $@" if $@;
}

# the function looks at %ENV and Makefile.PL option to figure out
# whether a specific mod_perl generation was requested.
# It uses the following logic:
# via options:
# perl Makefile.PL MOD_PERL=2
# or via %ENV:
# env MOD_PERL=1 perl Makefile.PL
#
# return value is:
# 1 or 2 if the specification was found (mp 1 and mp 2 respectively)
# 0 otherwise
sub wanted_mp_generation {

# check if we have a command line specification
# flag: 0: unknown, 1: mp1, 2: mp2
my $flag = 0;
foreach my $key (@ARGV) {
if ($key =~ /^MOD_PERL=(\d)$/) {
$flag = $1;
}
}

# check %ENV
my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0;

# check for contradicting requirements
if ($env && $flag && $flag != $env) {
die <<EOF;
Can\'t decide which mod_perl version should be used, since you have
supplied contradicting requirements:
enviroment variable MOD_PERL=$env
Makefile.PL option MOD_PERL=$flag
EOF
}

my $wanted = 0;
$wanted = 2 if $env == 2 || $flag == 2;
$wanted = 1 if $env == 1 || $flag == 1;

unless ($wanted) {
# if still unknown try to require mod_perl.pm
eval { require mod_perl };
if ($@) {
# if we don't have mp1, check for mp2
# see if we are in the mp2 build structure
eval { require File::Spec };
unless ($@) {
my $mplib = File::Spec->catdir('..', 'lib');
unshift @INC, $mplib if -e File::Spec->catfile($mplib,'mod_perl2.pm');
my $atlib = File::Spec->catdir('../', 'Apache-Test', 'lib');
unshift @INC, $atlib if -d $atlib;
}

eval { require mod_perl2 } if ($@);
unless ($@) {
$wanted = 2;
}
}
else {
$wanted = 1;
}
}

return $wanted;
}

package MY;

sub postamble {
my $self = shift;

my $string = $self->SUPER::postamble;

$string .= <<'EOF';
tag :
svn copy https://svn.apache.org/repos/asf/perl/Apache-Reload/trunk https://svn.apache.org/repos/asf/perl/Apache-Reload/tags/$(VERSION_SYM)
@echo update lib/Apache/Reload.pm VERSION now
EOF

return $string;
}

sub test {
my $self = shift;

eval { require Test::More } or return <<EOF;
test::
\t\@echo sorry, cannot run tests without Test::More
EOF

return $self->Apache::TestMM::test(@_) if $HAS_APACHE_TEST;

return <<EOF
test::
\t\@echo
\t\@echo sorry, cannot run tests without a properly
\t\@echo configured Apache-Test environment, mininum
\t\@echo Apache::Test version needed is $at_min_ver
\t\@echo
EOF
}

sub clean {
my $self = shift;

return $self->Apache::TestMM::clean(@_) if $HAS_APACHE_TEST;

return $self->SUPER::clean(@_);
}

sub constants {
my $self = shift;

my $string = $self->MM::constants;

# mp2 installs this into INSTALLSITEARCH, so in order to avoid
# problems when users forget 'make install UNINST=1', trick MM into
# installing pure perl modules to the sitearch location, when this is
# not installed as a part of mp2 build
if (!$ENV{MOD_PERL_2_BUILD}) {
$string .= <<'EOI';

# install into the same location as mod_perl 2.0
INSTALLSITELIB = $(INSTALLSITEARCH)
DESTINSTALLSITELIB = $(DESTINSTALLSITEARCH)
EOI
}

$string;
}
Apache-Reload/NOTICE000064400000000000000000000000001222434245500143360ustar00rootroot00000000000000Apache-Reload/README000064400000000000000000000062701222434245500143310ustar00rootroot00000000000000NAME
Apache::Reload - Reload changed modules

SYNOPSIS
In httpd.conf:

PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off

Then your module:

package My::Apache::Module;

use Apache::Reload;

sub handler { ... }

1;

DESCRIPTION
This module is two things. First it is an adaptation of Randal
Schwartz's Stonehenge::Reload module that attempts to be a
little more intuitive and makes the usage easier.
Stonehenge::Reload was written by Randal to make specific
modules reload themselves when they changed. Unlike
Apache::StatINC, Stonehenge::Reload only checked the change time
of modules that registered themselves with Stonehenge::Reload,
thus reducing stat() calls. Apache::Reload also offers the exact
same functionality as Apache::StatINC, and is thus designed to
be a drop-in replacement. Apache::Reload only checks modules
that register themselves with Apache::Reload if you explicitly
turn off the StatINC emulation method (see below). Like
Apache::StatINC, Apache::Reload must be installed as an Init
Handler.

StatINC Replacement

To use as a StatINC replacement, simply add the following
configuration to your httpd.conf:

PerlInitHandler Apache::Reload

Register Modules Implicitly

To only reload modules that have registered with Apache::Reload,
add the following to the httpd.conf:

PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off
# ReloadAll defaults to On

Then any modules with the line:

use Apache::Reload;

Will be reloaded when they change.

Register Modules Explicitly

You can also register modules explicitly in your httpd.conf file
that you want to be reloaded on change:

PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off
PerlSetVar ReloadModules "My::Foo My::Bar Foo::Bar::Test"

Note that these are split on whitespace, but the module list
must be in quotes, otherwise Apache tries to parse the parameter
list.

Special "Touch" File

You can also set a file that you can touch() that causes the
reloads to be performed. If you set this, and don't touch() the
file, the reloads don't happen. This can be a great boon in a
live environment:

PerlSetVar ReloadTouchFile /tmp/reload_modules

Now when you're happy with your changes, simply go to the
command line and type:

touch /tmp/reload_modules

And your modules will be magically reloaded on the next request.
This option works in both StatINC emulation mode and the
registered modules mode.

PSUEDOHASHES
The short summary of this is: Don't use psuedohashes. Use an
array with constant indexes. Its faster in the general case, its
more guaranteed, and generally, it works.

The long summary is that I've done some work to get this working
with modules that use psuedo hashes, but its still broken in the
case of a single module that contains multiple packages that all
use psuedohashes.

So don't do that.

AUTHOR
Matt Sergeant, matt@sergeant.org

MAINTAINERS

the mod_perl developers, dev@perl.apache.org

SEE ALSO
Apache::StatINC, Stonehenge::Reload

Apache-Reload/RELEASE000064400000000000000000000070611222434245500144530ustar00rootroot00000000000000Instructions for Apache-Reload Release Manager

0. Ask the PMC to verify that you have the appropriate CPAN permissions
on dev@perl.

make sure your public key is in the KEYS file in the mod_perl docs.
you should only need to do this if this is your first time playing
Release Manager

$ cd mod_perl-docs
$ grep $USER src/dist/KEYS

note that the KEYS file itself contains all the instructions you
need on how to add your key. if you need further help on gpg
(like how to create a key in the first place) you can look here

http://people.apache.org/~geoff/gpghowto.html

Copy the KEYS file into place:
% scp KEYS www.apache.org:/www/www.apache.org/dist/perl/KEYS

If this is your first release, ask someone with APML karma on PAUSE
to verify you have the appropriate permissions. Likely someone on
the PMC can do this.

a. login into https://pause.perl.org
b. menu click: Select Mailinglist/Action
c. choose APML and share_perms and click go
d. click 3.3 Make somebody else co-maintainer
e. choose the modules to give the perms to
type the username of the new co-maintainer
f. if you happen to know that packages were added this release,
make sure you give the correct permissions to them.

MAINTAINER_BUILDING_RELEASE=1 perl Makefile.PL

1. 'make disttest' - to make sure nothing is missing from the manifest.
Now 'make dist', and test this generated package (not svn)
with as many configurations as possible on as many platforms
as possible.

a. edit ./Changes:
- find lib -type f -name "*.pm" | \
xargs perl -pi -e 's,0.12-dev,0.12-rc1,g'
- perl -pi -e 's,0.12-dev,0.12-rc1,g' Changes

- don't commit these (see dev@ archives)

b. nuke any preinstalled Apache-Reload libs and run 'make test'

c. test that you can 'make install' and then run 'make test' again

d. test whether we still 100% OK on systems with no LWP:

% APACHE_TEST_PRETEND_NO_LWP=1 make test

2. once confident that the package is good, upload a release candidate
to people.apache.org/~username and post 24 hour-ish candidate alert
to the various lists

o dev/perl.apache.org
o modperl/perl.apache.org

Subject: [RELEASE CANDIDATE] Apache-Reload 0.12 RC\d+

(or maybe longer to give most people a chance to catch up). no need
to tag this package

a. if problems are detected during stage 2, repeat stages 1 and 2.

3. when the package has been reported to be good, prepare a new
package to be released

a. edit ./Changes
- remove -rc\d+ (from lib/Apache/Reload.pm and lib/Apache2/Reload.pm also)
- add release date

b. rerun:
% perl Makefile.PL
make sure tag looks right
% make -n tag

c. commit Changes
% svn ci Changes

d. tag
% make tag

e. create the final package
% make dist

f. test the final package again at least once

4. Upload the package to CPAN

5. Announce the package

a. post ... to the modperl, announce lists
Subject: [ANNOUNCE] Apache-Reload 0.12
include
- MD5 sig (as it comes from CPAN upload announce).
- the latest Changes

6. Prepare for the next cycle

a. increment version in lib/Apache/Reload.pm

b. edit ./Changes:
- start a new item with incremented version + '-dev'

=item 0.13-dev

c. bump up version numbers in this file to make it easier to do the
next release.

$ perl -pi -e 's/(\d+)\.(\d+)/join(".", $1, $2+1)/eg' RELEASE

d. commit Changes
% svn ci -m "start 0.12-dev cycle" Changes RELEASE \
lib/Apache/Reload.pm lib/Apache2/Reload.pm
Apache-Reload/lib/000075500000000000000000000000001222434245500142125ustar00rootroot00000000000000Apache-Reload/lib/Apache/000075500000000000000000000000001222434245500153735ustar00rootroot00000000000000Apache-Reload/lib/Apache/Reload.pm000064400000000000000000000204151222434245500171410ustar00rootroot00000000000000# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package Apache::Reload;

use strict;

$Apache::Reload::VERSION = '0.12';

use vars qw(%INCS %Stat $TouchTime %UndefFields %Ignore);

%Stat = ($INC{"Apache/Reload.pm"} => time);

$TouchTime = time;

sub import {
my $class = shift;
my ($package,$file) = (caller)[0,1];

$class->register_module($package, $file);
}

sub unimport {
my $class = shift;
my ($package,$file) = (caller)[0,1];

$class->unregister_module($package, $file);
}

sub package_to_module {
my $package = shift;
$package =~ s/::/\//g;
$package .= ".pm";
return $package;
}

sub register_module {
my ($class, $package, $file) = @_;
my $module = package_to_module($package);

if ($file) {
$INCS{$module} = $file;
}
else {
$file = $INC{$module};
return unless $file;
$INCS{$module} = $file;
}

no strict 'refs';
if (%{"${package}::FIELDS"}) {
$UndefFields{$module} = "${package}::FIELDS";
}
}

sub unregister_module {
my ($class, $package, $file) = @_;
my $module = package_to_module($package);

$Ignore{$module} = 1;
}

sub handler {
my $r = shift;

my $DEBUG = ref($r) && (lc($r->dir_config("ReloadDebug") || '') eq 'on');

my $TouchFile = ref($r) && $r->dir_config("ReloadTouchFile");

my $TouchModules;

if ($TouchFile) {
warn "Checking mtime of $TouchFile\n" if $DEBUG;
my $touch_mtime = (stat($TouchFile))[9] || return 1;
return 1 unless $touch_mtime > $TouchTime;
$TouchTime = $touch_mtime;
my $sym = Apache->gensym;
open($sym, $TouchFile) || die "Can't open '$TouchFile': $!";
$TouchModules = <$sym>;
chomp $TouchModules;
}

if (ref($r) && (lc($r->dir_config("ReloadAll") || 'on') eq 'on')) {
*Apache::Reload::INCS = \%INC;
}
else {
*Apache::Reload::INCS = \%INCS;
my $ExtraList =
$TouchModules ||
(ref($r) && $r->dir_config("ReloadModules")) ||
'';
my @extra = split(/\s+/, $ExtraList);
foreach (@extra) {
if (/(.*)::\*$/) {
my $prefix = $1;
$prefix =~ s/::/\//g;
foreach my $match (keys %INC) {
if ($match =~ /^\Q$prefix\E/) {
$Apache::Reload::INCS{$match} = $INC{$match};
my $package = $match;
$package =~ s/\//::/g;
$package =~ s/\.pm$//;
no strict 'refs';
# warn "checking for FIELDS on $package\n";
if (%{"${package}::FIELDS"}) {
# warn "found fields in $package\n";
$UndefFields{$match} = "${package}::FIELDS";
}
}
}
}
else {
Apache::Reload->register_module($_);
}
}
}

my @changed;
while (my($key, $file) = each %Apache::Reload::INCS) {
local $^W;
warn "Apache::Reload: Checking mtime of $key\n" if $DEBUG;

my $mtime = (stat $file)[9];

unless (defined($mtime) && $mtime) {
for (@INC) {
$mtime = (stat "$_/$file")[9];
last if defined($mtime) && $mtime;
}
}

warn("Apache::Reload: Can't locate $file\n"),next
unless defined $mtime and $mtime;

unless (defined $Stat{$file}) {
$Stat{$file} = $^T;
}
# remove the modules
if ($mtime > $Stat{$file}) {
if ($Ignore{$key}) {
warn "Apache::Reload: Not reloading $key\n";
}
else {
delete $INC{$key};
push @changed, $key;
}
}
$Stat{$file} = $mtime;
}

# reload the modules
foreach my $key (@changed) {
warn("Reloading $key\n") if $DEBUG;
if (my $symref = $UndefFields{$key}) {
warn("undeffing fields\n") if $DEBUG;
no strict 'refs';
undef %{$symref};
}
require $key;
warn("Apache::Reload: process $$ reloading $key\n")
if $DEBUG;
}

return 1;
}

1;
__END__

=head1 NAME

Apache::Reload - Reload changed modules

=head1 SYNOPSIS

In httpd.conf:

PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off

Then your module:

package My::Apache::Module;

use Apache::Reload;

sub handler { ... }

1;

=head1 DESCRIPTION

This module is two things. First it is an adaptation of Randal
Schwartz's Stonehenge::Reload module that attempts to be a little
more intuitive and makes the usage easier. Stonehenge::Reload was
written by Randal to make specific modules reload themselves when
they changed. Unlike Apache::StatINC, Stonehenge::Reload only checked
the change time of modules that registered themselves with
Stonehenge::Reload, thus reducing stat() calls. Apache::Reload also
offers the exact same functionality as Apache::StatINC, and is thus
designed to be a drop-in replacement. Apache::Reload only checks modules
that register themselves with Apache::Reload if you explicitly turn off
the StatINC emulation method (see below). Like Apache::StatINC,
Apache::Reload must be installed as an Init Handler.

=head2 StatINC Replacement

To use as a StatINC replacement, simply add the following configuration
to your httpd.conf:

PerlInitHandler Apache::Reload

=head2 Register Modules Implicitly

To only reload modules that have registered with Apache::Reload,
add the following to the httpd.conf:

PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off
# ReloadAll defaults to On

Then any modules with the line:

use Apache::Reload;

Will be reloaded when they change.

=head2 Register Modules Explicitly

You can also register modules explicitly in your httpd.conf file that
you want to be reloaded on change:

PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off
PerlSetVar ReloadModules "My::Foo My::Bar Foo::Bar::Test"

Note that these are split on whitespace, but the module list B<must>
be in quotes, otherwise Apache tries to parse the parameter list.

=head2 Un-Register Modules Explicitly

If ReloadAll is set to On, then you can explicity force a module not to be reloaded with

no Apache::Reload;

A warning will appear in the error log that the file has changed, but will
not be reloaded

=head2 Special "Touch" File

You can also set a file that you can touch() that causes the reloads to be
performed. If you set this, and don't touch() the file, the reloads don't
happen. This can be a great boon in a live environment:

PerlSetVar ReloadTouchFile /tmp/reload_modules

Now when you're happy with your changes, simply go to the command line and
type:

touch /tmp/reload_modules

And your modules will be magically reloaded on the next request. This option
works in both StatINC emulation mode and the registered modules mode.

=head1 PSUEDOHASHES

The short summary of this is: Don't use psuedohashes. Use an array with
constant indexes. Its faster in the general case, its more guaranteed, and
generally, it works.

The long summary is that I've done some work to get this working with
modules that use psuedo hashes, but its still broken in the case of a
single module that contains multiple packages that all use psuedohashes.

So don't do that.

=head1 AUTHOR

Matt Sergeant, matt@sergeant.org

=head1 MAINTAINERS

the mod_perl developers, dev@perl.apache.org

=head1 SEE ALSO

Apache::StatINC, Stonehenge::Reload

=cut
Apache-Reload/lib/Apache2/000075500000000000000000000000001222434245500154555ustar00rootroot00000000000000Apache-Reload/lib/Apache2/Reload.pm000064400000000000000000000435001222434245500172230ustar00rootroot00000000000000# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package Apache2::Reload;

use strict;
use warnings FATAL => 'all';

our $VERSION = '0.12';

use Apache2::Const -compile => qw(OK);

use Apache2::Connection;
use Apache2::ServerUtil;
use Apache2::RequestUtil;

use ModPerl::Util ();

use vars qw(%INCS %Stat $TouchTime);

%Stat = ($INC{"Apache2/Reload.pm"} => time);

$TouchTime = time;

sub import {
my $class = shift;
my ($package, $file) = (caller)[0,1];

$class->register_module($package, $file);
}

sub package_to_module {
my $package = shift;
$package =~ s/::/\//g;
$package .= ".pm";
return $package;
}

sub module_to_package {
my $module = shift;
$module =~ s/\//::/g;
$module =~ s/\.pm$//g;
return $module;
}

sub register_module {
my ($class, $package, $file) = @_;
my $module = package_to_module($package);

if ($file) {
$INCS{$module} = $file;
}
else {
$file = $INC{$module};
return unless $file;
$INCS{$module} = $file;
}
}

sub unregister_module {
my ($class, $package) = @_;
my $module = package_to_module($package);
delete $INCS{$module};
}

# the first argument is:
# $c if invoked as 'PerlPreConnectionHandler'
# $r if invoked as 'PerlInitHandler'
sub handler {
my $o = shift;
$o = $o->base_server if ref($o) eq 'Apache2::Connection';

my $DEBUG = ref($o) && (lc($o->dir_config("ReloadDebug") || '') eq 'on');

my $ReloadByModuleName = ref($o) && (lc($o->dir_config("ReloadByModuleName") || '') eq 'on');

my $TouchFile = ref($o) && $o->dir_config("ReloadTouchFile");

my $ConstantRedefineWarnings = ref($o) &&
(lc($o->dir_config("ReloadConstantRedefineWarnings") || '') eq 'off')
? 0 : 1;

my $TouchModules;

if ($TouchFile) {
warn "Checking mtime of $TouchFile\n" if $DEBUG;
my $touch_mtime = (stat $TouchFile)[9] || return Apache2::Const::OK;
return Apache2::Const::OK unless $touch_mtime > $TouchTime;
$TouchTime = $touch_mtime;
open my $fh, $TouchFile or die "Can't open '$TouchFile': $!";
$TouchModules = <$fh>;
chomp $TouchModules if $TouchModules;
}

if (ref($o) && (lc($o->dir_config("ReloadAll") || 'on') eq 'on')) {
*Apache2::Reload::INCS = \%INC;
}
else {
*Apache2::Reload::INCS = \%INCS;
my $ExtraList =
$TouchModules ||
(ref($o) && $o->dir_config("ReloadModules")) ||
'';
my @extra = split /\s+/, $ExtraList;
foreach (@extra) {
if (/(.*)::\*$/) {
my $prefix = $1;
$prefix =~ s/::/\//g;
foreach my $match (keys %INC) {
if ($match =~ /^\Q$prefix\E/) {
$Apache2::Reload::INCS{$match} = $INC{$match};
}
}
}
else {
Apache2::Reload->register_module($_);
}
}
}

my $ReloadDirs = ref($o) && $o->dir_config("ReloadDirectories");
my @watch_dirs = split(/\s+/, $ReloadDirs||'');

my @changed;
foreach my $key (sort { $a cmp $b } keys %Apache2::Reload::INCS) {
my $file = $Apache2::Reload::INCS{$key};

next unless defined $file;
next if ref $file;
next if @watch_dirs && !grep { $file =~ /^$_/ } @watch_dirs;
warn "Apache2::Reload: Checking mtime of $key\n" if $DEBUG;

my $mtime = (stat $file)[9];

unless (defined($mtime) && $mtime) {
for (@INC) {
$mtime = (stat "$_/$file")[9];
last if defined($mtime) && $mtime;
}
}

warn("Apache2::Reload: Can't locate $file\n"), next
unless defined $mtime and $mtime;

unless (defined $Stat{$file}) {
$Stat{$file} = $^T;
}

if ($mtime > $Stat{$file}) {
push @changed, [$key, $file];
}
$Stat{$file} = $mtime;
}

#First, let's unload all changed modules
foreach my $change (@changed) {
my ($module, $file) = @$change;
my $package = module_to_package($module);
ModPerl::Util::unload_package($package);
}

#Then, let's reload them all, so that module dependencies can satisfy
#themselves in the correct order.
foreach my $change (@changed) {
my ($module, $file) = @$change;
my $name = $ReloadByModuleName ? $module : $file;
require $name;
if ($DEBUG) {
my $package = module_to_package($module);
warn sprintf("Apache2::Reload: process %d reloading %s from %s\n",
$$, $package, $name);
}
}

return Apache2::Const::OK;
}

1;

__END__

=head1 NAME

Apache2::Reload - Reload Perl Modules when Changed on Disk

=head1 Synopsis

# Monitor and reload all modules in %INC:
# httpd.conf:
PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload

# when working with protocols and connection filters
# PerlPreConnectionHandler Apache2::Reload

# Reload groups of modules:
# httpd.conf:
PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlSetVar ReloadAll Off
PerlSetVar ReloadModules "ModPerl::* Apache2::*"
#PerlSetVar ReloadDebug On
#PerlSetVar ReloadByModuleName On

# Reload a single module from within itself:
package My::Apache2::Module;
use Apache2::Reload;
sub handler { ... }
1;

=head1 Description

C<Apache2::Reload> reloads modules that change on the disk.

When Perl pulls a file via C<require>, it stores the filename in the
global hash C<%INC>. The next time Perl tries to C<require> the same
file, it sees the file in C<%INC> and does not reload from disk. This
module's handler can be configured to iterate over the modules in
C<%INC> and reload those that have changed on disk or only specific
modules that have registered themselves with C<Apache2::Reload>. It can
also do the check for modified modules, when a special touch-file has
been modified.

Require-hooks, i.e., entries in %INC which are references, are ignored. The
hook should modify %INC itself, adding the path to the module file, for it to
be reloaded.

C<Apache2::Reload> inspects and reloads the B<file> associated with a given
module. Changes to @INC are not recognized, as it is the file which is
being re-required, not the module name.

In version 0.10 and earlier the B<module name>, not the file, is re-required.
Meaning it operated on the the current context of @INC. If you still want this
behavior set this environment variable in I<httpd.conf>:

PerlSetVar ReloadByModuleName On

This means, when called as a C<Perl*Handler>, C<Apache2::Reload> will not see
C<@INC> paths added or removed by C<ModPerl::Registry> scripts, as the value of
C<@INC> is saved on server startup and restored to that value after each
request. In other words, if you want C<Apache2::Reload> to work with modules
that live in custom C<@INC> paths, you should modify C<@INC> when the server is
started. Besides, C<'use lib'> in the startup script, you can also set the
C<PERL5LIB> variable in the httpd's environment to include any non-standard
'lib' directories that you choose. For example, to accomplish that you can
include a line:

PERL5LIB=/home/httpd/perl/extra; export PERL5LIB

in the script that starts Apache. Alternatively, you can set this
environment variable in I<httpd.conf>:

PerlSetEnv PERL5LIB /home/httpd/perl/extra

=head2 Monitor All Modules in C<%INC>

To monitor and reload all modules in C<%INC> at the beginning of
request's processing, simply add the following configuration to your
I<httpd.conf>:

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload

When working with connection filters and protocol modules
C<Apache2::Reload> should be invoked in the pre_connection stage:

PerlPreConnectionHandler Apache2::Reload

See also the discussion on
C<L<PerlPreConnectionHandler|docs::2.0::user::handlers::protocols/PerlPreConnectionHandler>>.

=head2 Register Modules Implicitly

To only reload modules that have registered with C<Apache2::Reload>,
add the following to the I<httpd.conf>:

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlSetVar ReloadAll Off
# ReloadAll defaults to On

Then any modules with the line:

use Apache2::Reload;

Will be reloaded when they change.

=head2 Register Modules Explicitly

You can also register modules explicitly in your I<httpd.conf> file
that you want to be reloaded on change:

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlSetVar ReloadAll Off
PerlSetVar ReloadModules "My::Foo My::Bar Foo::Bar::Test"

Note that these are split on whitespace, but the module list B<must>
be in quotes, otherwise Apache tries to parse the parameter list.

The C<*> wild character can be used to register groups of files under
the same namespace. For example the setting:

PerlSetVar ReloadModules "ModPerl::* Apache2::*"

will monitor all modules under the namespaces C<ModPerl::> and
C<Apache2::>.

=head2 Monitor Only Certain Sub Directories

To reload modules only in certain directories (and their
subdirectories) add the following to the I<httpd.conf>:

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlSetVar ReloadDirectories "/tmp/project1 /tmp/project2"

You can further narrow the list of modules to be reloaded from the
chosen directories with C<ReloadModules> as in:

PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlSetVar ReloadDirectories "/tmp/project1 /tmp/project2"
PerlSetVar ReloadAll Off
PerlSetVar ReloadModules "MyApache2::*"

In this configuration example only modules from the namespace
C<MyApache2::> found in the directories I</tmp/project1/> and
I</tmp/project2/> (and their subdirectories) will be reloaded.

=head2 Special "Touch" File

You can also declare a file, which when gets C<touch(1)>ed, causes the
reloads to be performed. For example if you set:

PerlSetVar ReloadTouchFile /tmp/reload_modules

and don't C<touch(1)> the file I</tmp/reload_modules>, the reloads
won't happen until you go to the command line and type:

% touch /tmp/reload_modules

When you do that, the modules that have been changed, will be
magically reloaded on the next request. This option works with any
mode described before.

=head2 Unregistering a module

In some cases, it might be necessary to explicitly stop reloading
a module.

Apache2::Reload->unregister_module('Some::Module');

But be carefull, since unregistering a module in this way will only
do so for the current interpreter. This feature should be used with
care.

=head1 Performance Issues

This module is perfectly suited for a development environment. Though
it's possible that you would like to use it in a production
environment, since with C<Apache2::Reload> you don't have to restart
the server in order to reload changed modules during software
updates. Though this convenience comes at a price:

=over

=item *

If the "touch" file feature is used, C<Apache2::Reload> has to stat(2)
the touch file on each request, which adds a slight but most likely
insignificant overhead to response times. Otherwise C<Apache2::Reload>
will stat(2) each registered module or even worse--all modules in
C<%INC>, which will significantly slow everything down.

=item *

Once the child process reloads the modules, the memory used by these
modules is not shared with the parent process anymore. Therefore the
memory consumption may grow significantly.

=back

Therefore doing a full server stop and restart is probably a better
solution.

=head1 Debug

If you aren't sure whether the modules that are supposed to be
reloaded, are actually getting reloaded, turn the debug mode on:

PerlSetVar ReloadDebug On

=head1 Caveats

=head2 Problems With Reloading Modules Which Do Not Declare Their Package Name

If you modify modules, which don't declare their C<package>, and rely on
C<Apache2::Reload> to reload them, you may encounter problems: i.e.,
it'll appear as if the module wasn't reloaded when in fact it
was. This happens because when C<Apache2::Reload> C<require()>s such a
module all the global symbols end up in the C<Apache2::Reload>
namespace! So the module does get reloaded and you see the compile
time errors if there are any, but the symbols don't get imported to
the right namespace. Therefore the old version of the code is running.


=head2 Failing to Find a File to Reload

C<Apache2::Reload> uses C<%INC> to find the files on the filesystem. If
an entry for a certain filepath in C<%INC> is relative,
C<Apache2::Reload> will use C<@INC> to try to resolve that relative
path. Now remember that mod_perl freezes the value of C<@INC> at the
server startup, and you can modify it only for the duration of one
request when you need to load some module which is not in on of the
C<@INC> directories. So a module gets loaded, and registered in
C<%INC> with a relative path. Now when C<Apache2::Reload> tries to find
that module to check whether it has been modified, it can't find since
its directory is not in C<@INC>. So C<Apache2::Reload> will silently
skip that module.

You can enable the C<Debug|/Debug> mode to see what C<Apache2::Reload>
does behind the scenes.



=head2 Problems with Scripts Running with Registry Handlers that Cache the Code

The following problem is relevant only to registry handlers that cache
the compiled script. For example it concerns
C<L<ModPerl::Registry|docs::2.0::api::ModPerl::Registry>> but not
C<L<ModPerl::PerlRun|docs::2.0::api::ModPerl::PerlRun>>.

=head3 The Problem

Let's say that there is a module C<My::Utils>:

#file:My/Utils.pm
#----------------
package My::Utils;
BEGIN { warn __PACKAGE__ , " was reloaded\n" }
use base qw(Exporter);
@EXPORT = qw(colour);
sub colour { "white" }
1;

And a registry script F<test.pl>:

#file:test.pl
#------------
use My::Utils;
print "Content-type: text/plain\n\n";
print "the color is " . colour();

Assuming that the server is running in a single mode, we request the
script for the first time and we get the response:

the color is white

Now we change F<My/Utils.pm>:

- sub colour { "white" }
+ sub colour { "red" }

And issue the request again. C<Apache2::Reload> does its job and we can
see that C<My::Utils> was reloaded (look in the I<error_log>
file). However the script still returns:

the color is white

=head3 The Explanation

Even though F<My/Utils.pm> was reloaded, C<ModPerl::Registry>'s cached
code won't run 'C<use My::Utils;>' again (since it happens only once,
i.e. during the compile time). Therefore the script doesn't know that
the subroutine reference has been changed.

This is easy to verify. Let's change the script to be:

#file:test.pl
#------------
use My::Utils;
print "Content-type: text/plain\n\n";
my $sub_int = \&colour;
my $sub_ext = \&My::Utils::colour;
print "int $sub_int\n";
print "ext $sub_ext\n";

Issue a request, you will see something similar to:

int CODE(0x8510af8)
ext CODE(0x8510af8)

As you can see both point to the same CODE reference (meaning that
it's the same symbol). After modifying F<My/Utils.pm> again:

- sub colour { "red" }
+ sub colour { "blue" }

and calling the script on the secondnd time, we get:

int CODE(0x8510af8)
ext CODE(0x851112c)

You can see that the internal CODE reference is not the same as the
external one.

=head3 The Solution

There are two solutions to this problem:

Solution 1: replace C<use()> with an explicit C<require()> +
C<import()>.

- use My::Utils;
+ require My::Utils; My::Utils->import();

now the changed functions will be reimported on every request.

Solution 2: remember to touch the script itself every time you change
the module that it requires.

=head1 Threaded MPM and Multiple Perl Interpreters

If you use C<Apache2::Reload> with a threaded MPM and multiple Perl
interpreters, the modules will be reloaded by each interpreter as they
are used, not every interpreters at once. Similar to mod_perl 1.0
where each child has its own Perl interpreter, the modules are
reloaded as each child is hit with a request.

If a module is loaded at startup, the syntax tree of each subroutine
is shared between interpreters (big win), but each subroutine has its
own padlist (where lexical my variables are stored). Once
C<Apache2::Reload> reloads a module, this sharing goes away and each
Perl interpreter will have its own copy of the syntax tree for the
reloaded subroutines.


=head1 Pseudo-hashes

The short summary of this is: Don't use pseudo-hashes. They are
deprecated since Perl 5.8 and are removed in 5.9.

Use an array with constant indexes. Its faster in the general case,
its more guaranteed, and generally, it works.

The long summary is that some work has been done to get this module
working with modules that use pseudo-hashes, but it's still broken in
the case of a single module that contains multiple packages that all
use pseudo-hashes.

So don't do that.




=head1 Copyright

mod_perl 2.0 and its core modules are copyrighted under
The Apache Software License, Version 2.0.


=head1 Authors

Matt Sergeant, matt@sergeant.org

Stas Bekman (porting to mod_perl 2.0)

A few concepts borrowed from C<Stonehenge::Reload> by Randal Schwartz
and C<Apache::StatINC> (mod_perl 1.x) by Doug MacEachern and Ask
Bjoern Hansen.

=head1 MAINTAINERS

the mod_perl developers, dev@perl.apache.org


=cut

Apache-Reload/t/000075500000000000000000000000001222434245500137075ustar00rootroot00000000000000Apache-Reload/t/all.t000064400000000000000000000001571222434245500146470ustar00rootroot00000000000000use strict;
use warnings FATAL => 'all';

use Apache::Test;
plan tests => 1, need_module('mod_perl.c');

ok(1);Apache-Reload/t/conf/000075500000000000000000000000001222434245500146345ustar00rootroot00000000000000Apache-Reload/t/conf/extra.last.conf.in000064400000000000000000000011341222434245500201740ustar00rootroot00000000000000<IfModule mod_perl.c>
<IfDefine APACHE2>
PerlModule Apache2::Reload
PerlModule Apache2::TestReload
</IfDefine>
<IfDefine APACHE1>
PerlModule Apache::Reload
PerlModule Apache::TestReload
</IfDefine>
<Location /reload>
SetHandler perl-script
<IfDefine APACHE2>
PerlInitHandler Apache2::Reload
PerlResponseHandler Apache2::TestReload
</IfDefine>
<IfDefine APACHE1>
PerlInitHandler Apache::Reload
PerlHandler Apache::TestReload
</IfDefine>
</Location>
</IfModule>
Apache-Reload/t/lib/000075500000000000000000000000001222434245500144555ustar00rootroot00000000000000Apache-Reload/t/lib/Apache/000075500000000000000000000000001222434245500156365ustar00rootroot00000000000000Apache-Reload/t/lib/Apache/TestReload.pm000064400000000000000000000014361222434245500202460ustar00rootroot00000000000000package Apache::TestReload;

use strict;
use warnings FATAL => 'all';

#use ModPerl::Util ();
use Apache::Constants qw(:common);

my $package = 'Reload::Test';

our $pass = 0;

sub handler {
my $r = shift;
$pass++;
$r->send_http_header('text/plain');
if ((defined ($r->args)) && ($r->args eq 'last')) {
#Apache2::Reload->unregister_module($package);
#ModPerl::Util::unload_package($package);
$pass = 0;
$r->print("unregistered OK");
return OK;
}

eval "require $package";

Reload::Test::run($r);

return OK;
}

# This one shouldn't be touched
package Reload::Test::SubPackage;

sub subpackage {
if ($Apache::TestReload::pass == '2') {
return 'SUBPACKAGE';
}
else {
return 'subpackage';
}
}

1;
Apache-Reload/t/lib/Apache2/000075500000000000000000000000001222434245500157205ustar00rootroot00000000000000Apache-Reload/t/lib/Apache2/TestReload.pm000064400000000000000000000014661222434245500203330ustar00rootroot00000000000000package Apache2::TestReload;

use strict;
use warnings FATAL => 'all';

use ModPerl::Util ();
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(OK);
use Apache2::RequestIO ();

my $package = 'Reload::Test';

our $pass = 0;

sub handler {
my $r = shift;
$pass++;
if ($r->args eq 'last') {
Apache2::Reload->unregister_module($package);
ModPerl::Util::unload_package($package);
$pass = 0;
$r->print("unregistered OK");
return Apache2::Const::OK;
}

eval "require $package";

Reload::Test::run($r);

return Apache2::Const::OK;
}

# This one shouldn't be touched
package Reload::Test::SubPackage;

sub subpackage {
if ($Apache2::TestReload::pass == '2') {
return 'SUBPACKAGE';
}
else {
return 'subpackage';
}
}

1;
Apache-Reload/t/reload.t000064400000000000000000000027311222434245500153450ustar00rootroot00000000000000use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest;
use File::Spec::Functions qw(catfile tmpdir);

Apache::TestRequest::user_agent(keep_alive => 1);

plan tests => 3, need 'HTML::HeadParser';

my $test_file = catfile qw(Reload Test.pm);

my $location = '/reload';

my @tests = qw(const prototype simple subpackage);

my $header = join '', <DATA>;

my $initial = <<'EOF';
sub simple { 'simple' }
use constant const => 'const';
sub prototype($) { 'prototype' }
sub promised;
EOF

my $modified = <<'EOF';
sub simple { 'SIMPLE' }
use constant const => 'CONST';
sub prototype($$) { 'PROTOTYPE' }
EOF

t_write_test_lib($test_file, $header, $initial);

{
my $expected = join '', map { "$_:$_\n" } sort @tests;
my $received = GET $location;
ok t_cmp($received->content, $expected, 'Initial');
}

t_write_test_lib($test_file, $header, $modified);

{
my $expected = join '', map { "$_:" . uc($_) . "\n" } sort @tests;
my $received = GET $location;
ok t_cmp($received->content, $expected, 'Reload');
}

{
my $expected = "unregistered OK";
my $received = GET "$location?last";
ok t_cmp($received->content, $expected, 'Unregister');
}

__DATA__
package Reload::Test;

our @methods = qw(const prototype simple subpackage);

sub subpackage { return Reload::Test::SubPackage::subpackage() }

sub run {
my $r = shift;
foreach my $m (sort @methods) {
$r->print($m, ':', __PACKAGE__->$m(), "\n");
}
}

1;
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009