mod_perl2 + fork + DBI = Chaos

Tosh Cooey <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Organization Twelve Hundred Group LLC
Message-ID <[email protected]>
My application-from-hell is doing odd things probably related to the 
above storms and culminating in a perfect storm.

Can anyone point me to resources outlining the best way to use the 
combination in the subject line?

There seems to be many ways of accomplishing specifics but very little 
generic methodologies which can be adapted.

What I'm trying to do is in a nutshell:

##########
my $object_with_DBH = new My::DataObject;

... do stuff...

if ($pid = fork) {
	... parent things ...
} elsif (defined $pid) {
   ... close STDhandles ...

   my $data = $object_with_DBH->SQL('do SQL stuff with old connection');

   exec 'things from $data';

   CORE::exit(0);
}
##########

I've tried Stas' code but that's for MP1, and with $DBI->clone(), and 
playing with "setsid" from POSIX and on... There seems to be no love 
between mod_perl2, fork, and DBI.

On a side, but possibly related note, my browser is sending a POST 
request which results in the FORK above and the parent then sends a 302 
redirect with some status variables.  This works fine, except between 
the POST and the 302 GET is another POST to the same URI which results 
in a 500 error, here's the log:

"POST /tosh/mailfile.pl HTTP/1.1" 302 282

"POST /tosh/mailfile.pl HTTP/1.1" 500 424

"GET /tosh/index.pl?message=Notice%20sent HTTP/1.1" 200 4309

The browser only seems to see the middle one, the 500.  I'm certain this 
is related to my poor forking above but I have no idea why.  Are there 
any tools for Firefox that will let me track every connection it's 
making and why?

Thanks again for any help with my Frankenstein monster...

Tosh

-- 
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.