|
|
sybperl-l Archive
Up Prev Next
From: Tim Holt <holt at roguewave dot com>
Subject: Sybperl in a fork'ed process?
Date: May 20 1998 4:27PM
Greetings all...
I need a little group confirmation of my theory here...
BACKGROUND
I've got a process (a CGI script) which establishes a connection to a
DB, does some initial processing & DB access to give proper feedback to
the page viewer. It also has to do some subsequent SQL to update some
records. I don't want to make the web user wait for the subsequent
processing to take place, so I fork off a process.
QUESTION
What's the state of a connection that's been forked? Here's a code
sample. Sybperl is "under" a module I use.
# --- Initialize the connection, get customer info from id
&Sql::initialize("mydb", "dbfoo", "user", "passwd");
&Sql::getrow ("mydb", "customer", "*", "WHERE id=$cid", \%customer);
print "Howdy $customer{name}! \n";
# --- We're all done now w/customer info for the CGI. Now
# --- spawn of a process to do further work that involves no
# --- output to the person viewing this CGI script.
unless ($pid=fork()) {
# --- Call sproc to record sales incident
$sproc = "eRWWebAppendSalesIncident";
$params{"IncidentId"} = $lastIncident;
# --- This should be the protected page that they're about to go
$params{"Item"} = "\"".$ENV{"SCRIPT_NAME"}.$ENV{"PATH_INFO"}."\"";
&Sql::getsproc ($dbname, $sproc, %params, \%out);
&Sql::results($dbname);
}
I seem to get odd errors (like "DBPROCESS is dead or not enabled")
SOMETIMES (not always) inside the fork'ed code. So, here's a refined
question: can I depend on the db connection (the $dbh that's maintained
by my Sql module) to be around? Won't the first process that quits
terminate the connection and leave the second one in an undefined state?
I know that Sybperl drops the connection when the $dbh goes out of
scope, but is this the same thing?
Thanks for your input on this vexing problem.
Tim Holt, (one of the) Webmaster(s)
Rogue Wave Software
|