From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 30 09:48:34 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 64F349EA for ; Wed, 30 Oct 2013 09:48:34 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from mail.embedded-brains.de (host-82-135-62-35.customer.m-online.net [82.135.62.35]) by mx1.freebsd.org (Postfix) with ESMTP id 1E00D21DB for ; Wed, 30 Oct 2013 09:48:33 +0000 (UTC) Received: by mail.embedded-brains.de (Postfix, from userid 65534) id E0C47652CF6; Wed, 30 Oct 2013 10:48:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fidibusdmz X-Spam-Level: X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from [192.168.100.11] (unknown [192.168.100.11]) by mail.embedded-brains.de (Postfix) with ESMTP id ECF2665253A; Wed, 30 Oct 2013 10:48:27 +0100 (CET) Message-ID: <5270D5EB.4060004@embedded-brains.de> Date: Wed, 30 Oct 2013 10:48:27 +0100 From: Sebastian Huber User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Konstantin Belousov Subject: Re: soo_close() vs. filt_soread() References: <526F8F58.1090307@embedded-brains.de> <20131029222508.GA59496@kib.kiev.ua> In-Reply-To: <20131029222508.GA59496@kib.kiev.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Oct 2013 09:48:34 -0000 On 2013-10-29 23:25, Konstantin Belousov wrote: > On Tue, Oct 29, 2013 at 11:35:04AM +0100, Sebastian Huber wrote: [...] >> Are there some means that prevent this >> sequence in a real FreeBSD kernel? > > When file descriptor gets closed, kevent subsystem is notified first > and clears knotes related to the filedescriptor (important, not the > file) being closed. You could see this in the closefp() function calling > knote_fdclose(). Since files are referenced and destroyed only when the > last reference vanishes, and filedescriptor holds a reference on the > file, file (which is socket in your case) cannot go away until knotes > are expunged. > > There are some corner cases, when knotes are really attached to objects > with different life-cycle, like vnodes, but I believe the description > above should be accurate enough for sockets. [...] Thanks for the hints. I missed this knote_fdclose() completely. Similar test cases worked for select() and poll() since they use the file descriptor index. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.huber@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.