From 5c4501f2732f323269274241bf8609e54a6778d0 Mon Sep 17 00:00:00 2001 From: bluhm Date: Sun, 14 Jul 2024 15:42:23 +0000 Subject: [PATCH] Fix source and drain confusion in socket splicing somove(). 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@ --- sys/kern/uipc_socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a2dfc010589..a17ac58eaba 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -1690,7 +1690,7 @@ somove(struct socket *so, int wait) * 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; } -- 2.20.1