summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2016-11-23 13:05:54 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2016-11-23 13:05:54 +0000
commitd0cfdf9a68a5e92978db1f9993c5d29b4898e7d2 (patch)
treec1f0c472988f61c3899eac921b532f61ec1fff4e /sys/kern
parent0702e6ae83100e0c0382f64eadf0ed7acd29f8a9 (diff)
Some socket splicing tests on loopback hang with large mbufs and
reduced buffer size. If the send buffer size is less than the size of a single mbuf, it will never fit. So if the send buffer is empty, split the large mbuf and move only a part. OK claudio@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_socket.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 552b555c164..691ae2fb4f0 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.166 2016/11/22 10:29:39 mpi Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.167 2016/11/23 13:05:53 bluhm Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1367,8 +1367,16 @@ somove(struct socket *so, int wait)
"m_type %d", so, so->so_type, *mp, (*mp)->m_type);
#endif
if ((*mp)->m_len > size) {
- if (!maxreached || (*mp = m_copym(
- so->so_rcv.sb_mb, 0, size, wait)) == NULL) {
+ /*
+ * 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) {
+ len -= size;
+ break;
+ }
+ *mp = m_copym(so->so_rcv.sb_mb, 0, size, wait);
+ if (*mp == NULL) {
len -= size;
break;
}