From owner-freebsd-arch@FreeBSD.ORG Thu Dec 21 17:15:49 2006 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 73F2516A412; Thu, 21 Dec 2006 17:15:49 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id F2AA613C462; Thu, 21 Dec 2006 17:15:48 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id kBLGeV9x020613; Thu, 21 Dec 2006 11:40:31 -0500 (EST) Date: Thu, 21 Dec 2006 11:40:31 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Robert Watson In-Reply-To: <20061221152115.U83974@fledge.watson.org> Message-ID: References: <32874.1165905843@critter.freebsd.dk> <20061220153126.G85384@fledge.watson.org> <200612210820.09955.davidxu@freebsd.org> <4589E7D2.9010608@ironport.com> <20061221152115.U83974@fledge.watson.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Thu, 21 Dec 2006 11:40:31 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: Julian Elischer , David Xu , freebsd-arch@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2006 17:15:49 -0000 On Thu, 21 Dec 2006, Robert Watson wrote: > On Wed, 20 Dec 2006, Julian Elischer wrote: > >>> I think the main concern is if we will record every thread using a fd, >>> that means, when you call read() on a fd, you record your thread pointer >>> into the fd's thread list, when one wants to close the fd, it has to >>> notify all the threads in the list, set a flag for each thread, the flag >>> indicates a thread is interrupted because the fd was closed, when the >>> thread returns from deep code path to read() syscall, it should check the >>> flag, and return EBADF to user if it was set. whatever, a reserved signal >>> or TDF_INTERRUPT may interrupt a thread. but since there are many file >>> operations, I don't know if we are willing to pay such overheads to every >>> file syscall, extra locking is not welcomed. >> >> I think you are only intersted in treads that are sleeping.. so you allow a >> sleeping thread to save a pointer to the fd (or whatever) on which it is >> sleeping, along with the sleep address. >> >> items that are not sleeping are either already returning, or are going to >> sleep, in which case they can check at that time. > > Hence my question about select and poll: should they throw an exception state > when a file descriptor is closed out from under them? They often sleep on > hundreds or thousands of file descriptors, and not just one. Yes, I would think so. Solaris behaves this way also, although there seems to be a bug in Solaris 8 (version tested) in that select() returns -1 but errno isn't properly set (it is 0). -- DE