1 Jan 2009 06:27
problem porting to threaded mode
<craig <at> animalhead.com>
2009-01-01 05:27:12 GMT
2009-01-01 05:27:12 GMT
Trying to shift our largely mod_perl2 web site to an Apache2 threaded
MPM and perl ithreads.
The following works under the non-threaded prefork MPM:
use DB_File;
my <at> dbs; # array of hash references
my <at> dbModTime; # mod times of db files
my <at> dbfns; # array of database pathnames
# executed before fork into child processes
sub post_config {
my $db;
my $s = $_[3];
# tie the DBs and get their mod times
for ($db = 0; $db < <at> dbfn; $db++) {
$dbs[$db] = {};
tie %{$dbs[$db]}, "DB_File", $dbfn[$db], O_RDONLY
or die ((caller 0)[3]. " can't tie " . $dbfn[$db] . ": $!");
$dbModTime[$db] = (CORE::stat($dbfn[$db]))[9]
or die ((caller 0)[3]. " can't stat " . $dbfn[$db] . ": $!");
} }
The routines that use the databases re-stat the DB files and untie and
re-tie a DB
that has changed. Each child process must do this for itself.
In the threaded environment, any thread within a process may discover
that such
an untie and re-tie is necessary, but such an operation should be
effective
(Continue reading)
RSS Feed