DBI-Informix-0.62 and forking
Posted in 1999
Topics: Platform-Specific Issues, Versions, Editions & End-of-Life
Hi everyone, I am using perl module DBI-Informix-0.62. The database is IDS 7.23_UC1 on Solaris 2.6. Perl version is 5.005_02. I have written a simple perl sockets server that forks and uses the DBI to process the request. The first time it forks no problem. On the second client connection and fork the $dbh->prepare($sql) never returns. Any thoughts as to what might cause this? I can fix the problem by pre- forking server children with each having their own handle to the DBI, but I would prefer an easier solution if one exists. Thanks in advance. Sorry if posting to wrong newsgroup (comp.databases.informix) for module question. ---------------- Ted Slusser tslusser@bigfoot.com Sent via Deja.com http://www.deja.com/ Before you buy.
On Thu, 02 Dec 1999 16:23:33 GMT, tslusser@bigfoot.com wrote: >I have written a simple perl sockets server that forks and uses the DBI >to process the request. The first time it forks no problem. On the >second client connection and fork the $dbh->prepare($sql) never returns. > >Any thoughts as to what might cause this? I can fix the problem by pre- >forking server children with each having their own handle to the DBI, >but I would prefer an easier solution if one exists. I wrote my upd_stats utility (shameless plug: available at http://www.iiug.org ) so that it forks some children, but each child makes its own connection to the database. I thought about having the parent make the connection and trying to fork it, but it didn't really sound like a safe & stable thing to do so I never actually tried. Cheers, Douglas Wilson
Douglas Wilson wrote: > On Thu, 02 Dec 1999 16:23:33 GMT, tslusser@bigfoot.com wrote: > > >I have written a simple perl sockets server that forks and uses the DBI > >to process the request. The first time it forks no problem. On the > >second client connection and fork the $dbh->prepare($sql) never returns. > > > >Any thoughts as to what might cause this? I can fix the problem by pre- > >forking server children with each having their own handle to the DBI, > >but I would prefer an easier solution if one exists. > > I wrote my upd_stats utility (shameless plug: available at > http://www.iiug.org ) so that it forks some children, but each > child makes its own connection to the database. I thought about > having the parent make the connection and trying > to fork it, but it didn't really sound like a safe & stable thing to do so I > never actually tried. Good. It wasn't safe, sensible or sane to use the parent to connect and then fork. It will not work reliably if you try to use a connection created in the parent process. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.62 -- see http://www.perl.com/CPAN #include <disclaimer.h>
tslusser@bigfoot.com wrote: > Hi everyone, I am using perl module DBI-Informix-0.62. The database is > IDS 7.23_UC1 on Solaris 2.6. Perl version is 5.005_02. > > I have written a simple perl sockets server that forks and uses the DBI > to process the request. The first time it forks no problem. On the > second client connection and fork the $dbh->prepare($sql) never returns. > > Any thoughts as to what might cause this? I can fix the problem by pre- > forking server children with each having their own handle to the DBI, > but I would prefer an easier solution if one exists. Do you create the database connection before or after you do the fork? If you do it beforehand, then you are in trouble -- it won't work reliably. If you create the database connection in the child after the fork, then there should be no problem. These rules apply to ESQL/C, too. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.62 -- see http://www.perl.com/CPAN #include <disclaimer.h>