Date: Thu, 19 Mar 2009 12:00:22 +0800 From: David Xu <davidxu@freebsd.org> To: Kostik Belousov <kostikbel@gmail.com> Cc: Daniel Eischen <deischen@freebsd.org>, David Schultz <das@freebsd.org>, hackers@freebsd.org, Jason Evans <jasone@freebsd.org>, Julian Elischer <julian@elischer.org> Subject: Re: threaded, forked, rethreaded processes will deadlock Message-ID: <49C1C356.9090006@freebsd.org> In-Reply-To: <20090318163222.GE7716@deviant.kiev.zoral.com.ua> References: <4966F81C.3070406@elischer.org> <20090109163426.GC2825@green.homeunix.org> <49678BBC.8050306@elischer.org> <20090116211959.GA12007@green.homeunix.org> <49710BD6.7040705@FreeBSD.org> <20090120004135.GB12007@green.homeunix.org> <20090121230033.GC12007@green.homeunix.org> <Pine.GSO.4.64.0901211831210.4150@sea.ntplx.net> <20090122045637.GA61058@zim.MIT.EDU> <Pine.GSO.4.64.0901220021320.4150@sea.ntplx.net> <20090318163222.GE7716@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
Kostik Belousov wrote: > I looked at the issue once more recently, and I propose the following > much less intrusive patch. It is somewhat hackish, but I think that > it would be good to have this working. Most other Unixes do have > working thread library after the fork. Any objections ? > > diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c > index bc410d1..ae6b9ad 100644 > --- a/lib/libthr/thread/thr_fork.c > +++ b/lib/libthr/thread/thr_fork.c > @@ -173,14 +173,19 @@ _fork(void) > /* Ready to continue, unblock signals. */ > _thr_signal_unblock(curthread); > > - if (unlock_malloc) > + if (unlock_malloc) { > + __isthreaded = 1; > _malloc_postfork(); > + __isthreaded = 0; > + } > > /* Run down atfork child handlers. */ > TAILQ_FOREACH(af, &_thr_atfork_list, qe) { > if (af->child != NULL) > af->child(); > } > + > + THR_UMUTEX_UNLOCK(curthread, &_thr_atfork_lock); ^^^ This line is not needed. > } else { > /* Parent process */ > errsave = errno;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49C1C356.9090006>