diff options
author | glebius <glebius@FreeBSD.org> | 2013-03-12 12:12:16 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2013-03-12 12:12:16 +0000 |
commit | ce515e6007c76b0ec23c6cce28f5d22c61219656 (patch) | |
tree | 0d024cc422747189d0a97cceae932de9cca805aa /sys/kern/uipc_mbuf.c | |
parent | 8be88fc42e7a1965a9adae2c9b231d96639abd20 (diff) | |
download | FreeBSD-src-ce515e6007c76b0ec23c6cce28f5d22c61219656.zip FreeBSD-src-ce515e6007c76b0ec23c6cce28f5d22c61219656.tar.gz |
The m_extadd() can fail due to memory allocation failure, thus:
- Make it return int, not void.
- Add wait parameter.
- Update MEXTADD() macro appropriately, defaults to M_NOWAIT, as
before this change.
Sponsored by: Nginx, Inc.
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 4606f37..13c9b52 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -255,25 +255,30 @@ m_freem(struct mbuf *mb) * Returns: * Nothing. */ -void +int m_extadd(struct mbuf *mb, caddr_t buf, u_int size, - void (*freef)(void *, void *), void *arg1, void *arg2, int flags, int type) + void (*freef)(void *, void *), void *arg1, void *arg2, int flags, int type, + int wait) { KASSERT(type != EXT_CLUSTER, ("%s: EXT_CLUSTER not allowed", __func__)); if (type != EXT_EXTREF) - mb->m_ext.ref_cnt = (u_int *)uma_zalloc(zone_ext_refcnt, M_NOWAIT); - if (mb->m_ext.ref_cnt != NULL) { - *(mb->m_ext.ref_cnt) = 1; - mb->m_flags |= (M_EXT | flags); - mb->m_ext.ext_buf = buf; - mb->m_data = mb->m_ext.ext_buf; - mb->m_ext.ext_size = size; - mb->m_ext.ext_free = freef; - mb->m_ext.ext_arg1 = arg1; - mb->m_ext.ext_arg2 = arg2; - mb->m_ext.ext_type = type; - } + mb->m_ext.ref_cnt = uma_zalloc(zone_ext_refcnt, wait); + + if (mb->m_ext.ref_cnt == NULL) + return (ENOMEM); + + *(mb->m_ext.ref_cnt) = 1; + mb->m_flags |= (M_EXT | flags); + mb->m_ext.ext_buf = buf; + mb->m_data = mb->m_ext.ext_buf; + mb->m_ext.ext_size = size; + mb->m_ext.ext_free = freef; + mb->m_ext.ext_arg1 = arg1; + mb->m_ext.ext_arg2 = arg2; + mb->m_ext.ext_type = type; + + return (0); } /* |