From owner-cvs-all@FreeBSD.ORG Wed Jun 9 17:43:50 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9CCD516A4CE; Wed, 9 Jun 2004 17:43:49 +0000 (GMT) Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6BB4843D1F; Wed, 9 Jun 2004 17:43:48 +0000 (GMT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([24.7.73.28]) by comcast.net (sccrmhc12) with ESMTP id <20040609174235012002gmvae>; Wed, 9 Jun 2004 17:42:36 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id KAA57994; Wed, 9 Jun 2004 10:42:36 -0700 (PDT) Date: Wed, 9 Jun 2004 10:42:35 -0700 (PDT) From: Julian Elischer To: Doug Rabson In-Reply-To: <1086798299.12306.3.camel@builder02.qubesoft.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: Poul-Henning Kamp cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_proc.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 17:43:50 -0000 On Wed, 9 Jun 2004, Doug Rabson wrote: > On Wed, 2004-06-09 at 10:33, Poul-Henning Kamp wrote: > > In message <200406090929.i599T8h6065944@repoman.freebsd.org>, Poul-Henning Kamp > > writes: > > > > > > Modified files: > > > sys/kern kern_proc.c > > > Log: > > > Fix a race in destruction of sessions. > > > > Not to pick on anybody, but this is a perfect example of getting locking > > almost right: > > > > BAD: > > > > LOCK(foo->lock) > > foo->refcount--; > > UNLOCK(foo->lock) > > if (foo->refcount == 0) > > destroy(foo); > > > > GOOD: > > > > LOCK(foo->lock) > > i = --foo->refcount; > > UNLOCK(foo->lock) > > if (i == 0) > > destroy(foo); > > Isn't there still a race in the GOOD case here if somone takes a new > reference, incrementing refcount after the UNLOCK(foo->lock)? if you had the only reference, then how didi the other party get it? > > >