From owner-cvs-src@FreeBSD.ORG Wed Jun 9 09:33:08 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0769A16A4CE; Wed, 9 Jun 2004 09:33:08 +0000 (GMT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3672C43D1D; Wed, 9 Jun 2004 09:33:07 +0000 (GMT) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.11/8.12.11) with ESMTP id i599X5Jq053419; Wed, 9 Jun 2004 11:33:05 +0200 (CEST) (envelope-from phk@phk.freebsd.dk) From: "Poul-Henning Kamp" In-Reply-To: Your message of "Wed, 09 Jun 2004 09:29:08 -0000." <200406090929.i599T8h6065944@repoman.freebsd.org> Date: Wed, 09 Jun 2004 11:33:05 +0200 Message-ID: <53418.1086773585@critter.freebsd.dk> cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_proc.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 09:33:08 -0000 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); -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.