If a large mbuf in the source socket buffer does not fit into the
drain buffer, split the mbuf. But if the drain buffer still has
some data in it, stop moving data and try again later. This skips
a potentially expensive mbuf operation.
When looking which socket buffer has to be locked, I found that the
length of the source send buffer was checked. Change it to drain.
As this is a performance optimization for a special corner case,
noone noticed the bug.
OK sashan@
-/* $OpenBSD: uipc_socket.c,v 1.337 2024/07/12 17:20:18 mvs Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.338 2024/07/14 15:42:23 bluhm Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
* Move only a partial mbuf at maximum splice length or
* if the drain buffer is too small for this large mbuf.
*/
- if (!maxreached && so->so_snd.sb_datacc > 0) {
+ if (!maxreached && sosp->so_snd.sb_datacc > 0) {
len -= size;
break;
}