On Wed, May 14, 2014 at 4:58 AM, Jérémie Courrèges-Anglas
<[email protected]>wrote:
...
> So here's the diff I came up with:
> - set MSG_TRUNC for atomic protocols only if there is actually a data
> loss
> - drop the remaining mbuf(s) if the protocol is atomic *or* it is an
> empty message
>
> I'm running this, and I can't see the downsides, but I could use eyes
> and comments.
>
> Index: kern/uipc_socket.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/uipc_socket.c,v
> retrieving revision 1.127
> diff -u -p -r1.127 uipc_socket.c
> --- kern/uipc_socket.c 7 Apr 2014 10:04:17 -0000 1.127
> +++ kern/uipc_socket.c 14 May 2014 02:56:09 -0000
> @@ -935,13 +935,15 @@ dontblock:
> }
> }
>
> - if (m && pr->pr_flags & PR_ATOMIC) {
> + if (m != NULL && m->m_len != 0 && pr->pr_flags & PR_ATOMIC)
> + /* Drop the remaining data later. */
> flags |= MSG_TRUNC;
> - if ((flags & MSG_PEEK) == 0)
> - (void) sbdroprecord(&so->so_rcv);
> - }
> +
<bikeshed>With the comment 'inside' the 'if', I would probably keep the
braces.</bikeshed>
if ((flags & MSG_PEEK) == 0) {
> - if (m == NULL) {
> + if (m != NULL) {
> + if (m->m_len == 0 || pr->pr_flags & PR_ATOMIC)
> + sbdroprecord(&so->so_rcv);
> + } else {
> /*
> * First part is an inline SB_EMPTY_FIXUP().
> Second
> * part makes sure sb_lastrecord is up-to-date if
>
>