Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Oct 2013 10:48:27 +0100
From:      Sebastian Huber <sebastian.huber@embedded-brains.de>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: soo_close() vs. filt_soread()
Message-ID:  <5270D5EB.4060004@embedded-brains.de>
In-Reply-To: <20131029222508.GA59496@kib.kiev.ua>
References:  <526F8F58.1090307@embedded-brains.de> <20131029222508.GA59496@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5270D5EB.4060004>