|
Posted by xhoster on March 31, 2008, 1:06 pm
Please log in for more thread options
>
> 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.
On my system it takes less than one millisecond to open a connection
to a MySQL server (located on a different system.) Do you find that
connection time problematic? This is about the same amount of time
it takes to fork in the first place.
> 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.
Yes, true.
> Well
> that's the very time consuming thing
I find that hard to believe.
> 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?
I don't. I rather doubt other people do, either. Maybe your server
should handle requests internally rather than forking.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
|