From owner-freebsd-current Thu Jul 18 12: 8:20 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9BAA637B400; Thu, 18 Jul 2002 12:08:17 -0700 (PDT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57F4C43E31; Thu, 18 Jul 2002 12:08:17 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.5/8.12.4) with ESMTP id g6IJ8HCV019432; Thu, 18 Jul 2002 12:08:17 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.5/8.12.4/Submit) id g6IJ8H5k019431; Thu, 18 Jul 2002 12:08:17 -0700 (PDT) (envelope-from dillon) Date: Thu, 18 Jul 2002 12:08:17 -0700 (PDT) From: Matthew Dillon Message-Id: <200207181908.g6IJ8H5k019431@apollo.backplane.com> To: John Baldwin Cc: current@FreeBSD.ORG Subject: Re: Questions about kern_descrip.c References: Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG :> The issue with dup2() was a race against open() or close() :> I believe, where dup2() could potentially dup into a :> descriptor that open() was about to use. Unfortunately, it :> does appear that dup() has the same issue. :> :> fdalloc() does not reserve the descriptor number it :> returns, it simply finds a free slot and says 'this :> index is a free slot'. Even in the latest -current, :> fdalloc() releases the fdp lock when it goes to :> MALLOC so the race appears to still be present. : :Well, execpt that if we malloc(), we then grab the lock and loop :again. If we return without an error, it means we reserved a slot :while holding a lock and returned with the lock still held. : :-- : :John Baldwin <>< http://www.FreeBSD.org/~jhb/ Yes, that makes sense... and it would be fairly trivial optimization to make. I suppose you could have fdalloc() return EAGAIN or something like that to indicate that it had to cycle the lock. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message