Date: Tue, 20 Apr 1999 11:16:34 -0700 From: John Plevyak <jplevyak@inktomi.com> To: Luoqi Chen <luoqi@watermarkgroup.com>, hackers@FreeBSD.ORG, jplevyak@inktomi.com Subject: Re: flock + kernel threads bug Message-ID: <19990420111634.D10370@proxydev.inktomi.com> In-Reply-To: <199904201759.NAA15897@lor.watermarkgroup.com>; from Luoqi Chen on Tue, Apr 20, 1999 at 01:59:58PM -0400 References: <199904201759.NAA15897@lor.watermarkgroup.com>
next in thread | previous in thread | raw e-mail | index | archive | help
I sumbmitted a bug: kern/10265 it includes a description, a program to repro and a patch. The problem is: releases of file locks depend on the close coming from the same PID as took out the lock. Since kernel threads have different PIDs it is possible for a peer thread to close the file locked by another peer. This results in the file lock not being cleared. The patch does: 1. to use p->p_leader as the PID for file locking, 2. to use p->p_leader->p_flag & P_ADVLOCK to determine if locks are held 3. ensure that p->p_leader does not complete exit1() before all the peers. The full patch is in the bug report. I can send it to you also if that is more convenient. The patch in the bug report is non-optimal since it wakes up the leader for each child instead of the just the last one. If you change the last lines to: if(p->p_leader->p_peers) { q = p->p_leader; while(q->p_peers != p) q = q->p_peers; q->p_peers = p->p_peers; if (!p->p_leader->p_peers) wakeup((caddr_t)p->p_leader); } from + if(p->p_leader->p_peers) { + q = p->p_leader; + while(q->p_peers != p) + q = q->p_peers; + q->p_peers = p->p_peers; + wakeup((caddr_t)p->p_leader); + } This fixes it. Thanx! john On Tue, Apr 20, 1999 at 01:59:58PM -0400, Luoqi Chen wrote: > > Currently, kernel threads + flock does not work. The lock is not > > necessarily released with the multi-threaded application shuts down. > > > Could you elaborate on the problem? > > > I have a patch which I have been running for a month now with no problems; > > who might I send it to to get it reviewed/committed? > > > You could file a bug reports, see send-pr(1). Or you can send to me, I'm > very interested in seeing it. > > > It would greatly simplify the installation of our multi-threaded apps > > on FreeBSD if a kernel patch was not required. Not to mention a > > general increase in confidence to have them work with FreeBSD "out-of-the-box". > > > > john > > > > -- > > John Bradley Plevyak, PhD, jplevyak@inktomi.com, PGP KeyID: 051130BD > > Inktomi Corporation, 1900 S. Norfolk Street, Suite 310, San Mateo, CA 94403 > > W:(650)653-2830 F:(650)653-2889 P:(888)491-1332/5103192436.4911332@pagenet.net > > > -lq > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message -- John Bradley Plevyak, PhD, jplevyak@inktomi.com, PGP KeyID: 051130BD Inktomi Corporation, 1900 S. Norfolk Street, Suite 310, San Mateo, CA 94403 W:(650)653-2830 F:(650)653-2889 P:(888)491-1332/5103192436.4911332@pagenet.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990420111634.D10370>