This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Help: shutdown(..., SHUT_WR) on TCP sockets
- From: Florian Weimer <fweimer at redhat dot com>
- To: Sergey Organov <sorganov at gmail dot com>
- Cc: libc-help at sourceware dot org
- Date: Fri, 17 May 2019 11:52:57 +0200
- Subject: Re: Help: shutdown(..., SHUT_WR) on TCP sockets
- References: <qblfrh$4m4i$1@blaine.gmane.org>
* Sergey Organov:
> Hello,
>
> I've got a few problems properly closing TCP sockets on GLIBC/Linux/ARM,
> and getting to the manual only added to the overall confusion.
>
> First, the manual[*] doesn't even mention SHUT_WR, etc. constants,
> instead it has raw numbers:
>
> The argument HOW specifies what action to perform:
>
> '0'
> Stop receiving data for this socket. If further data arrives,
> reject it.
>
> [...]
>
>
> That seems quite outdated.
>
> 2. The SHUT_WR (=1) specification seems to be plain wrong:
>
> '1'
> Stop trying to transmit data from this socket. Discard any
> data waiting to be sent. Stop looking for acknowledgement of
> data already sent; don't retransmit it if it is lost.
>
>
> Discarding data contradicts both the intended usage of the feature and
> the actual behavior (as observed by testing the state of the socket
> write queue using 'ioctl(fd, TIOCOUTQ, &val)' call before and after
> shutdown()).
>
> Given the above, could please somebody clarify what is the actual
> intended behavior of shutdown(..., SHUT_WR) on GLIBC/Linux nowadays?
Thanks for raising the issue. I posted a patch to libc-alpha.
What you saw is the expected behavior for the mainline Linux kernel.
Since this is what distributions ship, I think it makes sense to
document it.
Thanks,
Florian