Mark Hedges schrieb:
On Wed, 14 Jan 2009, Michael Ludwig wrote:
I want to build a mod_perl2 application using
Sleepycat::DbXml. This is
However, I don't know how to do this. Currently, I'm
trying to set up things in startup.pl (loaded via
PerlPostConfigRequire), store the database environment
handle in a global package variable, and access that from
the PerlContentHandler.
This probably won't work since the filehandle cannot be
shared among mod_perl children.
Thanks for your help, Mark. I'm not sure it's a plain filehandle,
but probably your remark applies anyway.
Your startup.pl script is running before the root apache
process forks into the child processes. Scalars, lists and
hashes will be cloned, but file handles won't, they have to
be opened.
Cloning might not be what the DbEnv, XmlManager and XmlContainer
objects need, or tolerate.
Or, you can use it like this in a handler, essentially the
same thing [as the PerlChildInitHandler]:
package YourResponseHandler;
use strict;
use warnings FATAL => 'all';
use SleepyCat::DbXml qw(simple);
# is this the way it works? i trolled for it...
# where is the manual page?? ugh
Probably not all in place yet.
my $container = XmlContainer->new('/path/to/whatever.xml');
sub handler {
my ($r) = @_;
$container->open(Db::DB_CREATE);
$container->put...
# ...
$container->close(); # ?? not sure how it works
}
I tried this style of initialization. It doesn't solve things.
Depending on how exactly I code this, I get either a SEGV on
startup attempt or when attempting concurrent access to the
application. I also saw this:
*** glibc detected *** free(): invalid pointer: 0x084e6a14 ***
But it's not clear how much time you're going to save. I
don't know how the thing works. You may or may not be able
to call open() from package scope because of locking, are
locks on the sleepycat database serial?
No, it supports multi-process and multi-threaded access.
Good news: I've been offered help. I'll report back once I'll
have attained a successful configuration, or be convinced that
this simply won't work.
Michael Ludwig