You wouldn't have a problem with SilkJS. Something like this works:
(function() {
var handle = null;
...
function connect() {
if (!handle) {
handle = mysql.connect();
}
}
...
exports.connect = connect;
}());
Every child would get a null handle at fork() time. So each child would call
your connect() method and get a new handle.
That's kinda rough, but I think you get the idea.
The handle variable could be a global variable, too, since those get cloned by
fork().
On Jun 26, 2012, at 11:45 AM, Stephan Beal wrote:
> Tue, Jun 26, 2012 at 8:26 PM, Michael Schwartz <[email protected]> wrote:
> "You can also encounter this error with applications that fork child
> processes, all of which try to use the same connection to the MySQL server.
> This can be avoided by using a separate connection for each child process."
>
> Plus, I'd think that socket would become a significant bottleneck, since
> you'd be talking basically to a single thread in the MySQL server...
>
> That's the crux of my problem: i write almost exclusively library-level code
> and i can't enforce this type of policy on downstream clients in any useful
> way. So my only defense against such things is either not providing such a
> feature (let the client do it) or documenting them with "big fat hairy
> warning" labels :/.
>
> --
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
> http://gplus.to/sgbeal
>
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users