On Sun, 29 Sep 2002 15:44:08 -0600, Sterin, Ilya spaketh:
>1. You can send it to the list and ask for suggestions
>(recommended)

Sounds like a plan. Re-submitted, with change of subject:

Under the category Miscellaneous, I plan to enter the following FAQ on Saturday Oct 5. 
Please review and critique before then. Thank you.

Q: How do I share a database handle between a parent and its child process? ���

A: You don't. You give the child enough information to open its own connection and let 
it do so. There are two prime reasons for not sharing connections between parent and 
child processes: ���

1) There is no guarantee that the client libraries that talk to the database can 
handle two processes "talking" to the same connection.

2) The DBI connection handle may hold data that relates to the state of the 
connection. Once the parent and the child are separated, you have two different data 
structures in different memory spaces. Changes made to one are not automatically made 
to the other and can leave the handles in an inconsistent state. �

Q: How do I share a database handle between threads of a single process?

A: Carefully. You share a database connection in the same manner as you share any 
other piece of data, carefully locking the handle before accessing it and releasing it 
after accessing it. HOWEVER, before you can use a particular DBD:: module in a 
threaded environment, you must determine if the underlying client libraries are thread 
safe.

Comments?

--
Matthew O. Persico


Reply via email to