[Spread-users] Question about thread-safety

James Rauser j.rauser at science-factory.com
Wed Jun 18 04:09:52 EDT 2003


"Theo E. Schlossnagle" wrote:
> > 
> For now, the duct-tape approach would be (for multiprocesses).  This approach
> works well for other such suffering libraries like Oracle's OCI C libs:
> 
> connect(&mbox);
> prefork stuff;
> disconnect(mbox);
> ret = fork();
> if(ret > 0) {
>    connect(&mbox);
>    do parent;
> } else if(ret == 0) {
>    connect(&mbox);
>    do child;
> } else {
>    perror("fork");
>    handle error;
> }

I rejected this solution because most of my clients also receive membership
messages and this causes each client to receive two such messages for each
fork().
 
> More permanent duct-tape is as John suggested:
> un-static SP_kill in sp.c and remake you libraries.
> 
> Then:
> connect(&mbox);
> ret = fork();
> if(ret > 0) {
>    do parent;
> } else if (ret == 0) {
>    SP_kill(mbox);
>    connect(&mbox);
> } else {
>    perror("fork");
>    handle error;
> }

I also tried this, but ran into other threading issues; see the archived
thread which ended with the message:

  http://lists.spread.org/pipermail/spread-users/2002-October/001129.html

In the end, the easiest solution was just to dup2() the mbox onto
/dev/null in the child and leave it at that.

Greetings,
Jim


-- 
------------------------------------------------------------------------
Jim Rauser                                          Science Factory GmbH
mailto:j.rauser at science-factory.com                       Unter Käster 1
Tel: +49 221 277 399 204                          50667 Cologne, Germany




More information about the Spread-users mailing list