From 37c366558223098bc7a67e95782260bbd5da37f2 Mon Sep 17 00:00:00 2001 From: rwatson Date: Wed, 21 Sep 2005 15:30:54 +0000 Subject: [PATCH] Merge uipc_socket2.c:1.148 from HEAD to RELENG_6: Re-comment sbcompress() to explain what it is it does; it took me quite a bit of reading to figure it out, and I want to avoid figuring it out again. Convert an if (foo) else printf("this is almost a panic") into a KASSERT. Approved by: re (scottl) --- sys/kern/uipc_socket2.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index e979251dd940..16fa1f8ad8e7 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1027,9 +1027,24 @@ sbappendcontrol(sb, m0, control) } /* - * Compress mbuf chain m into the socket - * buffer sb following mbuf n. If n - * is null, the buffer is presumed empty. + * Append the data in mbuf chain (m) into the socket buffer sb following mbuf + * (n). If (n) is NULL, the buffer is presumed empty. + * + * When the data is compressed, mbufs in the chain may be handled in one of + * three ways: + * + * (1) The mbuf may simply be dropped, if it contributes nothing (no data, no + * record boundary, and no change in data type). + * + * (2) The mbuf may be coalesced -- i.e., data in the mbuf may be copied into + * an mbuf already in the socket buffer. This can occur if an + * appropriate mbuf exists, there is room, and no merging of data types + * will occur. + * + * (3) The mbuf may be appended to the end of the existing mbuf chain. + * + * If any of the new mbufs is marked as M_EOR, mark the last mbuf appended as + * end-of-record. */ void sbcompress(sb, m, n) @@ -1080,10 +1095,8 @@ sbcompress(sb, m, n) n->m_next = 0; } if (eor) { - if (n) - n->m_flags |= eor; - else - printf("semi-panic: sbcompress\n"); + KASSERT(n != NULL, ("sbcompress: eor && n == NULL")); + n->m_flags |= eor; } SBLASTMBUFCHK(sb); }