From owner-freebsd-hackers Tue Apr 20 11:19: 3 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mercury.inktomi.com (mercury.inktomi.com [209.1.32.126]) by hub.freebsd.org (Postfix) with ESMTP id BB1FB14FE9 for ; Tue, 20 Apr 1999 11:19:01 -0700 (PDT) (envelope-from jplevyak@inktomi.com) Received: from proxydev.inktomi.com (proxydev.inktomi.com [209.1.32.44]) by mercury.inktomi.com (8.9.1a/8.9.1) with ESMTP id LAA01197; Tue, 20 Apr 1999 11:16:41 -0700 (PDT) Received: (from jplevyak@localhost) by proxydev.inktomi.com (8.8.5/8.7.3) id LAA12296; Tue, 20 Apr 1999 11:16:34 -0700 (PDT) Message-ID: <19990420111634.D10370@proxydev.inktomi.com> Date: Tue, 20 Apr 1999 11:16:34 -0700 From: John Plevyak To: Luoqi Chen , hackers@FreeBSD.ORG, jplevyak@inktomi.com Subject: Re: flock + kernel threads bug References: <199904201759.NAA15897@lor.watermarkgroup.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i In-Reply-To: <199904201759.NAA15897@lor.watermarkgroup.com>; from Luoqi Chen on Tue, Apr 20, 1999 at 01:59:58PM -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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