Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Sep 2005 13:16:46 +0100 (BST)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Maxim Konovalov <maxim@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/kern uipc_socket.c
Message-ID:  <20050915130901.R75005@fledge.watson.org>
In-Reply-To: <200509151145.j8FBjbAU070614@repoman.freebsd.org>
References:  <200509151145.j8FBjbAU070614@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On Thu, 15 Sep 2005, Maxim Konovalov wrote:

> maxim       2005-09-15 11:45:37 UTC
>
>  FreeBSD src repository
>
>  Modified files:
>    sys/kern             uipc_socket.c
>  Log:
>  o Return ENOTCONN when shutdown(2) on non-connected socket.
>
>  PR:             kern/84761
>  Submitted by:   James Juran
>  R-test:         tools/regression/sockets/shutdown
>  MFC after:      1 month

Are you sure this is the right thing to do?  I've seen shutdown used in 
several applications on non-connection-oriented sockets in order to 
indicate no messages will be received, so not to allow received packets to 
consume space.  Typical use is in the context of a raw IP or IPv6 socket, 
where raw packets will be sent but never received, and the socket will 
otherwise collect the normal random network detrious.

For example, rtsold(8) uses shutdown(2) on its IPv6 raw socket to indicate 
it is send-only, so received packets should not be stored in the socket 
buffer since they will never be read.  It does, however, contain the not 
unusual bug that it is called with an argument of 0, assuming that that 
will be the value SHUT_RD.  I'm fairly sure we used to have other examples 
of shutdown(2) being used in this way in the tree but don't see any others 
in a casual glance.

While POSIX mentions behavior for full-duplex connections, it does not 
specify for sockets that are not connection-oriented, so as I read it, the 
behavior we provide is permitted.

Robert N M Watson



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