From d978bbea8a78ef0a39dbf75c4e62cd05c5a8ddc5 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Thu, 16 Jan 2014 13:45:41 +0000 Subject: [PATCH] Simplify wait/nowait code, eventually killing last remnant of historical mbuf(9) allocator flag. Sponsored by: Nginx, Inc. --- sys/kern/uipc_socket.c | 39 +++++++++++++++++++-------------------- sys/sys/mbuf.h | 8 -------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 9da42057f9e..52c244e97aa 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1723,28 +1723,27 @@ dontblock: 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; diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index bc2924ad656..e8caa3897e3 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -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