[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Meaning of "surrogate parent" comment in back-shell/fork.c



At 09:26 AM 6/7/00 -0400, Kunkel, Ronald Dale (Ron) wrote:
>I am using the shell backend interface and have had some problems with dead
>locking.
>There is a comment in the file fork.c that mentions configuring
>without-threads or
>using a "surrogate" parent. Can someone please explain the meaning of this
>term, 
>as I am unfamiliar with it? Has anyone implemented a solution using
>pthread_atfork()?

fork() and threads don't mix well, at least not with POSIX thread
semantics.  pthread_atfork() provides limited capabilities, but only
works if you track each and every resource held by every thread
(include through library calls).  There are alternatives.

1) If possible, call fork() before any pthread call.  In this case,
   we're way too deep in threads.
2) Use a surrogate parent model.

Using this model, slapd would fork a child process before creating
any threads (ie: at initialization time) to serve as a "surrogate"
parent.  Then when back-shell wants to create a child process it
would have the "surrograte" do the fork on its behalf.

There are a number of ways this could be implemented... but that's
another discussion... (for the openldap-devel list).

	Kurt