Subject: | Not compatible with mod_perl in multi-threaded Apache 2 |
Date: | Sun, 14 Oct 2007 17:41:19 +0100 |
To: | bug-Maypole [...] rt.cpan.org |
From: | Ben Hutchings <ben [...] decadent.org.uk> |
Maypole::Model::Base::FETCH_CODE_ATTRIBUTES uses references as hash
keys. Hash keys are just strings, not ordinary scalars, so if the
interpreter is cloned, as it will be in multithreaded configurations of
Apache, these references become invalid. The module needs to store the
references in the hash values and then rehash after cloning. Suggested
fix:
--- maypole.orig/lib/Maypole/Model/Base.pm
+++ maypole/lib/Maypole/Model/Base.pm
@@ -12,14 +12,23 @@
shift; # class name not used
my ($coderef, @attrs) = @_;
- $remember{$coderef} = \@attrs;
+ $remember{$coderef} = [$coderef, \@attrs];
# previous version took care to return an empty array, not sure why,
# but shall cargo cult it until know better
return;
}
-sub FETCH_CODE_ATTRIBUTES { @{ $remember{$_[1]} || [] } }
+sub FETCH_CODE_ATTRIBUTES { @{ $remember{$_[1]}->[1] || [] } }
+
+sub CLONE {
+ # re-hash %remember
+ for my $key (keys %remember) {
+ my $value = delete $remember{$key};
+ $key = $value->[0];
+ $remember{$key} = $value;
+ }
+}
sub process {
my ( $class, $r ) = @_;
-- END --
Ben.
--
Ben Hutchings
Lowery's Law:
If it jams, force it. If it breaks, it needed replacing anyway.
Message body not shown because it is not plain text.