A
Andrew DeFaria
I have a process I was thinking of making into a multithreaded daemon
that deals with a MySQL database. The thought is that the daemon would
open the database once, then listen for clients. As clients connected
the daemon would fork off a copy of itself and handle the requests. This
would make the process faster because I wouldn't need to open the
database every time a new client wanted service.
However, I've found that once I fork the database handle (obtained
through DBI) is no longer valid. Reading around a little bit I noticed
people saying to reopen or reconnect to the database in the child. Well
that's the very time consuming thing I was trying to avoid!
Does anybody know how to open a MySQL database such that that database
connection can be used in forked children?
that deals with a MySQL database. The thought is that the daemon would
open the database once, then listen for clients. As clients connected
the daemon would fork off a copy of itself and handle the requests. This
would make the process faster because I wouldn't need to open the
database every time a new client wanted service.
However, I've found that once I fork the database handle (obtained
through DBI) is no longer valid. Reading around a little bit I noticed
people saying to reopen or reconnect to the database in the child. Well
that's the very time consuming thing I was trying to avoid!
Does anybody know how to open a MySQL database such that that database
connection can be used in forked children?