cmac has asked for the wisdom of the Perl Monks concerning the following question:
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.use DB_File; my @dbs; # array of hash references my @dbModTime; # mod times of db files my @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 < @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] . ": $!"); } }
Making only the changes above makes perl complain "Invalid value for shared scalar" about the $dbs[$db] = {}; line. This error message can be fixed as follows:use threads; use threads::shared; my @dbs :shared; # array of hash references my @dbModTime :shared; # mod times of db files
Unfortunately, when this is done the DBs look empty, and the log notices for each DB show "0 entries".for ($db = 0; $db < @dbfn; $db++) { $dbs[$db] = shared_clone({}); 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] . ": $!"); $s->log->notice ($dbfn[$db]." has " .scalar(keys(%{$dbs[$db]}))." entries"); }
in error_log and the following on the terminal:httpd in free(): error: chunk is already free
I guess not having databases is better. I've tried using @dbs as an array of references to named, shared hashes: also no database content. The 'worker' and 'event' MPMs work identically w/r/t this problem.Abort trap (core dumped) Error invoking apachectl start command
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem porting to threaded mode
by tilly (Archbishop) on Jan 01, 2009 at 11:45 UTC | |
by Anonymous Monk on Jan 01, 2009 at 19:33 UTC | |
|
Re: problem porting to threaded mode
by monarch (Priest) on Jan 01, 2009 at 23:09 UTC |