diff options
author | andre <andre@FreeBSD.org> | 2012-10-28 18:38:51 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2012-10-28 18:38:51 +0000 |
commit | d4bd5c150c587d094626f718ccb56a6504166457 (patch) | |
tree | 7e0d43b433a17a51ee75adf5baa7e95d072a5ad6 | |
parent | ff213d74944d9221c5e7ec192a52a49165208499 (diff) | |
download | FreeBSD-src-d4bd5c150c587d094626f718ccb56a6504166457.zip FreeBSD-src-d4bd5c150c587d094626f718ccb56a6504166457.tar.gz |
Improve m_cat() by being able to also merge contents from M_EXT
mbuf's by doing proper testing with M_WRITABLE().
In m_collapse() replace an incomplete manual check for M_RDONLY
with the M_WRITABLE() macro that also tests for shared buffers
and other cases that make a particular mbuf immutable.
MFC after: 2 weeks
-rw-r--r-- | sys/kern/uipc_mbuf.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index a6fda75..99243ce 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -911,8 +911,8 @@ m_cat(struct mbuf *m, struct mbuf *n) while (m->m_next) m = m->m_next; while (n) { - if (m->m_flags & M_EXT || - m->m_data + m->m_len + n->m_len >= &m->m_dat[MLEN]) { + if (!M_WRITABLE(m) || + M_TRAILINGSPACE(m) < n->m_len) { /* just join the two chains */ m->m_next = n; return; @@ -1584,7 +1584,7 @@ again: n = m->m_next; if (n == NULL) break; - if ((m->m_flags & M_RDONLY) == 0 && + if (M_WRITABLE(m) && n->m_len < M_TRAILINGSPACE(m)) { bcopy(mtod(n, void *), mtod(m, char *) + m->m_len, n->m_len); |