Simplify wait/nowait code, eventually killing last remnant of
historical mbuf(9) allocator flag. Sponsored by: Nginx, Inc.
This commit is contained in:
parent
529a68392a
commit
63cf6debb3
@ -1723,28 +1723,27 @@ soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio,
|
||||
moff += len;
|
||||
else {
|
||||
if (mp != NULL) {
|
||||
int copy_flag;
|
||||
|
||||
if (flags & MSG_DONTWAIT)
|
||||
copy_flag = M_NOWAIT;
|
||||
else
|
||||
copy_flag = M_WAIT;
|
||||
if (copy_flag == M_WAITOK)
|
||||
if (flags & MSG_DONTWAIT) {
|
||||
*mp = m_copym(m, 0, len,
|
||||
M_NOWAIT);
|
||||
if (*mp == NULL) {
|
||||
/*
|
||||
* m_copym() couldn't
|
||||
* allocate an mbuf.
|
||||
* Adjust uio_resid back
|
||||
* (it was adjusted
|
||||
* down by len bytes,
|
||||
* which we didn't end
|
||||
* up "copying" over).
|
||||
*/
|
||||
uio->uio_resid += len;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
SOCKBUF_UNLOCK(&so->so_rcv);
|
||||
*mp = m_copym(m, 0, len, copy_flag);
|
||||
if (copy_flag == M_WAITOK)
|
||||
*mp = m_copym(m, 0, len,
|
||||
M_WAITOK);
|
||||
SOCKBUF_LOCK(&so->so_rcv);
|
||||
if (*mp == NULL) {
|
||||
/*
|
||||
* m_copym() couldn't
|
||||
* allocate an mbuf. Adjust
|
||||
* uio_resid back (it was
|
||||
* adjusted down by len
|
||||
* bytes, which we didn't end
|
||||
* up "copying" over).
|
||||
*/
|
||||
uio->uio_resid += len;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m->m_data += len;
|
||||
|
@ -465,14 +465,6 @@ struct mbuf {
|
||||
#define MT_NOINIT 255 /* Not a type but a flag to allocate
|
||||
a non-initialized mbuf */
|
||||
|
||||
/*
|
||||
* Compatibility with historic mbuf allocator.
|
||||
*/
|
||||
#define MBTOM(how) (how)
|
||||
#define M_DONTWAIT M_NOWAIT
|
||||
#define M_TRYWAIT M_WAITOK
|
||||
#define M_WAIT M_WAITOK
|
||||
|
||||
/*
|
||||
* String names of mbuf-related UMA(9) and malloc(9) types. Exposed to
|
||||
* !_KERNEL so that monitoring tools can look up the zones with
|
||||
|
Loading…
Reference in New Issue
Block a user