Pre-fork and post-fork callback infrastructure ...

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu May 7 12:42:32 MDT 2015


On Thu, May 07, 2015 at 11:27:03AM -0700, Richard Sharpe wrote:
> On Thu, May 7, 2015 at 6:30 AM, Volker Lendecke
> <Volker.Lendecke at sernet.de> wrote:
> > On Wed, May 06, 2015 at 03:10:46PM -0700, Richard Sharpe wrote:
> >> Hi folks,
> >>
> >> I encountered a problem with the Zookeeper work I did a while ago
> >> because the Zookeeper client library is not fork safe. I had to hack a
> >> bunch of code in to reinit the connection to the Zookeeper server in
> >> each child.
> >>
> >> I notice that we already have reinit_after_fork and wondered whether
> >> we should have some standard infrastructure for where things need to
> >> be reinitialized after a fork.
> >>
> >> The sort of thing I am thinking of is some registration routines that
> >> allows a subsystem to register:
> >>
> >> 1. A pre-fork callback. This would be called in the parent just before
> >> the fork and passed an opaque pointer to a private data structure.
> >>
> >> 2. A post-fork callback that would be called in the parent and the
> >> child and passed the response from fork and an opaque pointer.
> >
> > man pthread_atfork
> 
> That's nice but I was not doing any forking ... the problems are
> related to the assumptions made by the Zookeeper library.

Hmm. You were asking for pre-fork and post-fork hooks.
That's what pthread_atfork gives you.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list