svn commit: r232617 - user/andre/tcp_workqueue/sys/kern

Andre Oppermann andre at FreeBSD.org
Tue Mar 6 19:43:27 UTC 2012


Author: andre
Date: Tue Mar  6 19:43:26 2012
New Revision: 232617
URL: http://svn.freebsd.org/changeset/base/232617

Log:
  In soreceive_stream() don't drop an already dequeued mbuf chain by
  overwriting the return mbuf pointer with newly received data after
  a loop.  Instead append the new mbuf chain to the existing one.
  
  Fix up sb_lastrecord when dequeuing mbuf's so that sbappend_stream()
  doesn't get confused.
  
  For the remainder copy case in the mbuf delivery part deduct the
  copied length len instead of the whole mbuf length.  Additionally
  don't depend on 'n' being being available which isn't true in the
  case of MSG_PEEK.
  
  Submitted by:	trociny (slightly different version)

Modified:
  user/andre/tcp_workqueue/sys/kern/uipc_socket.c

Modified: user/andre/tcp_workqueue/sys/kern/uipc_socket.c
==============================================================================
--- user/andre/tcp_workqueue/sys/kern/uipc_socket.c	Tue Mar  6 19:19:33 2012	(r232616)
+++ user/andre/tcp_workqueue/sys/kern/uipc_socket.c	Tue Mar  6 19:43:26 2012	(r232617)
@@ -2044,7 +2044,7 @@ deliver:
 	if (mp0 != NULL) {
 		/* Dequeue as many mbufs as possible. */
 		if (!(flags & MSG_PEEK) && len >= sb->sb_mb->m_len) {
-			for (*mp0 = m = sb->sb_mb;
+			for (m = sb->sb_mb;
 			     m != NULL && m->m_len <= len;
 			     m = m->m_next) {
 				len -= m->m_len;
@@ -2052,10 +2052,15 @@ deliver:
 				sbfree(sb, m);
 				n = m;
 			}
+			n->m_next = NULL;
 			sb->sb_mb = m;
+			sb->sb_lastrecord = sb->sb_mb;
 			if (sb->sb_mb == NULL)
 				SB_EMPTY_FIXUP(sb);
-			n->m_next = NULL;
+			if (*mp0 != NULL)
+				m_cat(*mp0, m);
+			else
+				*mp0 = m;
 		}
 		/* Copy the remainder. */
 		if (len > 0) {
@@ -2066,9 +2071,9 @@ deliver:
 			if (m == NULL)
 				len = 0;	/* Don't flush data from sockbuf. */
 			else
-				uio->uio_resid -= m->m_len;
+				uio->uio_resid -= len;
 			if (*mp0 != NULL)
-				n->m_next = m;
+				m_cat(*mp0, m);
 			else
 				*mp0 = m;
 			if (*mp0 == NULL) {


More information about the svn-src-user mailing list