Date: Wed, 09 Jun 2004 11:33:05 +0200 From: "Poul-Henning Kamp" <phk@phk.freebsd.dk> Cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_proc.c Message-ID: <53418.1086773585@critter.freebsd.dk> In-Reply-To: Your message of "Wed, 09 Jun 2004 09:29:08 -0000." <200406090929.i599T8h6065944@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53418.1086773585>