From owner-cvs-all@FreeBSD.ORG Wed Jun 9 16:45:30 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 340CA16A4CE; Wed, 9 Jun 2004 16:45:30 +0000 (GMT) Received: from mx.nsu.ru (mx.nsu.ru [212.192.164.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id C722243D1F; Wed, 9 Jun 2004 16:45:29 +0000 (GMT) (envelope-from danfe@regency.nsu.ru) Received: from regency.nsu.ru ([193.124.210.26]) by mx.nsu.ru with esmtp (Exim 4.30) id 1BY6FY-0007AF-HK; Wed, 09 Jun 2004 23:48:28 +0700 Received: from regency.nsu.ru (localhost [127.0.0.1]) by regency.nsu.ru (8.12.10/8.12.10) with ESMTP id i59GjSVf093573; Wed, 9 Jun 2004 23:45:28 +0700 (NOVST) (envelope-from danfe@regency.nsu.ru) Received: (from danfe@localhost) by regency.nsu.ru (8.12.10/8.12.10/Submit) id i59GjSfu093520; Wed, 9 Jun 2004 23:45:28 +0700 (NOVST) (envelope-from danfe) Date: Wed, 9 Jun 2004 23:45:28 +0700 From: Alexey Dokuchaev To: "M. Warner Losh" Message-ID: <20040609164528.GB90103@regency.nsu.ru> References: <200406090929.i599T8h6065944@repoman.freebsd.org> <53418.1086773585@critter.freebsd.dk> <20040609.100413.118633043.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040609.100413.118633043.imp@bsdimp.com> User-Agent: Mutt/1.4.2.1i cc: cvs-src@freebsd.org cc: phk@phk.freebsd.dk 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 16:45:30 -0000 On Wed, Jun 09, 2004 at 10:04:13AM -0600, M. Warner Losh wrote: > In message: <53418.1086773585@critter.freebsd.dk> > "Poul-Henning Kamp" writes: > : 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); > : > > Can you provide a couple of lines about why BAD is BAD and why GOOD > fixes that flaw? That should help others from making this mistake in > the future. Probably even document in developer's handbook, or some related manpage. ./danfe