summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_sockbuf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-09-18 10:30:10 +0000
committerrwatson <rwatson@FreeBSD.org>2005-09-18 10:30:10 +0000
commit1f480761492615d539935040c48d69531804ae62 (patch)
treef4c9e8a4c05ce3fb744256fd303448d6fa8d05c8 /sys/kern/uipc_sockbuf.c
parente329b23e49461ee46c2e94fd53638ee61ad7eed5 (diff)
downloadFreeBSD-src-1f480761492615d539935040c48d69531804ae62.zip
FreeBSD-src-1f480761492615d539935040c48d69531804ae62.tar.gz
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. MFC after: 3 days
Diffstat (limited to 'sys/kern/uipc_sockbuf.c')
-rw-r--r--sys/kern/uipc_sockbuf.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index e979251..16fa1f8 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.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);
}
OpenPOWER on IntegriCloud