i'm not sure if anyone will ever find this useful but this makes
$Application a per-process global var if you prefer that. this is
probably terribly coded but it works for what i need (i'm definitely
not a perl guru). please suggest improvement if you can ;)
need
PerlSetVar AppDataPerProcess 1
in config file.
jr
--
------------------------------------------------------------------------
Joel W. Reed http://ruby.ddiworld.com/jreed
-------------------Portable: survives system reboot.-------------------
--- ASP.pm Thu Feb 3 20:35:08 2000
+++ /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm Wed Mar 29 09:51:29 2000
@@ -250,6 +250,7 @@
$r->dir_config('GlobalPackage', $args{GlobalPackage});
$r->dir_config('StatINC', $args{StatINC});
$r->dir_config('StatINCMatch', $args{StatINCMatch});
+ $r->dir_config('AppDataPerProcess', $args{AppDataPerProcess});
eval {
my $asp = Apache::ASP::new($r);
@@ -395,6 +396,7 @@
stat_scripts => defined $r->dir_config('StatScripts') ?
$r->dir_config('StatScripts') : 1,
stat_inc => $r->dir_config('StatINC'),
stat_inc_match => $r->dir_config('StatINCMatch'),
+ app_data_per_process => $r->dir_config('AppDataPerProcess'),
# moved state to state config
# state_cache => $r->dir_config('StateCache'),
@@ -571,12 +573,14 @@
$self->{app_state} = (defined $r->dir_config('AllowApplicationState') ?
$r->dir_config('AllowApplicationState') : 1);
if($self->{app_state}) {
- ($self->{Application} = &Apache::ASP::Application::new($self))
- || $self->Error("can't get application state");
- if($self->{dbg}) {
+ if (!$self->{app_data_per_process}) {
+ ($self->{Application} = &Apache::ASP::Application::new($self))
+ || $self->Error("can't get application state");
+ if($self->{dbg}) {
$self->{Application}->Lock();
$self->Debug('created $Application', $self->{Application});
$self->{Application}->UnLock();
+ }
}
} else {
$self->{dbg} && $self->Debug("no application allowed config");
@@ -1147,6 +1151,11 @@
$self->UndefRoutine($subid);
$self->{dbg} && $self->Debug("compiling into package $self->{'package'} subid
$subid");
+ my $hack = "";
+ if (!$self->{app_data_per_process}) {
+ $hack = "use vars qw(%Application);\n*Application =
+\\%Apache::ASP::ApplicationPerProcess::Application;",
+ }
+
my $eval =
join(" ;; ",
"package $self->{'package'};",
@@ -1154,6 +1163,7 @@
# "use vars qw(\$".join(" \$",@Apache::ASP::Objects).');',
"sub $subid { ",
' return(1) unless $_[0]; ', #@_ = ();',
+ $hack,
$$script,
'}',
);
@@ -2110,11 +2120,17 @@
my $code = $exists ? $asp->ReadFile($filename) : "";
my $strict = $asp->{use_strict} ? "use strict" : "no strict";
$code =~ s/\<\/?script?.*?\>/\#script tag removed here/igs;
+ my $hack = "";
+ if (!$self->{app_data_per_process}) {
+ $hack = "use vars qw(%Application);\n*Application =
+\\%Apache::ASP::ApplicationPerProcess::Application;",
+ }
+
$code = join(" ;; ",
"package $self->{'package'};",
$strict,
"use vars qw(\$".join(" \$",@Apache::ASP::Objects).');',
"use lib qw($self->{asp}->{global});",
+ $hack,
$code,
'sub exit { $main::Response->End(); } ',
'1;',
@@ -2240,14 +2256,16 @@
my $asp = $self->{asp};
$asp->Debug("Application_OnEnd");
$self->Execute('Application_OnEnd');
- delete $asp->{Internal}{'application'};
+ if (! $asp->{app_data_per_process}) {
+ delete $asp->{Internal}{'application'};
- local $^W = 0;
- my $tied = tied %{$asp->{Application}};
- untie %{$asp->{Application}};
- $tied->DESTROY(); # call explicit DESTROY
- $asp->{Application} = &Apache::ASP::Application::new($self->{asp})
- || $self->Error("can't get application state");
+ local $^W = 0;
+ my $tied = tied %{$asp->{Application}};
+ untie %{$asp->{Application}};
+ $tied->DESTROY(); # call explicit DESTROY
+ $asp->{Application} = &Apache::ASP::Application::new($self->{asp})
+ || $self->Error("can't get application state");
+ }
}
sub ScriptOnStart {
@@ -3302,6 +3320,14 @@
}
}
+1;
+
+# ApplicationPerProcess Implementation
+package Apache::ASP::ApplicationPerProcess;
+use strict;
+use vars qw(%Application);
+%Application = (
+);
1;
# Session Object