svn commit: r267271 - projects/sendfile/sys/kern

Gleb Smirnoff glebius at FreeBSD.org
Mon Jun 9 14:24:42 UTC 2014


Author: glebius
Date: Mon Jun  9 14:24:41 2014
New Revision: 267271
URL: http://svnweb.freebsd.org/changeset/base/267271

Log:
  - Relax assertion in sb_shift_nrdy(), there is corner case when it
    is not held.
  - Make sbready() capable to work not only on send buffer, but on
    receive buffers, as well. Caller should lock the buffer and
    check that it can SEND/RECVMORE.
  
  Sponsored by:	Netflix
  Sponsored by:	Nginx, Inc.

Modified:
  projects/sendfile/sys/kern/uipc_sockbuf.c

Modified: projects/sendfile/sys/kern/uipc_sockbuf.c
==============================================================================
--- projects/sendfile/sys/kern/uipc_sockbuf.c	Mon Jun  9 14:18:24 2014	(r267270)
+++ projects/sendfile/sys/kern/uipc_sockbuf.c	Mon Jun  9 14:24:41 2014	(r267271)
@@ -72,7 +72,9 @@ static void
 sb_shift_nrdy(struct sockbuf *sb, struct mbuf *m)
 {
 
+#if 0	/* XXX: not yet: soclose() call path comes here w/o lock. */
 	SOCKBUF_LOCK_ASSERT(sb);
+#endif
 	KASSERT(m->m_flags & M_NOTREADY, ("%s: m %p !M_NOTREADY", __func__, m));
 
 	m = m->m_next;
@@ -90,12 +92,7 @@ sbready(struct sockbuf *sb, struct mbuf 
 {
 	u_int blocker;
 
-	SOCKBUF_LOCK(sb);
-
-	if (sb->sb_state & SBS_CANTSENDMORE) {
-		SOCKBUF_UNLOCK(sb);
-		return (ENOTCONN);
-	}
+	SOCKBUF_LOCK_ASSERT(sb);
 
 	KASSERT(sb->sb_fnrdy != NULL, ("%s: sb %p NULL fnrdy", __func__, sb));
 
@@ -109,10 +106,8 @@ sbready(struct sockbuf *sb, struct mbuf 
 			sb->sb_acc += m->m_len;
 	}
 
-	if (!blocker) {
-		SOCKBUF_UNLOCK(sb);
-		return (EWOULDBLOCK);
-	}
+	if (!blocker)
+		return (EINPROGRESS);
 
 	/* This one was blocking all the queue. */
 	for (; m && (m->m_flags & M_NOTREADY) == 0; m = m->m_next) {
@@ -124,8 +119,6 @@ sbready(struct sockbuf *sb, struct mbuf 
 
 	sb->sb_fnrdy = m;
 
-	SOCKBUF_UNLOCK(sb);
-
 	return (0);
 }
 


More information about the svn-src-projects mailing list