From owner-freebsd-current Sun May 19 8:59:12 2002 Delivered-To: freebsd-current@freebsd.org Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by hub.freebsd.org (Postfix) with ESMTP id 1015E37B406; Sun, 19 May 2002 08:59:08 -0700 (PDT) Received: by elvis.mu.org (Postfix, from userid 1192) id DBDB3AE162; Sun, 19 May 2002 08:59:07 -0700 (PDT) Date: Sun, 19 May 2002 08:59:07 -0700 From: Alfred Perlstein To: Robert Watson Cc: current@FreeBSD.org Subject: Re: Bug in -current flock()? Message-ID: <20020519155907.GS20683@elvis.mu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.27i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Robert Watson [020519 07:30] wrote: > > I don't know much (anything) about the advisory locking code, but was > puzzled to see the following at the bottom of the flock() system call code > in kern_descrip.c: > > if (uap->how & LOCK_EX) > lf.l_type = F_WRLCK; > else if (uap->how & LOCK_SH) > lf.l_type = F_RDLCK; > else { > error = EBADF; > goto done2; > } > FILE_LOCK(fp); > fp->f_flag |= FHASLOCK; > FILE_UNLOCK(fp); > error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, > (uap->how & LOCK_NB) ? F_FLOCK : F_FLOCK | F_WAIT); > done2: > fdrop(fp, td); > mtx_unlock(&Giant); > return (error); > } > > My reading of that is that the fp->f_flag field will be unconditionally > updated to include FHASLOCK, even if VOP_ADVLOCK() returns an error. Is > this correct? Yes, but it's harmless. All that may happen is that at exit/close time possibly calling VOP_ADVLOCK to unlock the file when it doesn't need to. -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message