From owner-p4-projects@FreeBSD.ORG Tue Aug 15 15:50:04 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9003F16A4EB; Tue, 15 Aug 2006 15:50:04 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4463C16A4E6; Tue, 15 Aug 2006 15:50:04 +0000 (UTC) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.10.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 21CF643D72; Tue, 15 Aug 2006 15:50:01 +0000 (GMT) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (localhost [127.0.0.1]) by eva.fit.vutbr.cz (envelope-from xdivac02@eva.fit.vutbr.cz) (8.13.7/8.13.7) with ESMTP id k7FFnucc060804 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 15 Aug 2006 17:49:56 +0200 (CEST) Received: (from xdivac02@localhost) by eva.fit.vutbr.cz (8.13.7/8.13.3/Submit) id k7FFnuGB060803; Tue, 15 Aug 2006 17:49:56 +0200 (CEST) Date: Tue, 15 Aug 2006 17:49:56 +0200 From: Divacky Roman To: John Baldwin Message-ID: <20060815154956.GB60482@stud.fit.vutbr.cz> References: <200608151407.k7FE7Lj5095567@repoman.freebsd.org> <200608151127.54902.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200608151127.54902.jhb@freebsd.org> User-Agent: Mutt/1.4.2i X-Scanned-By: MIMEDefang 2.54 on 147.229.10.14 Cc: Roman Divacky , Perforce Change Reviews Subject: Re: PERFORCE change 104029 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Aug 2006 15:50:04 -0000 On Tue, Aug 15, 2006 at 11:27:54AM -0400, John Baldwin wrote: > On Tuesday 15 August 2006 10:07, Roman Divacky wrote: > > http://perforce.freebsd.org/chv.cgi?CH=104029 > > > > Change 104029 by rdivacky@rdivacky_witten on 2006/08/15 14:06:41 > > > > Protect against racing concurent creation in futex_get() > > > > Pointed out by: jhb > > > > Affected files ... > > > > .. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#24 > edit > > > > Differences ... > > > > > ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#24 > (text+ko) ==== > > > > @@ -342,13 +342,13 @@ > > if (locked == FUTEX_UNLOCKED) > > FUTEX_UNLOCK; > > > > + if (locked == FUTEX_UNLOCKED) > > + FUTEX_LOCK; > > Looks like you should collapse the lock/unlock. However, it's probably best > to use mutexes instead of sx locks, and to instead do something like this: the lock here IS a mutex... > lock(); > if (item in list) { > item->ref++; > unlock(); > return (item); > } > unlock(); > > new_item = new_item(); > > lock(); > if (item in list) { > item->ref++; > unlock(); > free(new_item); > return (item); > } > insert new_item > new_item->ref++; > unlock(); > return (new_item) isnt this exactly what I am doing in later revision?