[Spread-users] after fork: session 'xxx' trying to make session 'yyy' do something

James Rauser j.rauser at science-factory.com
Tue Oct 1 04:38:48 EDT 2002


Hi,

I'm a Spread beginner.  We're using Spread 3.16.2 in a system which
distributes work from a shared queue to to a number of distributed
compute servers.  The servers each join spread groups with the same
name as the queue, and I use the group ordering to designate one as
the "leader".  The leader is responsible for monitoring the queue
and dispatching jobs to the remaining servers.

When a job is dispatched, the server which is running it forks a
new process in which to execute it.  The FD for the spread connection
is (of course) inherited across the fork.  The child needs its own
connection to the spread daemon, so it closes the parent's mbox
(with close(2)), and then calls SP_connect to reconnect.
Schematically:

   parent_mbox = SP_connect("xxx");
   SP_join(parent_mbox, "queue");
   while ( ... ) {
     SP_receive();
     if ( fork() == 0 ) {
        // child process for a new job
        close(parent_mbox);
        child_mbox = SP_connect("yyy");
        SP_join(child_mbox, "queue");
        SP_multicast()
     }
   }

If parent_mbox and child_mbox happen to be assigned the same (numerical)
FD, then the spread daemon produces the error message quoted in the
subject line, where "xxx" and "yyy" are the private names of the parent
and child, respectively, and the child's first attempt to SP_multicast()
dies with error -8: "connection closed by spread".  I can work around
the bug by doing a dummy open() or pipe() call between the close()
and the SP_connect() in the child.

After a quick examination of sp.c, it appears that I don't want to do
an SP_disconnect() in the child, because that actually updates the
membership at the daemon and the parent is not actually disconnecting.
The internal function SP_kill() looks like it does what I want (close
the mbox and update the client-side session table), but it's static and
undocumented.

Suggesstion? Any help would be appreciated.

Thanks, 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