From owner-freebsd-current Thu Jul 18 14:17:59 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 23A4C37B400; Thu, 18 Jul 2002 14:17:57 -0700 (PDT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id AEA7F43E64; Thu, 18 Jul 2002 14:17:56 -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 g6ILHuCV020396; Thu, 18 Jul 2002 14:17:56 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.5/8.12.4/Submit) id g6ILHuFr020395; Thu, 18 Jul 2002 14:17:56 -0700 (PDT) (envelope-from dillon) Date: Thu, 18 Jul 2002 14:17:56 -0700 (PDT) From: Matthew Dillon Message-Id: <200207182117.g6ILHuFr020395@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 :>:-- :>: :>: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. : :But it doesn't really matter if we cycle the lock. What I described :is the current behavior, btw. : :-- : :John Baldwin <>< http://www.FreeBSD.org/~jhb/ Well, the original code for dup2() looped to ensure that the source descriptor number was still a valid descriptor. Why the dup() code doesn't do this I'm not sure, but I think it needs to. If you cycle the locks and do not retry, someone else could get in and close() the source descriptor and dup2() will not return an error when it should. Also, do_dup() assumes that the source descriptor is non-NULL. If dup2() (and dup()) do not retry then do_dup() can wind up getting called with fd_ofiles[old] NULL (race against another thread close()ing or dup2()ing over the original descriptor). If I remember right, a dup2()/dup2() race was one of the problems being explicitly solved by this commit. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message