Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Oct 2012 18:38:51 +0000 (UTC)
From:      Andre Oppermann <andre@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r242256 - head/sys/kern
Message-ID:  <201210281838.q9SIcpiW074181@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andre
Date: Sun Oct 28 18:38:51 2012
New Revision: 242256
URL: http://svn.freebsd.org/changeset/base/242256

Log:
  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

Modified:
  head/sys/kern/uipc_mbuf.c

Modified: head/sys/kern/uipc_mbuf.c
==============================================================================
--- head/sys/kern/uipc_mbuf.c	Sun Oct 28 18:33:52 2012	(r242255)
+++ head/sys/kern/uipc_mbuf.c	Sun Oct 28 18:38:51 2012	(r242256)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210281838.q9SIcpiW074181>