view release on metacpan or search on metacpan
my $rtest = $ModPerl2 ? Apache2::RequestUtil->request() : Apache->request();
if($filename = eval { $rtest->filename }) {
$r = $rtest;
} else {
return &DSOError($rtest);
}
}
# better error checking ?
$filename ||= $r->filename();
# using _ is optimized to use last stat() record
return(404) if (! -e $filename or -d _);
# alias $0 to filename, bind to glob for bug workaround
local *0 = \$filename;
# ASP object creation, a lot goes on in there!
# method call used for speed optimization, as OO calls are slow
my $self = &Apache::ASP::new('Apache::ASP', $r, $filename);
# for runtime use/require library loads from global/INCDir
)
);
# $self->{dbg} && $self->Debug("compile checksum $checksum");
$self->{compile_checksum} = $checksum;
}
my $compile_checksum = $no_compile_checksum ? '' : $self->{compile_checksum};
my @inode_stat = ();
if($self->{inode_names}) {
@inode_stat = stat($file);
# one or the other device or file ids must be not 0
unless($inode_stat[0] || $inode_stat[1]) {
@inode_stat = ();
}
}
if(@inode_stat) {
$id = sprintf("____DEV%X_INODE%X",@inode_stat[0,1]);
$id .= 'x'.$compile_checksum;
} else {
my $id = &FileId($self, $include);
$subid = ($package || $self->{GlobalASA}{'package'})."::$id".'xINC';
my $compiled = $Apache::ASP::CompiledIncludes{$subid};
if($compiled && ! $self->{stat_scripts}) {
$self->{dbg} && $self->Debug("no stat: found cached code for include $id");
return $compiled;
}
# return cached code if include hasn't been modified recently
$mtime = (stat($include))[9];
if($compiled && ($compiled->{mtime} > $mtime)) {
# $self->Debug("found cached code for include $id");
# now check for changed includes, return if not changed
my $includes_changed = 0;
if(my $includes = $Apache::ASP::Includes{$include}) {
for my $k (keys %$includes) {
my $v = $includes->{$k} || 0;
my @stat = stat($k);
if(@stat) {
if($stat[9] >= $v) {
$self->{dbg} && $self->Debug("file $k mtime changed from $v to $stat[9]");
$includes_changed = 1;
last;
}
} else {
$self->{dbg} && $self->Debug("can't get mtime for file $k: $!");
$includes_changed = 1;
last;
CGI style. There will be a performance hit server side if output
is flushed automatically to the client, but is probably small.
I would leave this on, since error handling is poor, if your asp
script errors after sending only some of the output.
PerlSetVar BufferingOn 1
=item InodeNames
Default 0. Set to 1 to uses a stat() call on scripts and includes to
derive subroutine namespace based on device and inode numbers. In case of
multiple symbolic links pointing to the same script this will result
in the script being compiled only once. Use only on unix flavours
which support the stat() call that know about device and inode
numbers.
PerlSetVar InodeNames 1
=item RequestParams
Default 0, if set creates $Request->Params object with combined
contents of $Request->QueryString and $Request->Form. This
is for developer convenience simlar to CGI.pm's param() method.
=item StatScripts
default 1, if set to 0, changed scripts, global.asa, and includes
will not be reloaded. Coupled with Apache mod_perl startup and restart
handlers executing Apache::ASP->Loader() for your application
this allows your application to be frozen, and only reloaded on the
next server restart or stop/start.
There are a few advantages for not reloading scripts and modules
in production. First there is a slight performance improvement
by not having to stat() the script, its includes and the global.asa
every request.
From an application deployment standpoint, you
also gain the ability to deploy your application as a
snapshot taken when the server starts and restarts.
This provides you with the reassurance that during a
production server update from development sources, you
do not have to worry with sources being used for the
wrong libraries and such, while they are all being
copied over.
- When GlobalPackage config changes, but global.asa has not, global.asa
will be recompiled anyway to update the GlobalPackage correctly.
Changing GlobalPackage before would cause errors if global.asa was
already compiled.
++ For ANY PerlSetVar type config, OFF/Off/off will be assumed
to have value of 0 for that setting. Before, only a couple settings
had this semantics, but they all do now for consistency.
- Fix for InodeNames config on OpenBSD, or any OS that might have
a device # of 0 for the file being stat()'d, thanks to Peter Galbavy
for bug report.
++ Total XSLT speedups, 5-10% on large XSLT, 10-15% on small XSLT
+ bypass meta data check like expires for XSLT Cache() API use
because XSLT tranformations don't expire, saves hit to cache dbm
for meta data
+ use of direct Apache::ASP::State methods like FETCH/STORE
in Cache() layer so we don't have to go through slower tied interface.
+ INTERNAL API ReadFile() now returns scalar ref as memory optimization
+ cache InodeNames config setting in ASP object now for common lookups
+ removed CompileChecksum() INTERNAL API, since it was an unnecesary
method decomposition along a common code path
+ removed IsChanged() INTERNAL API since compiling of scripts
is now handled by CompileInclude() which does this functionality already
+ removed unnecessary decomp of IncludesChanged() INTERNAL API, which was along
critical code path
+ do not call INTERNAL SearchDirs() API when compiling base script
since we have already validated its path earlier
+ Use stat(_) type shortcut for stat() & -X calls where possible
+ Moved @INC initilization up to handler() & consolidated with $INCDir lib
+ removed useless Apache::ASP::Collection::DESTROY
+ removed useless Apache::ASP::Server::DESTROY
+ removed useless Apache::ASP::GlobalASA::DESTROY
+ removed useless Apache::ASP::Response::DESTROY
- Default path for $Response->{Cookies} was from CookiePath
config, but this was incorrect as CookiePath config is only
for $Session cookie, so now path for $Response->{Cookies}
defaults to /
Ime Smits. Added some 1-2% per request execution speed.
+Added StateDB MLDBM::Sync::SDBM_File support for faster
$Session + $Application than DB_File, yet still overcomes
SDBM_File's 1024 bytes value limitation. Documented in
StateDB config, and added Makefile.PL entry.
+Removed deprecated MD5 use and replace with Digest::MD5 calls
+PerlSetVar InodeNames 1 config which will compile scripts hashed by
their device & inode identifiers, from a stat($file)[0,1] call.
This allows for script directories, the Global directory,
and IncludesDir directories to be symlinked to without
recompiling identical scripts. Likely only works on Unix
systems. Thanks to Ime Smits for this one.
+Streamlined code internally so that includes & scripts were
compiled by same code. This is a baby step toward fusing
include & script code compilation models, leading to being
able to compile bits of scripts on the fly as ASP subs,
and being able to garbage collect ASP code subroutines.
the Apache ErrorDocument config setting. Updated
documentation, and added error_document.htm example.
=OrderCollections setting was added, but then REMOVED
because it was not going to be used. It bound
$Request->* collections/hashes to Tie::IxHash, so that data
in those collections would be read in the order the
browser sent it, when eaching through or with keys.
-global.asa will be reloaded when changed. This broke
when I optimized the modification times with (stat($file))[9]
rather than "use File::stat; stat($file)->mtime"
-Make Apache::ASP->Loader() PerlRestartHandler safe,
had some unstrict code that was doing the wrong thing.
-IncludesDir config now works with DynamicIncludes.
+DebugBufferLength feature added, giving control to
how much buffered output gets shown when debugging errors.
++Tuning of $Response->Write(), which processes all
Makefile.PL view on Meta::CPAN
#!/usr/local/bin/perl
use strict;
$| = 1;
my $mtime_makefile = (stat('Makefile'))[9] || 0;
my $fresh_makefile = ($mtime_makefile > time() - 1200) ? 1 : 0;
my $necessary_modules = {
# 'Apache' => 'Make sure your installation of mod_perl is complete',
'Class::Struct' => "Apache::ASP->Loader() precompile scripts functionality",
'MLDBM' => 'This is used for reading and writing multi-level hashes on disk',
'MLDBM::Sync 0.25' => 'Support for State dbms like $Session & $Application',
'SDBM_File' => 'Internal databases used for state files, like $Session',
'Data::Dumper' => 'Serializes data for MLDBM',
'Fcntl' => 'Used for file locking constants',
If false, 0, the output is immediately written to the client, CGI style.
There will be a performance hit server side if output is flushed
automatically to the client, but is probably small.
I would leave this on, since error handling is poor, if your asp script
errors after sending only some of the output.
PerlSetVar BufferingOn 1
InodeNames
Default 0. Set to 1 to uses a stat() call on scripts and includes to
derive subroutine namespace based on device and inode numbers. In case
of multiple symbolic links pointing to the same script this will result
in the script being compiled only once. Use only on unix flavours which
support the stat() call that know about device and inode numbers.
PerlSetVar InodeNames 1
RequestParams
Default 0, if set creates $Request->Params object with combined contents
of $Request->QueryString and $Request->Form. This is for developer
convenience simlar to CGI.pm's param() method.
PerlSetVar RequestParams 1
StatScripts
default 1, if set to 0, changed scripts, global.asa, and includes will
not be reloaded. Coupled with Apache mod_perl startup and restart
handlers executing Apache::ASP->Loader() for your application this
allows your application to be frozen, and only reloaded on the next
server restart or stop/start.
There are a few advantages for not reloading scripts and modules in
production. First there is a slight performance improvement by not
having to stat() the script, its includes and the global.asa every
request.
From an application deployment standpoint, you also gain the ability to
deploy your application as a snapshot taken when the server starts and
restarts. This provides you with the reassurance that during a
production server update from development sources, you do not have to
worry with sources being used for the wrong libraries and such, while
they are all being copied over.
Finally, though you really should not do this, you can work on a live
- When GlobalPackage config changes, but global.asa has not, global.asa
will be recompiled anyway to update the GlobalPackage correctly.
Changing GlobalPackage before would cause errors if global.asa was
already compiled.
++ For ANY PerlSetVar type config, OFF/Off/off will be assumed
to have value of 0 for that setting. Before, only a couple settings
had this semantics, but they all do now for consistency.
- Fix for InodeNames config on OpenBSD, or any OS that might have
a device # of 0 for the file being stat()'d, thanks to Peter Galbavy
for bug report.
++ Total XSLT speedups, 5-10% on large XSLT, 10-15% on small XSLT
+ bypass meta data check like expires for XSLT Cache() API use
because XSLT tranformations don't expire, saves hit to cache dbm
for meta data
+ use of direct Apache::ASP::State methods like FETCH/STORE
in Cache() layer so we don't have to go through slower tied interface.
+ INTERNAL API ReadFile() now returns scalar ref as memory optimization
+ cache InodeNames config setting in ASP object now for common lookups
+ removed CompileChecksum() INTERNAL API, since it was an unnecesary
method decomposition along a common code path
+ removed IsChanged() INTERNAL API since compiling of scripts
is now handled by CompileInclude() which does this functionality already
+ removed unnecessary decomp of IncludesChanged() INTERNAL API, which was along
critical code path
+ do not call INTERNAL SearchDirs() API when compiling base script
since we have already validated its path earlier
+ Use stat(_) type shortcut for stat() & -X calls where possible
+ Moved @INC initilization up to handler() & consolidated with $INCDir lib
+ removed useless Apache::ASP::Collection::DESTROY
+ removed useless Apache::ASP::Server::DESTROY
+ removed useless Apache::ASP::GlobalASA::DESTROY
+ removed useless Apache::ASP::Response::DESTROY
- Default path for $Response->{Cookies} was from CookiePath
config, but this was incorrect as CookiePath config is only
for $Session cookie, so now path for $Response->{Cookies}
defaults to /
Ime Smits. Added some 1-2% per request execution speed.
+Added StateDB MLDBM::Sync::SDBM_File support for faster
$Session + $Application than DB_File, yet still overcomes
SDBM_File's 1024 bytes value limitation. Documented in
StateDB config, and added Makefile.PL entry.
+Removed deprecated MD5 use and replace with Digest::MD5 calls
+PerlSetVar InodeNames 1 config which will compile scripts hashed by
their device & inode identifiers, from a stat($file)[0,1] call.
This allows for script directories, the Global directory,
and IncludesDir directories to be symlinked to without
recompiling identical scripts. Likely only works on Unix
systems. Thanks to Ime Smits for this one.
+Streamlined code internally so that includes & scripts were
compiled by same code. This is a baby step toward fusing
include & script code compilation models, leading to being
able to compile bits of scripts on the fly as ASP subs,
and being able to garbage collect ASP code subroutines.
the Apache ErrorDocument config setting. Updated
documentation, and added error_document.htm example.
=OrderCollections setting was added, but then REMOVED
because it was not going to be used. It bound
$Request->* collections/hashes to Tie::IxHash, so that data
in those collections would be read in the order the
browser sent it, when eaching through or with keys.
-global.asa will be reloaded when changed. This broke
when I optimized the modification times with (stat($file))[9]
rather than "use File::stat; stat($file)->mtime"
-Make Apache::ASP->Loader() PerlRestartHandler safe,
had some unstrict code that was doing the wrong thing.
-IncludesDir config now works with DynamicIncludes.
+DebugBufferLength feature added, giving control to
how much buffered output gets shown when debugging errors.
++Tuning of $Response->Write(), which processes all
lib/Apache/ASP/GlobalASA.pm view on Meta::CPAN
if(! $exists && ! $compiled->{'exists'}) {
# fastest exit for simple case of no global.asa
return $self;
} elsif(! $exists && $compiled->{'exists'}) {
# if the global.asa disappeared
$changed = 1;
} elsif($exists && ! $compiled->{'exists'}) {
# if global.asa reappeared
$changed = 1;
} else {
$self->{mtime} = $exists ? (stat(_))[9] : 0;
if($self->{mtime} > $compiled->{mtime}) {
# if the modification time is greater than the compile time
$changed = 1;
}
}
$changed || return($self);
my $code = $exists ? ${$asp->ReadFile($filename)} : "";
my $strict = $asp->{use_strict} ? "use strict" : "no strict";
lib/Apache/ASP/GlobalASA.pm view on Meta::CPAN
eval $code;
} else {
eval $code;
}
# if we have success compiling, then update the compile time
if(! $@) {
# if file mod times are bad, we need to use them anyway
# for relative comparison, time() was used here before, but
# doesn't work
$compiled->{mtime} = $self->{mtime} || (stat($filename))[9];
# remember whether the file really exists
$compiled->{'exists'} = $exists;
# we cache whether the code was compiled so we can do quick
# lookups before executing it
my $routines = {};
local *stash = *{"$self->{'package'}::"};
for(@Routines) {
if($stash{$_}) {
lib/Apache/ASP/Response.pm view on Meta::CPAN
if($data->{Cache}) {
$cache = 1;
$cache_expires = $data->{'Expires'};
$cache_clear = $data->{'Clear'};
my $file_data = '';
if(ref($file)) {
$file_data = 'INCLUDE SCALAR REF '.$$file;
} else {
my $real_file = $asp->SearchDirs($file);
$file_data = 'INCLUDE FILE '.(stat($real_file))[9].' //\\ :: '.$real_file.' //\\ :: '.$file;
}
if($data->{Key}) {
$cache_key = $file_data .' //\\ :: '.DumperX($data->{Key});
$asp->{dbg} && $asp->Debug("include cache key length ".length($cache_key)." with extra Key data");
} else {
$asp->{dbg} && $asp->Debug("include cache key length ".length($file_data));
$cache_key = $file_data;
}
$cache_key .= ' //\\ COMPILE CHECKSUM :: '.$asp->{compile_checksum};
$cache_key .= ' //\\ ARGS :: '.DumperX(@_);
lib/Apache/ASP/StatINC.pm view on Meta::CPAN
}
while(my($key,$file) = each %INC) {
if($self->{stat_inc_match} && defined $Stat{$file}) {
# we skip only if we have already registered this file
# we need to register the codes so we don't undef imported symbols
next unless ($key =~ /$self->{stat_inc_match}/);
}
next unless (-e $file); # sometimes there is a bad file in the %INC
my $mtime = (stat($file))[9];
# its ok if this block is CPU intensive, since it should only happen
# when modules get changed, and that should be infrequent on a production site
if(! defined $Stat{$file}) {
$self->{dbg} && $self->Debug("loading symbols first time", { $key => $file});
$self->StatRegister($key, $file, $mtime);
} elsif($mtime > $Stat{$file}) {
$self->{dbg} && $self->Debug("reloading", {$key => $file});
$stats++; # count files we have reloaded
$self->StatRegisterAll();
site/apps/search/global.asa view on Meta::CPAN
%final;
}
sub refresh_db {
my($CONF) = @_;
$SIG{__DIE__} = \&Carp::confess;
if(($SDB{LastRefresh} + $CONF->{RefreshPeriod}) < time
or
($SDB{LastRefresh} < stat($0)->mtime)
) {
%SDB = ();
$SDB{LastRefresh} = time();
my %files;
find( { wanted =>
sub {
if(! /$CONF->{FileMatch}/) {
$Response->Debug("$_ does not match $CONF->{FileMatch}");
} elsif(-d $_) {
site/apps/search/global.asa view on Meta::CPAN
my($file) = @_;
return unless -e $file;
$Response->Debug("indexing $file");
my $mtime_key = "MTIME:$file";
my $file_key = "FILE:$file";
my $file_data = $SDB{$file} || '';
my($mtime) = split(/\:\:/, $file_data, 2);
$mtime ||= 0;
if($mtime >= stat($file)->mtime) {
$Response->Debug("file $file has not been modified recently, last update $mtime");
return;
}
if($mtime) {
for (keys %SDB) {
if(/\:$file/) {
#$Response->Debug("deleting old key $_");
delete $SDB{$_};
}
site/apps/search/global.asa view on Meta::CPAN
# for my $word ( keys %words ) {
# my $count = $words{$word};
# my $word_key = "WORD:$word";
# my $word_dict = $SDB{$word_key} || {};
# $word_dict->{$file} = $count;
# $SDB{$word_key} = $word_dict;
# }
$Response->Debug("fetched words for $file"); # : ".join(", ", sort keys %words));
$SDB{$mtime_key} = stat($file)->mtime;
$SDB{$file_key} = {
title => $title,
summary => $summary,
};
my $weight = 1 / length(scalar(keys %words));
$SDB{"WEIGHT:$file"} = $weight;
# $Response->Debug($SDB{$file_key});
\%words;
site/changes.html view on Meta::CPAN
- When GlobalPackage config changes, but global.asa has not, global.asa
will be recompiled anyway to update the GlobalPackage correctly.
Changing GlobalPackage before would cause errors if global.asa was
already compiled.
++ For ANY PerlSetVar type config, OFF/Off/off will be assumed
to have value of 0 for that setting. Before, only a couple settings
had this semantics, but they all do now for consistency.
- Fix for InodeNames config on OpenBSD, or any OS that might have
a device # of 0 for the file being stat()'d, thanks to Peter Galbavy
for bug report.
++ Total XSLT speedups, 5-10% on large XSLT, 10-15% on small XSLT
+ bypass meta data check like expires for XSLT Cache() API use
because XSLT tranformations don't expire, saves hit to cache dbm
for meta data
+ use of direct Apache::ASP::State methods like FETCH/STORE
in Cache() layer so we don't have to go through slower tied interface.
site/changes.html view on Meta::CPAN
+ INTERNAL API ReadFile() now returns scalar ref as memory optimization
+ cache InodeNames config setting in ASP object now for common lookups
+ removed CompileChecksum() INTERNAL API, since it was an unnecesary
method decomposition along a common code path
+ removed IsChanged() INTERNAL API since compiling of scripts
is now handled by CompileInclude() which does this functionality already
+ removed unnecessary decomp of IncludesChanged() INTERNAL API, which was along
critical code path
+ do not call INTERNAL SearchDirs() API when compiling base script
since we have already validated its path earlier
+ Use stat(_) type shortcut for stat() & -X calls where possible
+ Moved @INC initilization up to handler() & consolidated with $INCDir lib
+ removed useless Apache::ASP::Collection::DESTROY
+ removed useless Apache::ASP::Server::DESTROY
+ removed useless Apache::ASP::GlobalASA::DESTROY
+ removed useless Apache::ASP::Response::DESTROY
- Default path for $Response->{Cookies} was from CookiePath
config, but this was incorrect as CookiePath config is only
for $Session cookie, so now path for $Response->{Cookies}
defaults to /
site/changes.html view on Meta::CPAN
Ime Smits. Added some 1-2% per request execution speed.
+Added StateDB MLDBM::Sync::SDBM_File support for faster
$Session + $Application than DB_File, yet still overcomes
SDBM_File's 1024 bytes value limitation. Documented in
StateDB config, and added Makefile.PL entry.
+Removed deprecated MD5 use and replace with Digest::MD5 calls
+PerlSetVar InodeNames 1 config which will compile scripts hashed by
their device & inode identifiers, from a stat($file)[0,1] call.
This allows for script directories, the Global directory,
and IncludesDir directories to be symlinked to without
recompiling identical scripts. Likely only works on Unix
systems. Thanks to Ime Smits for this one.
+Streamlined code internally so that includes & scripts were
compiled by same code. This is a baby step toward fusing
include & script code compilation models, leading to being
able to compile bits of scripts on the fly as ASP subs,
and being able to garbage collect ASP code subroutines.
site/changes.html view on Meta::CPAN
the Apache ErrorDocument config setting. Updated
documentation, and added error_document.htm example.
=OrderCollections setting was added, but then REMOVED
because it was not going to be used. It bound
$Request->* collections/hashes to Tie::IxHash, so that data
in those collections would be read in the order the
browser sent it, when eaching through or with keys.
-global.asa will be reloaded when changed. This broke
when I optimized the modification times with (stat($file))[9]
rather than "use File::stat; stat($file)->mtime"
-Make Apache::ASP->Loader() PerlRestartHandler safe,
had some unstrict code that was doing the wrong thing.
-IncludesDir config now works with DynamicIncludes.
+DebugBufferLength feature added, giving control to
how much buffered output gets shown when debugging errors.
++Tuning of $Response->Write(), which processes all
site/config.html view on Meta::CPAN
</pre></font>I would leave this on, since error handling is poor, if your asp
script errors after sending only some of the output.
<font face="courier new" size=3><pre>
PerlSetVar BufferingOn 1
</pre></font>
<p>
<a name=InodeNames></a>
<font face=verdana><font class=title size=-1 color=#555555><b>InodeNames</b></font>
<font face="courier new" size=3><pre>
</pre></font>Default 0. Set to 1 to uses a stat() call on scripts and includes to
derive subroutine namespace based on device and inode numbers. In case of
multiple symbolic links pointing to the same script this will result
in the script being compiled only once. Use only on unix flavours
which support the stat() call that know about device and inode
numbers.
<font face="courier new" size=3><pre>
PerlSetVar InodeNames 1
</pre></font>
<p>
<a name=RequestParam25a784ba></a>
<font face=verdana><font class=title size=-1 color=#555555><b>RequestParams</b></font>
<font face="courier new" size=3><pre>
</pre></font>Default 0, if set creates $Request->Params object with combined
site/config.html view on Meta::CPAN
<font face=verdana><font class=title size=-1 color=#555555><b>StatScripts</b></font>
<font face="courier new" size=3><pre>
</pre></font>default 1, if set to 0, changed scripts, global.asa, and includes
will not be reloaded. Coupled with Apache <a href=http://perl.apache.org><font size=-1 face=verdana><b>mod_perl</b></font></a> startup and restart
handlers executing Apache::ASP->Loader() for your application
this allows your application to be frozen, and only reloaded on the
next server restart or stop/start.
<font face="courier new" size=3><pre>
</pre></font>There are a few advantages for not reloading scripts and modules
in production. First there is a slight performance improvement
by not having to stat() the script, its includes and the global.asa
every request.
<font face="courier new" size=3><pre>
</pre></font>From an application deployment standpoint, you
also gain the ability to deploy your application as a
snapshot taken when the server starts and restarts.
This provides you with the reassurance that during a
production server update from development sources, you
do not have to worry with sources being used for the
wrong libraries and such, while they are all being
copied over.
t/inode_names.t view on Meta::CPAN
use strict;
my $ASP = $Server->{asp};
my $file_id1 = $ASP->FileId(basename($Server->File));
$t->eok(sub { $file_id1 =~ /^__ASP_inode_names_tx.{32}$/ }, "basename FileId()");
my $file_id2 = $ASP->FileId('abc'x200);
$t->eok(sub { $file_id2 =~ /abcx/ and length($file_id1) < 120 }, "long name FileId()");
my $file_id3 = '';
if(my $stat = (stat('.'))[1]) {
# need both here, inode_names is not cached at new() time
$ASP->{r}->dir_config->set('InodeNames', 1);
$ASP->{inode_names} = 1;
$file_id3 = $ASP->FileId(basename($Server->File));
$t->eok(sub { $file_id3 =~ /DEV.+_INODE.+/ }, "InodeNames FileId()");
}
$t->eok(length($ASP->{compile_checksum}) == 32, "Compile Checksum");