Hi,
I have seen a hang in my socket splicing test on loopback 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?
bluhm
Index: kern/uipc_socket.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.164
diff -u -p -r1.164 uipc_socket.c
--- kern/uipc_socket.c 14 Nov 2016 08:45:30 -0000 1.164
+++ kern/uipc_socket.c 16 Nov 2016 19:01:35 -0000
@@ -1365,8 +1365,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 lenght 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;
}