Fix a bug where MSG_TRUNC was not returned in all necessary cases for

SOCK_DGRAM socket. MSG_TRUNC was only returned when some mbufs could
not be copied to the application. If some data was left in the last
mbuf, it was correctly discarded, but MSG_TRUNC was not set.

Reviewed by: bz
MFC after: 3 weeks
This commit is contained in:
Michael Tuexen 2010-08-07 17:57:58 +00:00
parent 3e9b610706
commit af9ba7d805

View File

@ -2236,7 +2236,12 @@ soreceive_dgram(struct socket *so, struct sockaddr **psa, struct uio *uio,
m_freem(m);
return (error);
}
m = m_free(m);
if (len == m->m_len)
m = m_free(m);
else {
m->m_data += len;
m->m_len -= len;
}
}
if (m != NULL)
flags |= MSG_TRUNC;