SO_LINGER + shutdown(2)

Louis Mamakos louie at transsys.com
Fri May 1 16:51:51 UTC 2009


On May 1, 2009, at 6:11 AM, Poul-Henning Kamp wrote:

>
> I was somewhat surprised to see that calling shutdown(SHUT_WR) on
> a TCP socket with SO_LINGER set {.l_onoff = 1, .l_linger = 0} does
> not in fact flush the send queue orderly, but immediately RST's the
> connection.
>
> I realize this is an issue for the Dept. of deep TCP arcanæ and not
> something to be changed lightly, so consider this more of an
> observation than bug report.
>

Setting aside for the moment what applications might rely on this
behavior, this seems unexpected and perhaps wrong to me.  The intent
of the shutdown() system call in this instance ought to be to indicate
that the local end of the connection has no additional data to
transmit to the remote TCP peer.  But it ought to continue to allow
additional data to be read from the connection.  Sending a reset
segment to the far end will hardly enable that behavior.  The remote
TCP will abandon the connection and there will be no further data
forthcoming from it (aside from what might be in flight.)

If the local TCP connection has already received a FIN segment from
the far end and is in CLOSEWAIT state, then perhaps that's a bit of
a different animal..

louie


More information about the freebsd-net mailing list